这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

GPIO API 参考

GPIO

typedef void (*wm_drv_gpio_isr_t)(void *arg)

GPIO interrupt handler.

Param arg:

User registered data

wm_drv_gpio_fast_write(pin, value)

Fast write gpio with value 0 or 1, Please note that it is not thread safe.

wm_device_t *wm_drv_gpio_init(char *dev_name)

Initialize gpio dev, and configure gpio based on the device tree.

参数:

dev_name[in] like “gpio”, if device tree set

返回:

  • device handle: device handle, used wm_device_t

  • NULL: failed

int wm_drv_gpio_deinit(wm_device_t *dev)

Deinitialize gpio dev.

参数:

dev[in] use

  • wm_device_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_set_dir(wm_gpio_num_t pin, wm_gpio_dir_t dir)

Set gpio dir.

参数:
  • pin[in] use

    • wm_gpio_pin_num_t

  • dir[in] use

    • wm_gpio_dir_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_set_pullmode(wm_gpio_num_t pin, wm_gpio_pupd_t pullmode)

Set gpio pullmode.

参数:
  • pin[in] use

    • wm_gpio_pin_num_t

  • pullmode[in] use

    • wm_gpio_pupd_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_data_set(wm_gpio_num_t pin)

Write gpio with value 1.

警告

You should use this API after calling wm_drv_gpio_init.

参数:

pin[in] use

  • wm_gpio_num_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_data_reset(wm_gpio_num_t pin)

Write gpio with value 0.

警告

You should use this API after calling wm_drv_gpio_init.

参数:

pin[in] use

  • wm_gpio_num_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_data_get(wm_gpio_num_t pin)

Read gpio.

警告

You should use this API after calling wm_drv_gpio_init.

参数:

pin[in] use

  • wm_gpio_num_t

返回:

  • gpio value: 1 or 0

  • others: failed

int wm_drv_gpio_iomux_func_sel(wm_gpio_num_t pin, wm_gpio_pin_mux_t func)

Select iomux. please read wm_io_mux.h for pinmux cfg.

参数:
  • pin[in] use

    • wm_gpio_num_t

  • func[in] use

    • wm_gpio_pin_mux_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_enable_isr(wm_gpio_num_t pin)

Enable gpio irq.

参数:

pin[in] use

  • wm_gpio_num_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_disable_isr(wm_gpio_num_t pin)

Disable gpio irq.

参数:

pin[in] use

  • wm_gpio_num_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_set_intr_mode(wm_gpio_num_t pin, wm_gpio_intr_mode_t mode)

Set gpio intr mode.

参数:
  • pin[in] use

    • wm_gpio_num_t

  • mode[in] use

    • wm_gpio_intr_mode_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_add_isr_callback(wm_gpio_num_t gpio_num, wm_drv_gpio_isr_t isr_callback, void *args)

Add ISR handler for the corresponding GPIO pin.

警告

You should use this API after calling wm_drv_gpio_init.

参数:
  • gpio_num – GPIO number, If this pin is not set in the device tree, you need to initialize it separately

  • isr_callback – ISR handler function for the corresponding GPIO number.

  • args – parameter for ISR handler.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_gpio_remove_isr_callback(wm_gpio_num_t gpio_num)

Remove ISR handler for the corresponding GPIO pin.

警告

You should use this API after calling wm_drv_gpio_init.

参数:

gpio_num – GPIO number

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed