#include <sdrv_common.h>
#include <sdrv_pinctrl.h>
#include <types.h>
Go to the source code of this file.
|
| status_t | sdrv_gpio_set_pin_direction (uint32_t pin_index, gpio_direction_e dir) |
| |
| status_t | sdrv_gpio_set_pin_output_level (uint32_t pin_index, bool level) |
| |
| bool | sdrv_gpio_get_pin_output_level (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_toggle_pin_output_level (uint32_t pin_index) |
| |
| bool | sdrv_gpio_read_pin_input_level (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_set_pin_interrupt (uint32_t pin_index, gpio_interrupt_e intr) |
| |
| status_t | sdrv_gpio_pin_interrupt_enable (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_pin_interrupt_disable (uint32_t pin_index) |
| |
| bool | sdrv_gpio_pin_interrupt_status (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_clear_pin_interrupt_status (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_set_pin_async_interrupt (uint32_t pin_index, gpio_interrupt_e intr) |
| |
| status_t | sdrv_gpio_pin_async_interrupt_enable (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_pin_async_interrupt_disable (uint32_t pin_index) |
| |
| bool | sdrv_gpio_pin_async_interrupt_status (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_clear_pin_async_interrupt_status (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_register_interrupt_handler (uint32_t pin_index, sdrv_gpio_interrupt_handler_t handler, void *arg) |
| |
| status_t | sdrv_gpio_unregister_interrupt_handler (uint32_t pin_index) |
| |
| status_t | sdrv_gpio_interrupt_share_with (uint32_t pin_index, uint32_t mask) |
| |
| status_t | sdrv_gpio_cancel_interrupt_share_with (uint32_t pin_index, uint32_t mask) |
| |
| status_t | sdrv_gpio_ctrl_set_pin_direction (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index, gpio_direction_e dir) |
| |
| status_t | sdrv_gpio_ctrl_set_pin_output_level (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index, bool level) |
| |
| status_t | sdrv_gpio_ctrl_toggle_pin_output_level (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| bool | sdrv_gpio_ctrl_read_pin_input_level (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| bool | sdrv_gpio_ctrl_get_pin_output_level (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| status_t | sdrv_gpio_ctrl_set_pin_interrupt (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index, gpio_interrupt_e intr) |
| |
| status_t | sdrv_gpio_ctrl_pin_interrupt_enable (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| status_t | sdrv_gpio_ctrl_pin_interrupt_disable (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| bool | sdrv_gpio_ctrl_pin_interrupt_status (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| status_t | sdrv_gpio_ctrl_clear_pin_interrupt_status (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| status_t | sdrv_gpio_ctrl_set_pin_async_interrupt (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index, gpio_interrupt_e intr) |
| |
| status_t | sdrv_gpio_ctrl_pin_async_interrupt_enable (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| status_t | sdrv_gpio_ctrl_pin_async_interrupt_disable (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| bool | sdrv_gpio_ctrl_pin_async_interrupt_status (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
| status_t | sdrv_gpio_ctrl_clear_pin_async_interrupt_status (sdrv_gpio_t *gpio_ctrl, uint32_t pin_index) |
| |
- Copyright
- Copyright (c) 2022 Semidrive Semiconductor. All rights reserved.
◆ gpio_direction_e
Definition for gpio direction.
◆ gpio_interrupt_e
Definition for gpio interrupt type.
◆ gpio_interrupt_share_e
Definition for gpio interrupt share with core bit mask.
◆ sdrv_gpio_interrupt_handler_t
| typedef void(* sdrv_gpio_interrupt_handler_t) (uint32_t irq, uint32_t pin, void *arg) |
Function prototype for gpio interrupt callback.
- Parameters
-
| [in] | irq | irq number occured. |
| [in] | pin | pin index defined in pinctrl.h. |
| [in] | arg | user register callback param. |
◆ sdrv_gpio_t
GPIO Controller Instance.
◆ gpio_direction
Definition for gpio direction.
| Enumerator |
|---|
| GPIO_DIR_OUT | gpio output
|
| GPIO_DIR_IN | gpio input
|
◆ gpio_interrupt
Definition for gpio interrupt type.
| Enumerator |
|---|
| GPIO_INTR_DISABLE | |
| GPIO_INTR_HIGH_LEVEL | |
| GPIO_INTR_LOW_LEVEL | |
| GPIO_INTR_RISING_EDGE | |
| GPIO_INTR_FALLING_EDGE | |
| GPIO_INTR_BOTH_EDGE | |
◆ gpio_interrupt_share
Definition for gpio interrupt share with core bit mask.
| Enumerator |
|---|
| GPIO_INTR_SF | Default GPIO interrupt send to SF
|
| GPIO_INTR_SP0 | GPIO interrupt share with SP0
|
| GPIO_INTR_SP1 | GPIO interrupt share with SP1
|
| GPIO_INTR_SX0 | GPIO interrupt share with SX0
|
| GPIO_INTR_SX1 | GPIO interrupt share with SX1
|
◆ sdrv_gpio_error
GPIO status error code.
| Enumerator |
|---|
| SDRV_GPIO_BAD_PIN | |
| SDRV_GPIO_CTRL_NULL | |
| SDRV_GPIO_IRQ_ATTACH_FAIL | |
◆ sdrv_gpio_cancel_interrupt_share_with()
| status_t sdrv_gpio_cancel_interrupt_share_with |
( |
uint32_t |
pin_index, |
|
|
uint32_t |
mask |
|
) |
| |
Cancel gpio interrupt share with other core.
This function cancel gpio interrupt with core sp or sx.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | mask | OR'ed value defined in gpio_interrupt_share_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_clear_pin_async_interrupt_status()
| status_t sdrv_gpio_clear_pin_async_interrupt_status |
( |
uint32_t |
pin_index | ) |
|
Clear specific pin asynchronous interrupt status.
This function clear pin asynchronous interrupt status. Only edge interrupt type need clear status, level type should inactive source level.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_clear_pin_interrupt_status()
| status_t sdrv_gpio_clear_pin_interrupt_status |
( |
uint32_t |
pin_index | ) |
|
Clear specific pin interrupt status.
This function clear pin interrupt status. Only edge interrupt type need clear status, level type should inactive source level.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_clear_pin_async_interrupt_status()
| status_t sdrv_gpio_ctrl_clear_pin_async_interrupt_status |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Clear specific pin asynchronous interrupt status.
This function clear pin asynchronous interrupt status. Only edge interrupt type need clear status, level type should inactive source level.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_clear_pin_interrupt_status()
| status_t sdrv_gpio_ctrl_clear_pin_interrupt_status |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Clear specific pin interrupt status.
This function clear pin interrupt status. Only edge interrupt type need clear status, level type should inactive source level.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_get_pin_output_level()
| bool sdrv_gpio_ctrl_get_pin_output_level |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Get gpio output level.
This function read gpio output data register for specific pin.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents high configed, false represents low configed.
◆ sdrv_gpio_ctrl_pin_async_interrupt_disable()
| status_t sdrv_gpio_ctrl_pin_async_interrupt_disable |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Disable asynchronous interrupt for specific pin.
This function config pin interrupt disable register and mask pin interrupt status.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_pin_async_interrupt_enable()
| status_t sdrv_gpio_ctrl_pin_async_interrupt_enable |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Enable asynchronous interrupt for specific pin.
This function config pin interrupt enable register and unmask pin interrupt status.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_pin_async_interrupt_status()
| bool sdrv_gpio_ctrl_pin_async_interrupt_status |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Get specific pin asynchronous interrupt status.
This function read pin asynchronous interrupt status register.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents interrupt status is set, false represents no interrupt status.
◆ sdrv_gpio_ctrl_pin_interrupt_disable()
Disable interrupt for specific pin.
This function config pin interrupt disable register and mask pin interrupt status.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_pin_interrupt_enable()
Enable interrupt for specific pin.
This function config pin interrupt enable register and unmask pin interrupt status.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_pin_interrupt_status()
| bool sdrv_gpio_ctrl_pin_interrupt_status |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Get specific pin interrupt status.
This function read pin interrupt status register.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents interrupt status is set, false represents no
◆ sdrv_gpio_ctrl_read_pin_input_level()
| bool sdrv_gpio_ctrl_read_pin_input_level |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Get specific pin input level.
This function read pin input level.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents high level, false represents low level.
◆ sdrv_gpio_ctrl_set_pin_async_interrupt()
Config asynchronous interrupt type for specific pin.
This function config pin as interrupt type using asynchronous way. Compare to normal interrupt way, asynchronous interrupt can also receive interrupt without clock, so it can be work in lowpower mode.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | intr | interrupt type defined in gpio_interrupt_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_set_pin_direction()
Config gpio direction.
This function config gpio as input or output.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | dir | direction defined as gpio_direction_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_set_pin_interrupt()
Config interrupt type for specific pin.
This function config pin as interrupt type, after configuration, you also need call sdrv_gpio_pin_interrupt_enable for starting receive interrupt.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | intr | interrupt type defined in gpio_interrupt_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_set_pin_output_level()
| status_t sdrv_gpio_ctrl_set_pin_output_level |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index, |
|
|
bool |
level |
|
) |
| |
Config gpio output level.
This function config gpio output high or low level.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | level | true represents high, false represents low. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_ctrl_toggle_pin_output_level()
| status_t sdrv_gpio_ctrl_toggle_pin_output_level |
( |
sdrv_gpio_t * |
gpio_ctrl, |
|
|
uint32_t |
pin_index |
|
) |
| |
Toggle specific pin output level.
This function toggle output level for specific pin, for example, if pin output high at first, after call this function, it will output low.
- Parameters
-
| [in] | gpio_ctrl | gpio instance. |
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_get_pin_output_level()
| bool sdrv_gpio_get_pin_output_level |
( |
uint32_t |
pin_index | ) |
|
Get gpio output level.
This function read gpio output data register for specific pin.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents high configed, false represents low configed.
◆ sdrv_gpio_interrupt_share_with()
| status_t sdrv_gpio_interrupt_share_with |
( |
uint32_t |
pin_index, |
|
|
uint32_t |
mask |
|
) |
| |
Set gpio interrupt share with other core.
This function set gpio interrupt with core sp or sx. Pin interrupt default send to sf only, if you want use other core handler this interrupt, you must share interrupt with core.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | mask | OR'ed value defined in gpio_interrupt_share_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_pin_async_interrupt_disable()
| status_t sdrv_gpio_pin_async_interrupt_disable |
( |
uint32_t |
pin_index | ) |
|
Disable asynchronous interrupt for specific pin.
This function config pin interrupt disable register and mask pin interrupt status.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_pin_async_interrupt_enable()
| status_t sdrv_gpio_pin_async_interrupt_enable |
( |
uint32_t |
pin_index | ) |
|
Enable asynchronous interrupt for specific pin.
This function config pin interrupt enable register and unmask pin interrupt status.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_pin_async_interrupt_status()
| bool sdrv_gpio_pin_async_interrupt_status |
( |
uint32_t |
pin_index | ) |
|
Get specific pin asynchronous interrupt status.
This function read pin asynchronous interrupt status register.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents interrupt status is set, false represents no interrupt status.
◆ sdrv_gpio_pin_interrupt_disable()
| status_t sdrv_gpio_pin_interrupt_disable |
( |
uint32_t |
pin_index | ) |
|
Disable interrupt for specific pin.
This function config pin interrupt disable register and mask pin interrupt status.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_pin_interrupt_enable()
| status_t sdrv_gpio_pin_interrupt_enable |
( |
uint32_t |
pin_index | ) |
|
Enable interrupt for specific pin.
This function config pin interrupt enable register and unmask pin interrupt status.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_pin_interrupt_status()
| bool sdrv_gpio_pin_interrupt_status |
( |
uint32_t |
pin_index | ) |
|
Get specific pin interrupt status.
This function read pin interrupt status register.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents interrupt status is set, false represents no
◆ sdrv_gpio_read_pin_input_level()
| bool sdrv_gpio_read_pin_input_level |
( |
uint32_t |
pin_index | ) |
|
Get specific pin input level.
This function read pin input level.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- true represents high level, false represents low level.
◆ sdrv_gpio_register_interrupt_handler()
Register interrupt callback function for specific pin.
This function register pin interrupt callback. It according to pin index getting irq number, and use irq_attach/irq_enable to enable it. Each 32 pin share one interrupt number.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | handler | callback function handler. |
| [in] | arg | callback function param. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_set_pin_async_interrupt()
Config asynchronous interrupt type for specific pin.
This function config pin as interrupt type using asynchronous way. Compare to normal interrupt way, asynchronous interrupt can also receive interrupt without clock, so it can be work in lowpower mode.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | intr | interrupt type defined in gpio_interrupt_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_set_pin_direction()
Config gpio direction.
This function config gpio as input or output.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | dir | direction defined as gpio_direction_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_set_pin_interrupt()
Config interrupt type for specific pin.
This function config pin as interrupt type, after configuration, you also need call sdrv_gpio_pin_interrupt_enable for starting receive interrupt.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | intr | interrupt type defined in gpio_interrupt_e. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_set_pin_output_level()
| status_t sdrv_gpio_set_pin_output_level |
( |
uint32_t |
pin_index, |
|
|
bool |
level |
|
) |
| |
Config gpio output level.
This function config gpio output high or low level.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
| [in] | level | true represents high, false represents low. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_toggle_pin_output_level()
| status_t sdrv_gpio_toggle_pin_output_level |
( |
uint32_t |
pin_index | ) |
|
Toggle specific pin output level.
This function toggle output level for specific pin, for example, if pin output high at first, after call this function, it will output low.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.
◆ sdrv_gpio_unregister_interrupt_handler()
| status_t sdrv_gpio_unregister_interrupt_handler |
( |
uint32_t |
pin_index | ) |
|
Unregister interrupt callback function for specific pin.
This function unregister pin interrupt callback. If it is last pin for its group interrupt number, irq_disable/irq_detach will be called.
- Parameters
-
| [in] | pin_index | defined pin macro in pinctrl.h. |
- Returns
- SDRV_STATUS_OK or error code.