GPIO gives access to the MCU pins.
Data Structures | |
struct | gpio_map_t |
A type definition of pins and modules connectivity. More... | |
Peripheral Bus Interface | |
static uint32_t | gpio_configure_edge_detector (uint32_t pin, uint32_t mode) |
Configure the edge detector of an input pin. More... | |
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... | |
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.
| |
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.
| |
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... | |
Peripheral Event System support | |
The GPIO can be programmed to output peripheral events whenever an interrupt condition is detected, such as pin value change, or only when a rising or falling edge is detected. | |
static __always_inline void | gpio_enable_pin_periph_event (uint32_t pin) |
Enables the peripheral event generation of a pin. More... | |
static __always_inline void | gpio_disable_pin_periph_event (uint32_t pin) |
Disables the peripheral event generation of a pin. More... | |
uint32_t | gpio_configure_pin_periph_event_mode (uint32_t pin, uint32_t mode, uint32_t use_igf) |
#define GPIO_BOTHEDGES (3 << 7) |
Sense Both Edges.
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_BUSKEEPER (3 << 2) |
Bus Keeper.
#define GPIO_DIR_INPUT (0 << 0) |
Pin is Input.
Referenced by board_init().
#define GPIO_DIR_OUTPUT (1 << 0) |
Pin is Output.
Referenced by board_init(), gpio_configure_group(), and gpio_configure_pin().
#define GPIO_DRIVE_HIGH (2 << 4) |
Drive High Configuration.
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_DRIVE_LOW (1 << 4) |
Drive Low Configuration.
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_DRIVE_MAX (3 << 4) |
Drive Max Configuration.
#define GPIO_DRIVE_MIN (0 << 4) |
Drive Min Configuration.
#define GPIO_FALLING (7 << 7) |
Sense Falling Edge.
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_FALLING_EDGE 2 |
Interrupt triggered upon falling edge.
Referenced by gpio_configure_edge_detector().
#define GPIO_INIT_HIGH (1 << 1) |
Initial Output State is High.
Referenced by board_init(), gpio_configure_group(), and gpio_configure_pin().
#define GPIO_INIT_LOW (0 << 1) |
Initial Output State is Low.
#define GPIO_INTERRUPT (1 << 7) |
Enable Pin/Group Interrupt.
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_INVALID_ARGUMENT 1 |
Input parameters are out of range.
Referenced by gpio_configure_edge_detector(), gpio_enable_module_pin(), and gpio_enable_pin_interrupt().
#define GPIO_OPEN_DRAIN (1 << 6) |
Open-Drain (when output)
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_PIN_CHANGE 0 |
Interrupt triggered upon pin change.
Referenced by gpio_configure_edge_detector(), and ui_enable_asynchronous_interrupt().
#define GPIO_PULL_DOWN (2 << 2) |
Pull-Down (when input)
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_PULL_UP (1 << 2) |
Pull-Up (when input)
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_RISING (5 << 7) |
Sense Rising Edge.
Referenced by gpio_configure_group(), and gpio_configure_pin().
#define GPIO_RISING_EDGE 1 |
Interrupt triggered upon rising edge.
Referenced by gpio_configure_edge_detector().
#define GPIO_SUCCESS 0 |
Function successfully completed.
Referenced by gpio_configure_edge_detector(), gpio_enable_module(), gpio_enable_module_pin(), and gpio_enable_pin_interrupt().
void gpio_clear_pin_interrupt_flag | ( | uint32_t | pin | ) |
void gpio_clr_gpio_open_drain_pin | ( | uint32_t | pin | ) |
Drives a GPIO pin to 0 using open drain.
pin | The pin number. |
void gpio_clr_gpio_pin | ( | uint32_t | pin | ) |
Drives a GPIO pin to 0.
pin | The pin number. |
|
static |
Configure the edge detector of an input pin.
pin | The pin number. |
mode | The edge detection mode (GPIO_PIN_CHANGE, GPIO_RISING_EDGE or GPIO_FALLING_EDGE). |
References GPIO_FALLING_EDGE, GPIO_INVALID_ARGUMENT, GPIO_PIN_CHANGE, GPIO_RISING_EDGE, and GPIO_SUCCESS.
Referenced by gpio_enable_pin_interrupt().
void gpio_configure_group | ( | uint32_t | port, |
uint32_t | mask, | ||
uint32_t | flags | ||
) |
Configuration functionality on a port.
port | The port number. |
mask | The mask. |
flags | The configuration. |
References GPIO_BOTHEDGES, GPIO_DIR_OUTPUT, GPIO_DRIVE_HIGH, GPIO_DRIVE_LOW, GPIO_FALLING, GPIO_INIT_HIGH, GPIO_INTERRUPT, GPIO_OPEN_DRAIN, GPIO_PULL_DOWN, GPIO_PULL_UP, and GPIO_RISING.
void gpio_configure_pin | ( | uint32_t | pin, |
uint32_t | flags | ||
) |
Configuration functionality on a pin.
pin | The pin number. |
flags | The configuration. |
References GPIO_BOTHEDGES, GPIO_DIR_OUTPUT, GPIO_DRIVE_HIGH, GPIO_DRIVE_LOW, GPIO_FALLING, GPIO_INIT_HIGH, GPIO_INTERRUPT, GPIO_OPEN_DRAIN, GPIO_PULL_DOWN, GPIO_PULL_UP, and GPIO_RISING.
Referenced by board_init().
uint32_t gpio_configure_pin_periph_event_mode | ( | uint32_t | pin, |
uint32_t | mode, | ||
uint32_t | use_igf | ||
) |
void gpio_disable_pin_glitch_filter | ( | uint32_t | pin | ) |
Disables the glitch filter of a pin.
pin | The pin number. |
void gpio_disable_pin_interrupt | ( | uint32_t | pin | ) |
Disables the interrupt of a pin.
pin | The pin number. |
Referenced by ui_disable_asynchronous_interrupt().
|
static |
Disables the peripheral event generation of a pin.
pin | The pin number. |
void gpio_disable_pin_pull_up | ( | uint32_t | pin | ) |
Disables the pull-up resistor of a pin.
pin | The pin number. |
void gpio_enable_gpio | ( | const gpio_map_t | gpiomap, |
uint32_t | size | ||
) |
Enables the GPIO mode of a set of pins.
gpiomap | The pin map. |
size | The number of pins in gpiomap. |
References gpio_enable_gpio_pin(), and gpio_map_t::pin.
void gpio_enable_gpio_pin | ( | uint32_t | pin | ) |
Enables the GPIO mode of a pin.
pin | The pin number. Refer to the product header file `uc3x.h' (where x is the part number; e.g. x = a0512) for pin definitions. E.g., to enable the GPIO mode of PX21, AVR32_PIN_PX21 can be used. Module pins such as AVR32_PWM_3_PIN for PWM channel 3 can also be used to release module pins for GPIO. |
Referenced by gpio_enable_gpio().
uint32_t gpio_enable_module | ( | const gpio_map_t | gpiomap, |
uint32_t | size | ||
) |
Enables specific module modes for a set of pins.
gpiomap | The pin map. |
size | The number of pins in gpiomap. |
References gpio_map_t::function, gpio_enable_module_pin(), GPIO_SUCCESS, and gpio_map_t::pin.
Referenced by board_init().
uint32_t gpio_enable_module_pin | ( | uint32_t | pin, |
uint32_t | function | ||
) |
Enables a specific module mode for a pin.
AVR32_*_PIN
constants map a GPIO number from the device datasheet to the appropriate pin function, while the corresponding AVR32_*_FUNCTION
macro contains the appropriate function index. AVR32_PWM_3_PIN
and AVR32_PWM_3_FUNCTION
contain the pin and function index of the PWM module, channel 3, for the current device (if available).pin | The pin number. |
function | The pin function. |
References GPIO_INVALID_ARGUMENT, and GPIO_SUCCESS.
Referenced by gpio_enable_module(), and ui_enable_asynchronous_interrupt().
void gpio_enable_pin_glitch_filter | ( | uint32_t | pin | ) |
Enables the glitch filter of a pin.
When the glitch filter is enabled, a glitch with duration of less than 1 clock cycle is automatically rejected, while a pulse with duration of 2 clock cycles or more is accepted. For pulse durations between 1 clock cycle and 2 clock cycles, the pulse may or may not be taken into account, depending on the precise timing of its occurrence. Thus for a pulse to be guaranteed visible it must exceed 2 clock cycles, whereas for a glitch to be reliably filtered out, its duration must not exceed 1 clock cycle. The filter introduces 2 clock cycles latency.
pin | The pin number. |
uint32_t gpio_enable_pin_interrupt | ( | uint32_t | pin, |
uint32_t | mode | ||
) |
Enables the interrupt of a pin with the specified settings.
pin | The pin number. |
mode | The trigger mode (GPIO_PIN_CHANGE, GPIO_RISING_EDGE or GPIO_FALLING_EDGE). |
References gpio_configure_edge_detector(), GPIO_INVALID_ARGUMENT, and GPIO_SUCCESS.
Referenced by ui_enable_asynchronous_interrupt().
|
static |
Enables the peripheral event generation of a pin.
pin | The pin number. |
void gpio_enable_pin_pull_up | ( | uint32_t | pin | ) |
Enables the pull-up resistor of a pin.
pin | The pin number. |
Referenced by ui_enable_asynchronous_interrupt().
bool gpio_get_gpio_open_drain_pin_output_value | ( | uint32_t | pin | ) |
Returns the output value set for a GPIO pin using open drain.
pin | The pin number. |
bool gpio_get_gpio_pin_output_value | ( | uint32_t | pin | ) |
Returns the output value set for a GPIO pin.
pin | The pin number. |
bool gpio_get_pin_interrupt_flag | ( | uint32_t | pin | ) |
Gets the interrupt flag of a pin.
pin | The pin number. |
bool gpio_get_pin_value | ( | uint32_t | pin | ) |
Returns the value of a pin.
pin | The pin number. |
Referenced by gpio_pin_is_high(), gpio_pin_is_low(), is_joystick_down(), is_joystick_left(), is_joystick_pressed(), is_joystick_right(), is_joystick_up(), ui_device_sof_action(), and ui_host_sof_event().
|
static |
Drives a GPIO pin to 0 using open drain.
pin | The pin number. |
|
static |
Drives a GPIO pin to 0.
pin | The pin number. |
|
static |
Disables the output driver of a pin.
pin | The pin number. |
|
static |
Enables the output driver of a pin.
pin | The pin number. |
|
static |
Returns the value of a pin.
pin | The pin number. |
|
static |
Enables the local bus interface for GPIO.
References Get_system_register, and Set_system_register.
|
static |
Initializes the configuration of a GPIO pin so that it can be used with GPIO open-drain functions.
|
static |
Drives a GPIO pin to 1 using open drain.
pin | The pin number. |
|
static |
Drives a GPIO pin to 1.
pin | The pin number. |
|
static |
Toggles a GPIO pin using open drain.
pin | The pin number. |
|
static |
Toggles a GPIO pin.
pin | The pin number. |
|
static |
Check if the pin is in high logical level.
pin | The pin number. |
true
if the pin is in high logical level false
if the pin is not in high logical level References gpio_get_pin_value().
|
static |
Check if the pin is in low logical level.
pin | The pin number. |
true
if the pin is in low logical level false
if the pin is not in low logical level References gpio_get_pin_value().
void gpio_set_gpio_open_drain_pin | ( | uint32_t | pin | ) |
Drives a GPIO pin to 1 using open drain.
pin | The pin number. |
void gpio_set_gpio_pin | ( | uint32_t | pin | ) |
Drives a GPIO pin to 1.
pin | The pin number. |
void gpio_set_group_high | ( | uint32_t | port, |
uint32_t | mask | ||
) |
Drives a GPIO port to 1.
port | The port number. |
mask | The mask. |
void gpio_set_group_low | ( | uint32_t | port, |
uint32_t | mask | ||
) |
Drives a GPIO port to 0.
port | The port number. |
mask | The mask. |
void gpio_set_pin_high | ( | uint32_t | pin | ) |
Drives a GPIO pin to 1.
pin | The pin number. |
void gpio_set_pin_low | ( | uint32_t | pin | ) |
Drives a GPIO pin to 0.
pin | The pin number. |
void gpio_tgl_gpio_open_drain_pin | ( | uint32_t | pin | ) |
Toggles a GPIO pin using open drain.
pin | The pin number. |
void gpio_tgl_gpio_pin | ( | uint32_t | pin | ) |
Toggles a GPIO pin.
pin | The pin number. |
void gpio_toggle_group | ( | uint32_t | port, |
uint32_t | mask | ||
) |
Toggles a GPIO group.
port | The port number. |
mask | The mask. |
void gpio_toggle_pin | ( | uint32_t | pin | ) |
Toggles a GPIO pin.
pin | The pin number. |