GPIO gives access to the MCU pins.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the GPIO - General-Purpose Input/Output. | |
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... | |
#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.
#define GPIO_DIR_OUTPUT (1 << 0) |
Pin is Output.
Referenced by 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 at42qt1060_register_int(), dip204_example_configure_joystick_IT(), gpio_configure_edge_detector(), prvSetupMACBInterrupt(), and rtouch_enable_detect_int().
#define GPIO_INIT_HIGH (1 << 1) |
Initial Output State is High.
Referenced by 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 b_joystick_init(), b_pushb1_init(), b_pushb2_init(), b_pushb3_init(), gpio_configure_edge_detector(), and main().
#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 dip204_example_configure_push_buttons_IT(), gpio_configure_edge_detector(), main(), and usb_suspend().
#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 | ) |
Clears the interrupt flag of a pin.
pin | The pin number. |
Referenced by at42qt1060_register_int(), dip204_example_Joy_int_handler(), dip204_example_PB_int_handler(), gpio_pin_change_interrupt_handler(), ISR(), prvjoystick_ISR_NonNakedBehaviour(), prvpushb_ISR_NonNakedBehaviour(), rtouch_clear_detect_flag(), rtouch_disable_detect_int(), touch_button_isr(), and usb_suspend().
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. |
Referenced by dip204_init(), dip204_set_backlight(), et024006_ResetDisplay(), ethernet_phy_hw_reset(), int_handler_usart(), led_task(), main(), qt1081_power_up(), rtouch_gradient_x_surface(), rtouch_gradient_y_surface(), rtouch_ground_x_surface(), rtouch_ground_y_surface(), and wdt_scheduler().
|
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 sensor_board_init().
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 rtouch_disable_detect_int(), touch_button_isr(), v_joystick_stop(), v_pushb1_stop(), v_pushb2_stop(), and v_pushb3_stop().
void gpio_disable_pin_pull_up | ( | uint32_t | pin | ) |
Disables the pull-up resistor of a pin.
pin | The pin number. |
Referenced by rtouch_gradient_x_surface(), rtouch_gradient_y_surface(), rtouch_tristate_x_surface(), and rtouch_tristate_y_surface().
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(), i, and gpio_map_t::pin.
Referenced by aic23b_dac_stop(), ms3_dac_mute(), ms3_dac_stop(), pwm_dac_stop(), and tpa6130_dac_stop().
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 et024006_SetupInterface(), gpio_enable_gpio(), main(), qt60168_check_device_ready(), rtouch_gradient_x_surface(), rtouch_gradient_y_surface(), rtouch_ground_x_surface(), rtouch_ground_y_surface(), rtouch_pullup_y_surface(), rtouch_tristate_x_surface(), and rtouch_tristate_y_surface().
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, i, gpio_map_t::pin, and status.
Referenced by acc_init(), adc_init(), aic23b_dac_start(), at45dbx_resources_init(), dac_pwm_init(), dsp_debug_init(), init_adc(), init_dbg_rs232_ex(), init_rs232(), init_shl_rs232(), init_spi(), init_stdio(), init_twi(), init_usart(), main(), ms3_dac_mute(), ms3_dac_start(), portTASK_FUNCTION(), prv_at45dbx_resources_init(), prv_sd_mmc_resources_init(), prvMMI_Init(), pwm_dac_start(), qt60168_check_device_ready(), rtouch_init(), sd_mmc_resources_init(), smc_enable_muxed_pins(), tpa6130_dac_start(), twi_init(), ushell_task_init(), and xSerialPortInitMinimal().
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 b_light_init(), b_potentiometer_init(), b_temperature_init(), dip204_init(), et024006_SetupInterface(), gpio_enable_module(), init_codec_gclk(), local_enable_gclk_on_gpio(), local_start_gc(), main(), prvMMI_Init(), rtouch_tristate_x_surface(), rtouch_tristate_y_surface(), and xUsartInit().
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 at42qt1060_register_int(), b_joystick_init(), b_pushb1_init(), b_pushb2_init(), b_pushb3_init(), dip204_example_configure_joystick_IT(), dip204_example_configure_push_buttons_IT(), main(), prvSetupMACBInterrupt(), rtouch_enable_detect_int(), and usb_suspend().
void gpio_enable_pin_pull_up | ( | uint32_t | pin | ) |
Enables the pull-up resistor of a pin.
pin | The pin number. |
Referenced by init_spi(), main(), and rtouch_pullup_y_surface().
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. |
Referenced by dip204_example_Joy_int_handler(), dip204_example_PB_int_handler(), ISR(), prvjoystick_ISR_NonNakedBehaviour(), and prvpushb_ISR_NonNakedBehaviour().
bool gpio_get_pin_value | ( | uint32_t | pin | ) |
Returns the value of a pin.
pin | The pin number. |
Referenced by ai_sd_mmc_get_device_status(), aic23b_dac_output(), device_cdc_task(), gpio_pin_is_high(), gpio_pin_is_low(), is_joystick_down(), is_joystick_left(), is_joystick_pressed(), is_joystick_right(), is_joystick_up(), is_usb_mouse_event(), main(), ms3_dac_output(), prvjoystick_ISR_NonNakedBehaviour(), prvpushb_ISR_NonNakedBehaviour(), qt60168_check_device_ready(), and rtouch_is_detect().
|
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. |
Referenced by main().
|
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.
Referenced by main().
|
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().
Referenced by wait_for_switches().
|
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().
Referenced by ak8975_get_data(), hmc5883l_get_data(), main(), and wait_for_switches().
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. |
Referenced by dip204_init(), dip204_set_backlight(), et024006_ResetDisplay(), et024006_SetupInterface(), ethernet_phy_hw_reset(), gui_init(), led_task(), main(), ms3_dac_start(), qt1081_power_down(), rtouch_gradient_x_surface(), rtouch_gradient_y_surface(), and wdt_scheduler().
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. |
Referenced by main().
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. |
Referenced by gpio_pin_change_interrupt_handler(), main(), tc_irq(), toggle_led(), and touch_button_isr().
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. |