This is an old revision of the document!
General Purpose Input
- The output buffer is disabled.
- The Schmitt trigger input is active.
- The pull-up and -down resistors are active, according to PUPDR.
- Input data is sampled every AHB clock.
- Input data register holds I/O state.
Programming Example
The code snippet bellow shows how to configure and use a GPIO pin as input.
#include "reg_stm32f4xx.h" RCC->AHBENR[0] |= (0x1 << 0u); /* Enable GPIOA clock */ /* Configure GPIO pin A.10 as input. */ GPIOA->MODER &= ~(0x3 << 20u); /* Clear existing mode bits 20 and 21. */ GPIOA->PUPDR &= ~(0x3 << 20u); /* Clear existing pull-up/-down bits 20 and 21. */ GPIOA->PUPDR |= (0x1 << 20u); /* Set pin 10 to pull-up mode. */ /* Read from GPIO pin A.10. */ uint32_t data = GPIOA->IDR; /* Read the input data register. */