Wirepas SDK
|
Board-independent GPIO functions. More...
Board-independent GPIO functions.
Definition in file gpio.h.
Go to the source code of this file.
Typedefs | |
typedef uint8_t | gpio_id_t |
GPIO identification number. More... | |
typedef uint8_t | gpio_port_t |
GPIO port number. More... | |
typedef uint8_t | gpio_pin_t |
GPIO pin number. More... | |
typedef void(* | gpio_in_event_cb_f) (gpio_id_t id, gpio_in_event_e event) |
Callback structure for a GPIO event. More... | |
Functions | |
gpio_res_e | Gpio_init (void) |
Initialize GPIO module. More... | |
gpio_res_e | Gpio_inputSetCfg (gpio_id_t id, const gpio_in_cfg_t *in_cfg) |
Configure a GPIO as an input GPIO. More... | |
gpio_res_e | Gpio_inputRead (gpio_id_t id, gpio_level_e *level) |
Read the GPIO input level. More... | |
gpio_res_e | Gpio_outputSetCfg (gpio_id_t id, const gpio_out_cfg_t *out_cfg) |
Configure a GPIO as an output GPIO. More... | |
gpio_res_e | Gpio_outputWrite (gpio_id_t id, gpio_level_e level) |
Write GPIO output level. More... | |
gpio_res_e | Gpio_outputToggle (gpio_id_t id) |
Toggle GPIO output level. More... | |
gpio_res_e | Gpio_outputRead (gpio_id_t id, gpio_level_e *level) |
Read the GPIO output level. More... | |
gpio_res_e | Gpio_getPin (gpio_id_t id, gpio_port_t *port, gpio_pin_t *pin) |
Get the GPIO port and pin numbers of the given GPIO id. More... | |
uint8_t | Gpio_getNumber (void) |
Get the number of GPIOs. More... | |
Data Structures | |
struct | gpio_in_cfg_t |
GPIO input configuration. More... | |
struct | gpio_out_cfg_t |
GPIO output configuration. More... | |
Enumerations | |
enum | gpio_res_e { GPIO_RES_OK = 0, GPIO_RES_UNINITIALIZED = 1, GPIO_RES_NOT_IMPLEMENTED = 2, GPIO_RES_INVALID_PARAM = 3, GPIO_RES_INVALID_PIN = 4, GPIO_RES_INVALID_DIRECTION = 5, GPIO_RES_NO_FREE_IT = 6 } |
List of return code. More... | |
enum | gpio_level_e { GPIO_LEVEL_LOW, GPIO_LEVEL_HIGH } |
GPIO logical level. More... | |
enum | gpio_in_mode_cfg_e { GPIO_IN_DISABLED, GPIO_IN_PULL_NONE, GPIO_IN_PULL_DOWN, GPIO_IN_PULL_UP } |
GPIO pull configuration. More... | |
enum | gpio_out_mode_cfg_e { GPIO_OUT_MODE_PUSH_PULL, GPIO_OUT_MODE_OPEN_DRAIN, GPIO_OUT_MODE_OPEN_DRAIN_WITH_PULL_UP } |
GPIO operating mode configuration. More... | |
enum | gpio_in_event_e { GPIO_IN_EVENT_NONE = 0, GPIO_IN_EVENT_RISING_EDGE = 1U << 0U, GPIO_IN_EVENT_FALLING_EDGE = 1U << 1U } |
GPIO event. More... | |
Macros | |
#define | IS_RISING_EDGE(event) ((event & GPIO_IN_EVENT_RISING_EDGE) == GPIO_IN_EVENT_RISING_EDGE) |
Check if event has its rising edge bit set. More... | |
#define | IS_FALLING_EDGE(event) ((event & GPIO_IN_EVENT_FALLING_EDGE) == GPIO_IN_EVENT_FALLING_EDGE) |
Check if event has its falling edge bit set. More... | |
typedef void(* gpio_in_event_cb_f) (gpio_id_t id, gpio_in_event_e event) |
typedef uint8_t gpio_pin_t |
typedef uint8_t gpio_port_t |
uint8_t Gpio_getNumber | ( | void | ) |
Get the number of GPIOs.
gpio_res_e Gpio_getPin | ( | gpio_id_t | id, |
gpio_port_t * | port, | ||
gpio_pin_t * | pin | ||
) |
Get the GPIO port and pin numbers of the given GPIO id.
id | Id of the GPIO | |
[out] | port | Returned GPIO port number |
[out] | pin | Returned GPIO pin number |
gpio_res_e Gpio_init | ( | void | ) |
Initialize GPIO module.
Example on use:
gpio_res_e Gpio_inputRead | ( | gpio_id_t | id, |
gpio_level_e * | level | ||
) |
Read the GPIO input level.
id | Id of the GPIO | |
[out] | level | Returned GPIO level (low or high) |
gpio_res_e Gpio_inputSetCfg | ( | gpio_id_t | id, |
const gpio_in_cfg_t * | in_cfg | ||
) |
Configure a GPIO as an input GPIO.
id | Id of the GPIO | |
[in] | in_cfg | GPIO input configuration |
gpio_res_e Gpio_outputRead | ( | gpio_id_t | id, |
gpio_level_e * | level | ||
) |
Read the GPIO output level.
id | Id of the GPIO | |
[out] | level | Returned GPIO level (low or high) |
gpio_res_e Gpio_outputSetCfg | ( | gpio_id_t | id, |
const gpio_out_cfg_t * | out_cfg | ||
) |
Configure a GPIO as an output GPIO.
id | Id of the GPIO | |
[in] | out_cfg | GPIO output configuration |
gpio_res_e Gpio_outputToggle | ( | gpio_id_t | id | ) |
Toggle GPIO output level.
id | Id of the GPIO |
gpio_res_e Gpio_outputWrite | ( | gpio_id_t | id, |
gpio_level_e | level | ||
) |
Write GPIO output level.
id | Id of the GPIO |
level | GPIO level (low or high) to write |
struct gpio_in_cfg_t |
Data Fields | ||
---|---|---|
gpio_in_event_cb_f | event_cb |
Callback called on GPIO events |
gpio_in_event_e | event_cfg: 2 |
Event configuration. Use | (OR) operator to detect both rising and falling edges. e.g.: .event_cfg = (GPIO_IN_EVENT_RISING_EDGE | GPIO_IN_EVENT_FALLING_EDGE) |
gpio_in_mode_cfg_e | in_mode_cfg: 2 |
Pull configuration (e.g.: Pull-down) |
struct gpio_out_cfg_t |
Data Fields | ||
---|---|---|
gpio_level_e | level_default: 1 |
GPIO default logical level (e.g.: Low) |
gpio_out_mode_cfg_e | out_mode_cfg: 2 |
Operating mode configuration (e.g.: Push-pull) |
enum gpio_in_event_e |
enum gpio_in_mode_cfg_e |
enum gpio_level_e |
enum gpio_out_mode_cfg_e |
enum gpio_res_e |
List of return code.
Definition at line 27 of file gpio.h.
#define IS_FALLING_EDGE | ( | event | ) | ((event & GPIO_IN_EVENT_FALLING_EDGE) == GPIO_IN_EVENT_FALLING_EDGE) |
#define IS_RISING_EDGE | ( | event | ) | ((event & GPIO_IN_EVENT_RISING_EDGE) == GPIO_IN_EVENT_RISING_EDGE) |