====== Alternate Functions (GPIO) ====== * The output buffer can be enabled (open drain or push-pull). * The output buffer is controlled by connected peripheral. * The Schmitt trigger input is active. * The pull-up and -down resistors are active, according to [[gpio#registers|PUPDR]]. * Input data is sampled every AHB clock. * Input data register holds I/O state. \\ {{gpio_complete.svg}} \\ \\ ===== Programming Instructions ===== Depending on the alternate function you have to configure the pins as: * [[gpio_input#programming_instructions|digital input]], * [[gpio_output#programming_instructions|digital output]] or * [[gpio_analog#programming_instructions|analog input]]. \\ ===== Configuration Registers ===== ==== GPIOx_MODER - Mode register ==== \\ {{gpio_reg_common.svg}} \\ \\ |< 100% 5em 5em >| |Pin x|10|Alternate function mode| ==== GPIOx_AFRL/H - Alternate function register (low / high) ==== \\ {{gpio_reg_afrl.svg}} \\ \\ \\ {{gpio_reg_afrh.svg}} \\ \\ |< 100% 5em 5em>| |Pin x|0000|AF0: RTC, MCO, Tamper, SWJ, Trace| |:::|0001|AF1: Timer 1, [[timer2_5|Timer 2]]| |:::|0010|AF2: [[timer2_5|Timer 3..5]]| |:::|0011|AF3: Timer 8..11| |:::|0100|AF4: I²C 1..3| |:::|0101|AF5: SPI 1..6| |:::|0110|AF6: SPI 2/3, SAI 1| |:::|0111|AF7: SPI 3, USART 1..3| |:::|1000|AF8: USART 6, UART 4/5/7/8| |:::|1001|AF9: CAN 1/2, Timer 12..14, LCD| |:::|1010|AF10: USB OTG HS/FS| |:::|1011|AF11: Ethernet| |:::|1100|AF12: FMC, SDIO, USB OTG FS| |:::|1101|AF13: DCMI| |:::|1110|AF14: LCD| |:::|1111|AF15: Event Out| ==== GPIOx_PUPDR - GPIO port pull-up / pull-down register ==== \\ {{gpio_reg_common.svg}} \\ \\ |< 100% 5em 5em >| |Pin x|00|No pull-up, pull-down (reset state)| |:::|01|Pull-up| |:::|10|Pull-down| |:::|11|Reserved| ==== GPIOx_OTYPER - Port output type register ==== \\ {{gpio_reg_otyper.svg}} \\ \\ |< 100% 5em 5em >| |Pin x|0|Output type: push-pull (reset state)| |:::|1|Output type: open-drain| ==== GPIOx_OSPEEDR - Port output speed register ==== \\ {{gpio_reg_common.svg}} \\ \\ |< 100% 5em 5em >| |Pin x|00|Speed: 2 MHz (reset state)| |:::|01|Speed: 10 MHz| |:::|10|Speed: 50 MHz| |:::|11|Speed: 100 MHz|