General-purpose I/Os (GPIO)
ï€ Input: Floating, Pull-up, Pull-down.
ï€ Output: Push-Pull (Pull-up, Pull-down or no Pull), Open Drain (Pull-up, Pull-down
or no Pull). In output mode, the speed is configurable: Low, Medium, Fast or
High.
ï€ Alternate Function: Push-Pull (Pull-up, Pull-down or no Pull), Open Drain (Pull-
up, Pull-down or no Pull).
ï€ Analog: required mode when a pin is to be used as ADC channel, DAC output or
comparator input.
3. Peripherals alternate function:
ï€ For ADC, DAC and comparators, configure the desired pin in analog mode using
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AN
ï€ For other peripherals (TIM, USART...):
ï€ Connect the pin to the desired peripherals' Alternate Function (AF) using
GPIO_PinAFConfig() function.
ï€ Configure the desired pin in alternate function mode using GPIO_InitStruct-
>GPIO_Mode = GPIO_Mode_AF
ï€ Select the type, pull-up/pull-down and output speed via GPIO_PuPd,
GPIO_OType and GPIO_Speed members.
ï€ Call GPIO_Init() function.
4. To get the level of a pin configured in input mode use GPIO_ReadInputDataBit()
5. To set/reset the level of a pin configured in output mode use
GPIO_SetBits()/GPIO_ResetBits()
6. During and just after reset, the alternate functions are not active and the GPIO pins
are configured in input floating mode (except JTAG pins).
7. The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general-
purpose (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has
priority over the GPIO function.
8. The HSE oscillator pins OSC_IN/OSC_OUT can be used as general-purpose (PF0
and PF1 respectively) when the HSE oscillator is off. The HSE has the priority over
the GPIO function.
12.2.2 Initialization and Configuration
ï‚· GPIO_DeInit()
ï‚· GPIO_Init()
ï‚· GPIO_StructInit()
ï‚· GPIO_PinLockConfig()
12.2.3 GPIO Read and Write
ï‚· GPIO_ReadInputDataBit()
ï‚· GPIO_ReadInputData()
ï‚· GPIO_ReadOutputDataBit()
ï‚· GPIO_ReadOutputData()
ï‚· GPIO_SetBits()
ï‚· GPIO_ResetBits()
ï‚· GPIO_WriteBit()
ï‚· GPIO_Write()
12.2.4 GPIO Alternate functions configuration functions