GPIO abstraction layer RIOT adaption. More...

Detailed Description

GPIO abstraction layer RIOT adaption.

Author
Francisco Molina franc.nosp@m.ois-.nosp@m.xavie.nosp@m.r.mo.nosp@m.lina@.nosp@m.inri.nosp@m.a.fr

Definition in file hal_gpio.h.

#include "periph/gpio.h"
+ Include dependency graph for hal_gpio.h:

Go to the source code of this file.

Typedefs

typedef gpio_mode_t hal_gpio_pull_t
 hal_gpio_pull type
 
typedef gpio_flank_t hal_gpio_irq_trig_t
 hal_gpio_irq_trig type
 
typedef gpio_cb_t hal_gpio_irq_handler_t
 Function proto for GPIO irq handler functions.
 

Enumerations

enum  { HAL_GPIO_PULL_NONE = GPIO_IN, HAL_GPIO_PULL_UP = GPIO_IN_PU, HAL_GPIO_PULL_DOWN = GPIO_IN_PD }
 Map hal_gpio_pull_t enum types to gpio_mode_t enum types. More...
 
enum  { HAL_GPIO_TRIG_RISING = GPIO_RISING, HAL_GPIO_TRIG_FALLING = GPIO_FALLING, HAL_GPIO_TRIG_BOTH = GPIO_BOTH }
 Map hal_gpio_irq_trig_t enum types to gpio_flank_t enum types. More...
 

Functions

static int hal_gpio_init_in (gpio_t pin, hal_gpio_pull_t pull)
 Initializes the specified pin as an input. More...
 
static int hal_gpio_init_out (gpio_t pin, int val)
 Initialize the specified pin as an output, setting the pin to the specified value. More...
 
static void hal_gpio_write (gpio_t pin, int val)
 Write a value (either high or low) to the specified pin. More...
 
static int hal_gpio_read (gpio_t pin)
 Reads the specified pin. More...
 
static int hal_gpio_toggle (gpio_t pin)
 Toggles the specified pin. More...
 
static int hal_gpio_irq_init (gpio_t pin, hal_gpio_irq_handler_t handler, void *arg, hal_gpio_irq_trig_t trig, hal_gpio_pull_t pull)
 Initialize a given pin to trigger a GPIO IRQ callback. More...
 
static void hal_gpio_irq_release (gpio_t pin)
 Release a pin from being configured to trigger IRQ on state change. More...
 
static void hal_gpio_irq_enable (gpio_t pin)
 Enable IRQs on the passed pin. More...
 
static void hal_gpio_irq_disable (gpio_t pin)
 Disable IRQs on the passed pin. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Map hal_gpio_pull_t enum types to gpio_mode_t enum types.

Enumerator
HAL_GPIO_PULL_NONE 

Pull-up/down not enabled.

HAL_GPIO_PULL_UP 

Pull-up enabled.

HAL_GPIO_PULL_DOWN 

Pull-down enabled.

Definition at line 32 of file hal_gpio.h.

◆ anonymous enum

anonymous enum

Map hal_gpio_irq_trig_t enum types to gpio_flank_t enum types.

Enumerator
HAL_GPIO_TRIG_RISING 

IRQ occurs on rising edge.

HAL_GPIO_TRIG_FALLING 

IRQ occurs on falling edge.

HAL_GPIO_TRIG_BOTH 

IRQ occurs on either edge.

Definition at line 48 of file hal_gpio.h.

Function Documentation

◆ hal_gpio_init_in()

static int hal_gpio_init_in ( gpio_t  pin,
hal_gpio_pull_t  pull 
)
inlinestatic

Initializes the specified pin as an input.

Parameters
pinPin number to set as input
pullpull type
Returns
int 0: no error; -1 otherwise.

Definition at line 85 of file hal_gpio.h.

◆ hal_gpio_init_out()

static int hal_gpio_init_out ( gpio_t  pin,
int  val 
)
inlinestatic

Initialize the specified pin as an output, setting the pin to the specified value.

Parameters
pinPin number to set as output
valValue to set pin
Returns
int 0: no error; -1 otherwise.

Definition at line 99 of file hal_gpio.h.

◆ hal_gpio_irq_disable()

static void hal_gpio_irq_disable ( gpio_t  pin)
inlinestatic

Disable IRQs on the passed pin.

Parameters
pinThe pin to disable IRQs on

Definition at line 188 of file hal_gpio.h.

◆ hal_gpio_irq_enable()

static void hal_gpio_irq_enable ( gpio_t  pin)
inlinestatic

Enable IRQs on the passed pin.

Parameters
pinThe pin to enable IRQs on

Definition at line 178 of file hal_gpio.h.

◆ hal_gpio_irq_init()

static int hal_gpio_irq_init ( gpio_t  pin,
hal_gpio_irq_handler_t  handler,
void *  arg,
hal_gpio_irq_trig_t  trig,
hal_gpio_pull_t  pull 
)
inlinestatic

Initialize a given pin to trigger a GPIO IRQ callback.

Parameters
pinThe pin to trigger GPIO interrupt on
handlerThe handler function to call
argThe argument to provide to the IRQ handler
trigThe trigger mode (e.g. rising, falling)
pullThe mode of the pin (e.g. pullup, pulldown)
Returns
0 on success, non-zero error code on failure.

Definition at line 153 of file hal_gpio.h.

◆ hal_gpio_irq_release()

static void hal_gpio_irq_release ( gpio_t  pin)
inlinestatic

Release a pin from being configured to trigger IRQ on state change.

Parameters
pinThe pin to release

Definition at line 167 of file hal_gpio.h.

◆ hal_gpio_read()

static int hal_gpio_read ( gpio_t  pin)
inlinestatic

Reads the specified pin.

Parameters
pinPin number to read
Returns
int 0: low, 1: high

Definition at line 124 of file hal_gpio.h.

◆ hal_gpio_toggle()

static int hal_gpio_toggle ( gpio_t  pin)
inlinestatic

Toggles the specified pin.

Parameters
pinPin number to toggle
Returns
current gpio state int 0: low, 1: high

Definition at line 136 of file hal_gpio.h.

◆ hal_gpio_write()

static void hal_gpio_write ( gpio_t  pin,
int  val 
)
inlinestatic

Write a value (either high or low) to the specified pin.

Parameters
pinPin to set
valValue to set pin (0:low 1:high)

Definition at line 112 of file hal_gpio.h.