Gpio#

group bsp_gpio

GPIO management.

Author

Alexandre Abadie alexandre.abadie@inria.fr

Copyright

Inria, 2022-2023

Defines

DB_GPIO_ENABLE(port, pin)#

Enable a pin as output.

Enable a pin as output, must be called once before using the other macros below

DB_GPIO_ON(port, pin)#

Turn on the pin.

DB_GPIO_OFF(port, pin)#

Turn off the pin.

DB_GPIO_TOGGLE(port, pin)#

Toggle the pin.

Typedefs

typedef void (*gpio_cb_t)(void *ctx)#

Callback function prototype, it is called on each gpio interrupt.

Enums

enum gpio_mode_t#

GPIO mode.

Values:

enumerator DB_GPIO_OUT#

Floating output.

enumerator DB_GPIO_IN#

Floating input.

enumerator DB_GPIO_IN_PU#

Pull up input.

enumerator DB_GPIO_IN_PD#

Pull down input.

enum gpio_irq_edge_t#

GPIO interrupt edge.

Values:

enumerator DB_GPIO_IRQ_EDGE_RISING#

Rising edge.

enumerator DB_GPIO_IRQ_EDGE_FALLING#

Falling edge.

enumerator DB_GPIO_IRQ_EDGE_BOTH#

Both falling and rising edges.

Functions

void db_gpio_init(const gpio_t *gpio, gpio_mode_t mode)#

Initialize a GPIO.

Parameters:
  • gpio[in] Pointer to the GPIO descriptor

  • mode[in] GPIO mode (output, input, etc)

void db_gpio_init_irq(const gpio_t *gpio, gpio_mode_t mode, gpio_irq_edge_t edge, gpio_cb_t callback, void *ctx)#

Initialize a GPIO with IRQ.

Parameters:
  • gpio[in] Pointer to the GPIO descriptor

  • mode[in] GPIO mode, should one flavor of input

  • edge[in] Type of edge to trigger the IRQ (Falling, Rising or both)

  • callback[in] Function pointer that is called from gpio ISR

  • ctx[in] Pointer to some context passed as parameter to the callback

void db_gpio_set(const gpio_t *gpio)#

Set the GPIO output high.

Parameters:
  • gpio[in] Pointer to the GPIO descriptor

void db_gpio_clear(const gpio_t *gpio)#

Set the GPIO output low.

Parameters:
  • gpio[in] Pointer to the GPIO descriptor

void db_gpio_toggle(const gpio_t *gpio)#

Toggle the GPIO output.

Parameters:
  • gpio[in] Pointer to the GPIO descriptor

uint8_t db_gpio_read(const gpio_t *gpio)#

Read the value of a GPIO.

Parameters:
  • gpio[in] Pointer to the GPIO descriptor

Returns:

GPIO level (0 or 1)

Variables

static NRF_GPIO_Type *nrf_port[2] = {NRF_P0, NRF_P1}#
struct gpio_t#

GPIO instance.

Public Members

uint8_t port#

Port number of the GPIO.

uint8_t pin#

Pin number of the GPIO.