Microchip® Advanced Software Framework

gpio.h File Reference
#include <avr32/io.h>
#include "compiler.h"

Data Structures

struct  gpio_map_t
 A type definition of pins and modules connectivity. More...
 

Macros

Return Values of the GPIO API
#define GPIO_SUCCESS   0
 Function successfully completed. More...
 
#define GPIO_INVALID_ARGUMENT   1
 Input parameters are out of range. More...
 
Interrupt Trigger Modes
#define GPIO_PIN_CHANGE   0
 Interrupt triggered upon pin change. More...
 
#define GPIO_RISING_EDGE   1
 Interrupt triggered upon rising edge. More...
 
#define GPIO_FALLING_EDGE   2
 Interrupt triggered upon falling edge. More...
 
Common defines for GPIO_FLAGS parameter
#define GPIO_DIR_INPUT   (0 << 0)
 Pin is Input. More...
 
#define GPIO_DIR_OUTPUT   (1 << 0)
 Pin is Output. More...
 
#define GPIO_INIT_LOW   (0 << 1)
 Initial Output State is Low. More...
 
#define GPIO_INIT_HIGH   (1 << 1)
 Initial Output State is High. More...
 
#define GPIO_PULL_UP   (1 << 2)
 Pull-Up (when input) More...
 
#define GPIO_PULL_DOWN   (2 << 2)
 Pull-Down (when input) More...
 
#define GPIO_BUSKEEPER   (3 << 2)
 Bus Keeper. More...
 
#define GPIO_DRIVE_MIN   (0 << 4)
 Drive Min Configuration. More...
 
#define GPIO_DRIVE_LOW   (1 << 4)
 Drive Low Configuration. More...
 
#define GPIO_DRIVE_HIGH   (2 << 4)
 Drive High Configuration. More...
 
#define GPIO_DRIVE_MAX   (3 << 4)
 Drive Max Configuration. More...
 
#define GPIO_OPEN_DRAIN   (1 << 6)
 Open-Drain (when output) More...
 
#define GPIO_INTERRUPT   (1 << 7)
 Enable Pin/Group Interrupt. More...
 
#define GPIO_BOTHEDGES   (3 << 7)
 Sense Both Edges. More...
 
#define GPIO_RISING   (5 << 7)
 Sense Rising Edge. More...
 
#define GPIO_FALLING   (7 << 7)
 Sense Falling Edge. More...
 

Functions

Peripheral Bus Interface

Low-speed interface with a non-deterministic number of clock cycles per access.

This interface operates with lower clock frequencies (fPB <= fCPU), and its timing is not deterministic since it needs to access a shared bus which may be heavily loaded.

Note
This interface is immediately available without initialization.
uint32_t gpio_enable_module (const gpio_map_t gpiomap, uint32_t size)
 Enables specific module modes for a set of pins. More...
 
uint32_t gpio_enable_module_pin (uint32_t pin, uint32_t function)
 Enables a specific module mode for a pin. More...
 
void gpio_enable_gpio (const gpio_map_t gpiomap, uint32_t size)
 Enables the GPIO mode of a set of pins. More...
 
void gpio_enable_gpio_pin (uint32_t pin)
 Enables the GPIO mode of a pin. More...
 
void gpio_enable_pin_pull_up (uint32_t pin)
 Enables the pull-up resistor of a pin. More...
 
void gpio_disable_pin_pull_up (uint32_t pin)
 Disables the pull-up resistor of a pin. More...
 
void gpio_configure_pin (uint32_t pin, uint32_t flags)
 Configuration functionality on a pin. More...
 
void gpio_configure_group (uint32_t port, uint32_t mask, uint32_t flags)
 Configuration functionality on a port. More...
 
bool gpio_get_pin_value (uint32_t pin)
 Returns the value of a pin. More...
 
static __always_inline bool gpio_pin_is_low (uint32_t pin)
 Check if the pin is in low logical level. More...
 
static __always_inline bool gpio_pin_is_high (uint32_t pin)
 Check if the pin is in high logical level. More...
 
bool gpio_get_gpio_pin_output_value (uint32_t pin)
 Returns the output value set for a GPIO pin. More...
 
