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