STM32F4 GPIO API¶
-
group
STM32F4_HAL_GPIO
Defines
-
K_NUM_PINS
(16 * 5)¶ Number of available GPIO pins.
-
K_LED_0
YOTTA_CFG_HARDWARE_PINS_LED1¶ Led 0 pin.
-
K_LED_1
YOTTA_CFG_HARDWARE_PINS_LED2¶ Led 1 pin.
-
K_LED_2
YOTTA_CFG_HARDWARE_PINS_LED3¶ Led 2 pin.
-
K_LED_3
YOTTA_CFG_HARDWARE_PINS_LED4¶ Led 3 pin.
-
K_LED_COUNT
4¶ Number of available leds.
-
K_BUTTON_0
YOTTA_CFG_HARDWARE_PINS_USER_BUTTON¶ User button pin.
-
STM32F4_PIN_OFFSET
(p) ((p) % 16)¶ Derives GPIO pin offset (within respective port)
-
STM32F4_PIN_MASK
(p) (1 << STM32F4_PIN_OFFSET(p))¶ Derives bit mask for GPIO pin.
-
STM32F4_PIN_GPIO
(p) ((GPIO_TypeDef *) (GPIOA_BASE + (((p) / 16) * 0x400)))¶ Derives GPIO port from pin number.
-
STM32F4_PIN_AHB1ENR_BIT
(p) (1 << ((p) / 16))¶ Derives AHB (hardware clock) bit from pin number.
-
CHECK_BIT
(src, bit) (READ_BIT((src), (bit)) == (bit))¶ Checks if bit value in src is set.
-
CHECK_SET_BIT
(dest, bit) do { \ uint32_t tmpreg = READ_BIT(dest, bit); \ if (!tmpreg) { \ SET_BIT(dest, bit); \ /* Delay after an RCC peripheral clock enabling */ \ tmpreg = READ_BIT(dest, bit);\ } \ } while(0)¶ Checks until bit value in dest is set.
Enums
-
enum
KPin
¶ All available GPIO pins for STM32F4.
Values:
-
PA0
= 0¶
-
PA1
¶
-
PA2
¶
-
PA3
¶
-
PA4
¶
-
PA5
¶
-
PA6
¶
-
PA7
¶
-
PA8
¶
-
PA9
¶
-
PA10
¶
-
PA11
¶
-
PA12
¶
-
PA13
¶
-
PA14
¶
-
PA15
¶
-
PB0
¶
-
PB1
¶
-
PB2
¶
-
PB3
¶
-
PB4
¶
-
PB5
¶
-
PB6
¶
-
PB7
¶
-
PB8
¶
-
PB9
¶
-
PB10
¶
-
PB11
¶
-
PB12
¶
-
PB13
¶
-
PB14
¶
-
PB15
¶
-
PC0
¶
-
PC1
¶
-
PC2
¶
-
PC3
¶
-
PC4
¶
-
PC5
¶
-
PC6
¶
-
PC7
¶
-
PC8
¶
-
PC9
¶
-
PC10
¶
-
PC11
¶
-
PC12
¶
-
PC13
¶
-
PC14
¶
-
PC15
¶
-
PD0
¶
-
PD1
¶
-
PD2
¶
-
PD3
¶
-
PD4
¶
-
PD5
¶
-
PD6
¶
-
PD7
¶
-
PD8
¶
-
PD9
¶
-
PD10
¶
-
PD11
¶
-
PD12
¶
-
PD13
¶
-
PD14
¶
-
PD15
¶
-
PE0
¶
-
PE1
¶
-
PE2
¶
-
PE3
¶
-
PE4
¶
-
PE5
¶
-
PE6
¶
-
PE7
¶
-
PE8
¶
-
PE9
¶
-
PE10
¶
-
PE11
¶
-
PE12
¶
-
PE13
¶
-
PE14
¶
-
PE15
¶
-
Functions
-
void
kprv_gpio_alt_config
(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)¶ Performs alternate GPIO configuration.
- Parameters
GPIOx
: STM32CubeF4 GPIO definitionGPIO_PinSource
: pin port numberGPIO_AF
: alternate pin number
-
void
k_gpio_init
(int pin, KGPIOMode mode, KGPIOPullup pullup)¶ Performs low-level GPIO pin configuration and setup.
- Parameters
pin
: GPIO pin numbermode
: pin modepullup
: pin pullup setting
-
unsigned int
k_gpio_read
(int pin)¶ Reads value off GPIO pin.
- Return
- int value read from pin
- Parameters
pin
: GPIO pin to read from
-
void
k_gpio_write
(int pin, unsigned int val)¶ Writes value to GPIO pin.
- Parameters
pin
: GPIO pin to write toval
: value to write to pin
-
struct
KPinDesc
¶ - #include <pins.h>
Structure describing GPIO pin.
-