![]() |
ARMEBS4
revision-607
|
![]() |
Modules | |
GPIO Interrupts | |
Data Structures | |
struct | gpio_t |
GPIO control structure. More... | |
Macros | |
#define | GPIO_NC |
Unconnected pin. | |
#define | DEF_GPIOA(__PIN, __MODE) |
Helper for defining a pin. More... | |
#define | DEF_GPIOB(__PIN, __MODE) |
same as DEF_GPIOA for port B | |
#define | DEF_GPIOC(__PIN, __MODE) |
same as DEF_GPIOA for port C | |
#define | DEF_GPIOD(__PIN, __MODE) |
same as DEF_GPIOA for port D | |
#define | DEF_GPIOE(__PIN, __MODE) |
same as DEF_GPIOA for port E | |
#define | DEF_GPIOF(__PIN, __MODE) |
same as DEF_GPIOA for port F | |
#define | DEF_GPIOG(__PIN, __MODE) |
same as DEF_GPIOA for port G | |
#define | DEF_GPIOH(__PIN, __MODE) |
same as DEF_GPIOA for port H | |
#define | DEF_GPIOI(__PIN, __MODE) |
same as DEF_GPIOA for port I | |
Enumerations | |
enum | gpio_mode_e { GPIO_INPUT, GPIO_OUTPUT, GPIO_OUTPUT_0, GPIO_OUTPUT_1, GPIO_AF, GPIO_AN, GPIO_PP, GPIO_OD, GPIO_SPEED_2, GPIO_SPEED_25, GPIO_SPEED_50, GPIO_SPEED_100, GPIO_NOPULL, GPIO_PULLUP, GPIO_PULLDOWN } |
GPIO modes, can be ORed. More... | |
Functions | |
status_e | gpio_setup (const struct gpio_t *gpio) |
Setup a gpio. More... | |
status_e | gpio_setup_list (const struct gpio_t gpio[], size_t len) |
Setup an array of gpio. More... | |
static GPIO_TypeDef * | _internal_gpio_get_ctrl (const struct gpio_t *gpio) |
Get the gpio controller given the gpio struct. | |
static void | gpio_toggle (const struct gpio_t *gpio) |
Toggle a gpio line. More... | |
static uint32_t | gpio_get (const struct gpio_t *gpio) |
Get gpio level. More... | |
static uint32_t | gpio_get_internal (const struct gpio_t *gpio) |
Get gpio internal level. More... | |
static void | gpio_set (const struct gpio_t *gpio, uint32_t value) |
Set a gpio. More... | |
static void | gpio_set_direction (const struct gpio_t *gpio, enum gpio_mode_e dir) |
Set a gpio direction. More... | |
#define DEF_GPIOA | ( | __PIN, | |
__MODE | |||
) |
Helper for defining a pin.
__PIN | the pin number (0 for GPIOx0, ..., 3 for GPIOx3, ...) |
__MODE | gpio_mode_e of the pin |
Example for one pin:
Example for multiple pins:
Definition at line 358 of file stm32_gpio.h.
enum gpio_mode_e |
GPIO modes, can be ORed.
Enumerator | |
---|---|
GPIO_INPUT |
Input. |
GPIO_OUTPUT |
Output (same as GPIO_OUTPUT_0) |
GPIO_OUTPUT_0 |
Output (default 0) |
GPIO_OUTPUT_1 |
Output (default 1) |
GPIO_AF |
Alternate function. |
GPIO_AN |
Analog. |
GPIO_PP |
Output type : Push-Pull. |
GPIO_OD |
Output type : Open Drain. |
GPIO_SPEED_2 |
Output speed : 2 MHz. |
GPIO_SPEED_25 |
Output speed : 25 MHz. |
GPIO_SPEED_50 |
Output speed : 50 MHz. |
GPIO_SPEED_100 |
Output speed : 100 MHz. |
GPIO_NOPULL |
No pull up or down. |
GPIO_PULLUP |
Pull up. |
GPIO_PULLDOWN |
pull down |
Definition at line 41 of file stm32_gpio.h.
Setup a gpio.
gpio | Pointer on the gpio |
Example configuring GPIOA3 as input with pullup:
Definition at line 9 of file stm32_gpio.c.
References _internal_gpio_get_ctrl(), GPIO_TypeDef::AFR, gpio_t::ctrl, gpio_set(), gpio_t::mode, GPIO_TypeDef::MODER, NO_ERROR, gpio_t::nr, GPIO_TypeDef::OSPEEDR, GPIO_TypeDef::OTYPER, and GPIO_TypeDef::PUPDR.
Referenced by bsp_init(), camera_init(), gpio_irq_setup(), gpio_setup_list(), and workaround_reset_i2c_devices().
Setup an array of gpio.
gpio | Pointer on the first gpio |
len | The number of gpios |
Definition at line 47 of file stm32_gpio.c.
References gpio_setup(), and NO_ERROR.
Referenced by Audio_Init(), bsp_init(), and camera_init().
|
inlinestatic |
Toggle a gpio line.
gpio | which gpio |
Definition at line 185 of file stm32_gpio.h.
References _internal_gpio_get_ctrl(), GPIO_TypeDef::BSRRL, gpio_t::ctrl, gpio_t::mask, and GPIO_TypeDef::ODR.
|
inlinestatic |
Get gpio level.
gpio | which gpio |
The value returned is the value of the pin, outside of the chip
Definition at line 219 of file stm32_gpio.h.
References _internal_gpio_get_ctrl(), gpio_t::ctrl, GPIO_TypeDef::IDR, and gpio_t::mask.
Referenced by bsp_button_get(), gpio_irq_restore(), and gpio_irq_setup().
|
inlinestatic |
Get gpio internal level.
gpio | which gpio |
The value returned is the value of the output register, not the value of the pin.
Definition at line 242 of file stm32_gpio.h.
References _internal_gpio_get_ctrl(), gpio_t::ctrl, gpio_t::mask, and GPIO_TypeDef::ODR.
|
inlinestatic |
Set a gpio.
gpio | the gpio to set |
value | 0 for output logical 0, anything else for logical level 1 |
Definition at line 260 of file stm32_gpio.h.
References _internal_gpio_get_ctrl(), GPIO_TypeDef::BSRRH, GPIO_TypeDef::BSRRL, gpio_t::ctrl, and gpio_t::mask.
Referenced by gpio_set_direction(), gpio_setup(), and workaround_reset_i2c_devices().
|
inlinestatic |
Set a gpio direction.
gpio | the gpio to set |
dir | GPIO_INPUT, GPIO_OUTPUT_0 or GPIO_OUTPUT_1 |
Definition at line 286 of file stm32_gpio.h.
References _internal_gpio_get_ctrl(), gpio_t::ctrl, gpio_set(), GPIO_TypeDef::MODER, and gpio_t::nr.