bool gpio_get_gpio_open_drain_pin_output_value (uint32_t pin)
 Returns the output value set for a GPIO pin using open drain. More...
 
void gpio_set_gpio_pin (uint32_t pin)
 Drives a GPIO pin to 1. More...
 
void gpio_set_pin_high (uint32_t pin)
 Drives a GPIO pin to 1. More...
 
void gpio_set_group_high (uint32_t port, uint32_t mask)
 Drives a GPIO port to 1. More...
 
void gpio_clr_gpio_pin (uint32_t pin)
 Drives a GPIO pin to 0. More...
 
void gpio_set_pin_low (uint32_t pin)
 Drives a GPIO pin to 0. More...
 
void gpio_set_group_low (uint32_t port, uint32_t mask)
 Drives a GPIO port to 0. More...
 
void gpio_tgl_gpio_pin (uint32_t pin)
 Toggles a GPIO pin. More...
 
void gpio_toggle_pin (uint32_t pin)
 Toggles a GPIO pin. More...
 
void gpio_toggle_group (uint32_t port, uint32_t mask)
 Toggles a GPIO group. More...
 
void gpio_set_gpio_open_drain_pin (uint32_t pin)
 Drives a GPIO pin to 1 using open drain. More...
 
void gpio_clr_gpio_open_drain_pin (uint32_t pin)
 Drives a GPIO pin to 0 using open drain. More...
 
void gpio_tgl_gpio_open_drain_pin (uint32_t pin)
 Toggles a GPIO pin using open drain. More...
 
void gpio_enable_pin_glitch_filter (uint32_t pin)
 Enables the glitch filter of a pin. More...
 
void gpio_disable_pin_glitch_filter (uint32_t pin)
 Disables the glitch filter of a pin. More...
 
uint32_t gpio_enable_pin_interrupt (uint32_t pin, uint32_t mode)
 Enables the interrupt of a pin with the specified settings. More...
 
void gpio_disable_pin_interrupt (uint32_t pin)
 Disables the interrupt of a pin. More...
 
bool gpio_get_pin_interrupt_flag (uint32_t pin)
 Gets the interrupt flag of a pin. More...
 
void gpio_clear_pin_interrupt_flag (uint32_t pin)
 Clears the interrupt flag of a pin. More...
 
Local Bus Interface

High-speed interface with only one clock cycle per access.

This interface operates with high clock frequency (fCPU), and its timing is deterministic since it does not need to access a shared bus which may be heavily loaded.

Warning
To use this interface, the clock frequency of the peripheral bus on which the GPIO peripheral is connected must be set to the CPU clock frequency (fPB = fCPU).
Note
This interface has to be initialized in order to be available.
static __always_inline void gpio_local_init (void)
 Enables the local bus interface for GPIO. More...
 
static __always_inline void gpio_local_enable_pin_output_driver (uint32_t pin)
 Enables the output driver of a pin. More...
 
static __always_inline void gpio_local_disable_pin_output_driver (uint32_t pin)
 Disables the output driver of a pin. More...
 
static __always_inline bool gpio_local_get_pin_value (uint32_t pin)
 Returns the value of a pin. More...
 
static __always_inline void gpio_local_set_gpio_pin (uint32_t pin)
 Drives a GPIO pin to 1. More...
 
static __always_inline void gpio_local_clr_gpio_pin (uint32_t pin)
 Drives a GPIO pin to 0. More...
 
static __always_inline void gpio_local_tgl_gpio_pin (uint32_t pin)
 Toggles a GPIO pin. More...
 
static __always_inline void gpio_local_init_gpio_open_drain_pin (uint32_t pin)
 Initializes the configuration of a GPIO pin so that it can be used with GPIO open-drain functions. More...
 
static __always_inline void gpio_local_set_gpio_open_drain_pin (uint32_t pin)
 Drives a GPIO pin to 1 using open drain. More...
 
static __always_inline void gpio_local_clr_gpio_open_drain_pin (uint32_t pin)
 Drives a GPIO pin to 0 using open drain. More...
 
static __always_inline void gpio_local_tgl_gpio_open_drain_pin (uint32_t pin)
 Toggles a GPIO pin using open drain. More...