Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yunke120
rt-thread
提交
614f0a76
R
rt-thread
项目概览
yunke120
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
614f0a76
编写于
8月 19, 2020
作者:
G
guohp1128
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update nrf5x gpio driver
上级
e2263acd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
119 addition
and
0 deletion
+119
-0
bsp/nrf5x/libraries/drivers/drv_gpio.c
bsp/nrf5x/libraries/drivers/drv_gpio.c
+119
-0
未找到文件。
bsp/nrf5x/libraries/drivers/drv_gpio.c
浏览文件 @
614f0a76
...
...
@@ -46,6 +46,24 @@ static const struct pin_index pins[] =
__NRF5X_PIN
(
29
,
0
,
29
),
__NRF5X_PIN
(
30
,
0
,
30
),
__NRF5X_PIN
(
31
,
0
,
31
),
#ifdef SOC_NRF52840
__NRF5X_PIN
(
32
,
1
,
0
),
__NRF5X_PIN
(
33
,
1
,
1
),
__NRF5X_PIN
(
34
,
1
,
2
),
__NRF5X_PIN
(
35
,
1
,
3
),
__NRF5X_PIN
(
36
,
1
,
4
),
__NRF5X_PIN
(
37
,
1
,
5
),
__NRF5X_PIN
(
38
,
1
,
6
),
__NRF5X_PIN
(
39
,
1
,
7
),
__NRF5X_PIN
(
40
,
1
,
8
),
__NRF5X_PIN
(
41
,
1
,
9
),
__NRF5X_PIN
(
42
,
1
,
10
),
__NRF5X_PIN
(
43
,
1
,
11
),
__NRF5X_PIN
(
44
,
1
,
12
),
__NRF5X_PIN
(
45
,
1
,
13
),
__NRF5X_PIN
(
46
,
1
,
14
),
__NRF5X_PIN
(
47
,
1
,
15
),
#endif
/* SOC_NRF52840 */
};
/* EVENTS_IN[n](n=0..7) and EVENTS_PORT */
...
...
@@ -356,4 +374,105 @@ int rt_hw_pin_init(void)
}
INIT_BOARD_EXPORT
(
rt_hw_pin_init
);
/* test GPIO write, read, input interrupt */
#define DK_BOARD_LED_1 13
#define DK_BOARD_LED_2 14
#define DK_BOARD_LED_3 15
#define DK_BOARD_LED_4 16
#define DK_BOARD_BUTTON_1 11
#define DK_BOARD_BUTTON_2 12
#define DK_BOARD_BUTTON_3 24
#define DK_BOARD_BUTTON_4 25
void
button_1_callback
(
void
*
args
)
{
static
int
flag1
=
0
;
if
(
flag1
==
0
)
{
flag1
=
1
;
rt_pin_write
(
DK_BOARD_LED_1
,
PIN_LOW
);
}
else
{
flag1
=
0
;
rt_pin_write
(
DK_BOARD_LED_1
,
PIN_HIGH
);
}
}
void
button_2_callback
(
void
*
args
)
{
static
int
flag2
=
0
;
if
(
flag2
==
0
)
{
flag2
=
1
;
rt_pin_write
(
DK_BOARD_LED_2
,
PIN_LOW
);
}
else
{
flag2
=
0
;
rt_pin_write
(
DK_BOARD_LED_2
,
PIN_HIGH
);
}
}
void
button_3_callback
(
void
*
args
)
{
static
int
flag3
=
0
;
if
(
flag3
==
0
)
{
flag3
=
1
;
rt_pin_write
(
DK_BOARD_LED_3
,
PIN_LOW
);
}
else
{
flag3
=
0
;
rt_pin_write
(
DK_BOARD_LED_3
,
PIN_HIGH
);
}
}
void
button_4_callback
(
void
*
args
)
{
static
int
flag4
=
0
;
if
(
flag4
==
0
)
{
flag4
=
1
;
rt_pin_write
(
DK_BOARD_LED_4
,
PIN_LOW
);
}
else
{
flag4
=
0
;
rt_pin_write
(
DK_BOARD_LED_4
,
PIN_HIGH
);
}
}
void
gpio_sample
(
void
)
{
rt_err_t
err_code
;
rt_pin_mode
(
DK_BOARD_LED_1
,
PIN_MODE_OUTPUT
);
rt_pin_mode
(
DK_BOARD_LED_2
,
PIN_MODE_OUTPUT
);
rt_pin_mode
(
DK_BOARD_LED_3
,
PIN_MODE_OUTPUT
);
rt_pin_mode
(
DK_BOARD_LED_4
,
PIN_MODE_OUTPUT
);
rt_pin_write
(
DK_BOARD_LED_1
,
PIN_HIGH
);
rt_pin_write
(
DK_BOARD_LED_2
,
PIN_HIGH
);
rt_pin_write
(
DK_BOARD_LED_3
,
PIN_HIGH
);
rt_pin_write
(
DK_BOARD_LED_4
,
PIN_HIGH
);
err_code
=
rt_pin_attach_irq
(
DK_BOARD_BUTTON_1
,
PIN_IRQ_MODE_FALLING
,
button_1_callback
,
(
void
*
)
true
);
//true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
rt_pin_irq_enable
(
DK_BOARD_BUTTON_1
,
PIN_IRQ_ENABLE
);
err_code
=
rt_pin_attach_irq
(
DK_BOARD_BUTTON_2
,
PIN_IRQ_MODE_FALLING
,
button_2_callback
,
(
void
*
)
true
);
//true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
rt_pin_irq_enable
(
DK_BOARD_BUTTON_2
,
PIN_IRQ_ENABLE
);
err_code
=
rt_pin_attach_irq
(
DK_BOARD_BUTTON_3
,
PIN_IRQ_MODE_FALLING
,
button_3_callback
,
(
void
*
)
true
);
//true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
rt_pin_irq_enable
(
DK_BOARD_BUTTON_3
,
PIN_IRQ_ENABLE
);
err_code
=
rt_pin_attach_irq
(
DK_BOARD_BUTTON_4
,
PIN_IRQ_MODE_FALLING
,
button_4_callback
,
(
void
*
)
false
);
//true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
rt_pin_irq_enable
(
DK_BOARD_BUTTON_4
,
PIN_IRQ_ENABLE
);
}
MSH_CMD_EXPORT
(
gpio_sample
,
gpio
sample
);
#endif
/* RT_USING_PIN */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录