DRV_GPIO
DRV_GPIO API Status
API |
|---|
DRV_GPIO API Reference
Header File
Functions
-
int32_t drv_gpio_initialise(void)
gpio driver initialise.
gpio driver的初始化,主要是中断的注册,开机的时候调用一次
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_gpio_pin_config_pull(uint32_t gpio_pin_id, bool pull_en, bool pull_down)
config gpio pull.
设置gpio的上拉/下拉,或者不进行上下拉
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM
pull_en – [in] true: enable pull false: disable pull
pull_down – [in] true: pull down false: pull up (it works only when pull_en is true)
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_gpio_pin_config_output(uint32_t gpio_pin_id, bool output_en, bool out_high)
config gpio output.
配置gpio的输出功能,是否输出,输出高还是低
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1
output_en – [in] output enable, true: enable false: disable output
out_high – [in] true: output 1 false: output 0 (it works only when output_en is true)
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_gpio_pin_output_reverse(uint32_t gpio_pin_id)
reverse gpio output value.
reverse gpio output value
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_gpio_pin_enable_input(uint32_t gpio_pin_id, bool input_en)
enable gpio input function or not.
是否打开gpio的输入功能
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1
input_en – [in] true: enable input function false: disable input function
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
uint32_t drv_gpio_pin_get_input(uint32_t gpio_pin_id)
get input value.
获取当前gpio的输入值,0(低电平) 1(高电平)
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1
- 返回:
input value
-
int32_t drv_gpio_pin_reg_intr_callback(uint32_t gpio_pin_id, drv_gpio_intr_cond_e e_type, pfunc_gpio_cb_t pfn_cb)
register gpio callback.
注册GPIO的中断处理函数,如果想关掉中断,将参数pfn_cb赋为NULL即可
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1
e_type – [in] 产生中断的条件, see drv_gpio_intr_cond_e
pfn_cb – [in] interrupt callback, disable interrupt if it is NULL
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_gpio_pin_enable_function(uint32_t gpio_pin_id, bool func_en, gpio_func_e e_func)
enable gpio peripheral function or not.
打开或关闭GPIO的外设功能
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1
func_en – [in] true: enable function false: disable function
e_func – [in] see gpio_func_e (it works only when func_en is true)
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_gpio_pin_enter_highz(uint32_t gpio_pin_id)
make the gpio enter high Z.
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_gpio_pin_set_driver_capacity(uint32_t gpio_pin_id, uint8_t value)
set gpio driver capacity.
- 参数:
gpio_pin_id – [in] gpio pin index, from 0 to GPIO_PIN_NUM-1]
value – [in] driver level, form 0 to 3
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
Macros
-
GPIO_PIN0
-
GPIO_PIN1
-
GPIO_PIN2
-
GPIO_PIN3
-
GPIO_PIN4
-
GPIO_PIN5
-
GPIO_PIN6
-
GPIO_PIN7
-
GPIO_PIN8
-
GPIO_PIN9
-
GPIO_PIN10
-
GPIO_PIN11
-
GPIO_PIN12
-
GPIO_PIN13
-
GPIO_PIN14
-
GPIO_PIN15
-
GPIO_PIN16
-
GPIO_PIN17
-
GPIO_PIN18
-
GPIO_PIN19
-
GPIO_PIN20
-
GPIO_PIN21
-
GPIO_PIN22
-
GPIO_PIN23
-
GPIO_PIN24
-
GPIO_PIN25
-
GPIO_PIN26
-
GPIO_PIN27
-
GPIO_PIN28
-
GPIO_PIN29
-
GPIO_PIN30
-
GPIO_PIN31
-
GPIO_OUT_HIGH(x)
-
GPIO_OUT_LOW(x)
Type Definitions
-
typedef enum _drv_gpio_intr_cond_e drv_gpio_intr_cond_e
gpio interrupt condition
-
typedef void (*pfunc_gpio_cb_t)(uint32_t gpio_pin_id)
GPIO interrupt callback.
Enumerations
-
enum _drv_gpio_intr_cond_e
gpio interrupt condition
Values:
-
enumerator DRV_GPIO_INTR_LOW_LVL
generate interrupt if gpio is low
-
enumerator DRV_GPIO_INTR_HIGH_LVL
generate interrupt if gpio is high
-
enumerator DRV_GPIO_INTR_POS_EDGE
generate interrupt if gpio is on the rising edage
-
enumerator DRV_GPIO_INTR_NEG_EDGE
generate interrupt if gpio is on the falling edage
-
enumerator DRV_GPIO_INTR_TYPE_MAX
not used
-
enumerator DRV_GPIO_INTR_LOW_LVL