gpio.h File Reference

Low-level GPIO peripheral driver interface definitions. More...

Detailed Description

Low-level GPIO peripheral driver interface definitions.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file gpio.h.

#include <limits.h>
#include "periph_cpu.h"
#include "periph_conf.h"
+ Include dependency graph for gpio.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gpio_isr_ctx_t
 Default interrupt context for GPIO pins. More...
 

Macros

#define GPIO_PIN(x, y)   ((gpio_t)((x & 0) | y))
 Convert (port, pin) tuple to gpio_t value.
 
#define GPIO_UNDEF   ((gpio_t)(UINT_MAX))
 GPIO pin not defined.
 

Typedefs

typedef unsigned int gpio_t
 GPIO type identifier.
 
typedef void(* gpio_cb_t) (void *arg)
 Signature of event callback functions triggered from interrupts. More...
 

Enumerations

enum  gpio_mode_t {
  GPIO_IN = GPIOHANDLE_REQUEST_INPUT , GPIO_IN_PD = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_DOWN , GPIO_IN_PU = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_UP , GPIO_OUT = GPIOHANDLE_REQUEST_OUTPUT ,
  GPIO_OD = GPIOHANDLE_REQUEST_OPEN_DRAIN , GPIO_OD_PU = GPIOHANDLE_REQUEST_OPEN_DRAIN | GPIOHANDLE_REQUEST_PULL_UP , GPIO_IN , GPIO_IN_PD ,
  GPIO_IN_PU , GPIO_OUT , GPIO_OD , GPIO_OD_PU
}
 Available pin modes. More...
 
enum  gpio_flank_t {
  GPIO_ISC_BOTH = (0 << 4) , GPIO_ISC_RISING = (1 << 4) , GPIO_ISC_FALLING = (2 << 4) , GPIO_ISC_LOW_LEVEL = (3 << 4) ,
  GPIO_INT_DISABLED_ALL = (1 << 3) , GPIO_INT0_VCT = (0 << 2) , GPIO_INT1_VCT = (1 << 2) , GPIO_LVL_OFF = (0 << 0) ,
  GPIO_LVL_LOW = (1 << 0) , GPIO_LVL_MID = (2 << 0) , GPIO_LVL_HIGH = (3 << 0) , GPIO_FALLING = GPIO_ISC_FALLING | GPIO_LVL_LOW ,
  GPIO_RISING = GPIO_ISC_RISING | GPIO_LVL_LOW , GPIO_BOTH = GPIO_ISC_BOTH | GPIO_LVL_LOW , GPIO_FALLING = GPIOEVENT_EVENT_FALLING_EDGE , GPIO_RISING = GPIOEVENT_EVENT_RISING_EDGE ,
  GPIO_BOTH = GPIO_FALLING | GPIO_RISING , GPIO_LEVEL_LOW = 0x1 , GPIO_LEVEL_HIGH = 0x2 , GPIO_FALLING = 0x4 ,
  GPIO_RISING = 0x8 , GPIO_BOTH = 0xc , GPIO_FALLING = 0 , GPIO_RISING = 1 ,
  GPIO_BOTH = 2
}
 Definition of possible active flanks for external interrupt mode. More...
 

Functions

int gpio_init (gpio_t pin, gpio_mode_t mode)
 Initialize the given pin as general purpose input or output. More...
 
int gpio_init_int (gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, gpio_cb_t cb, void *arg)
 Initialize a GPIO pin for external interrupt usage. More...
 
void gpio_irq_enable (gpio_t pin)
 Enable pin interrupt if configured as interrupt source. More...
 
void gpio_irq_disable (gpio_t pin)
 Disable the pin interrupt if configured as interrupt source. More...
 
int gpio_read (gpio_t pin)
 Get the current value of the given pin. More...
 
void gpio_set (gpio_t pin)
 Set the given pin to HIGH. More...
 
void gpio_clear (gpio_t pin)
 Set the given pin to LOW. More...
 
void gpio_toggle (gpio_t pin)
 Toggle the value of the given pin. More...
 
void gpio_write (gpio_t pin, int value)
 Set the given pin to the given value. More...
 
static int gpio_is_equal (gpio_t gpio1, gpio_t gpio2)
 Test if a GPIO pin is equal to another GPIO pin. More...
 
static int gpio_is_valid (gpio_t gpio)
 Test if a GPIO pin is a valid pin and not declared as undefined. More...