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.




The code snippet bellow shows how to configure a GPIO pin as input.

#include "reg_stm32f4xx.h"
 
/* 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. */





00Input mode (reset state)




00No pull-up, pull-down (reset state)
01Pull-up
10Pull-down




* Register is read only




  • stm32/peripherals/gpio_input.1456388023.txt.gz
  • Last modified: 2016/02/25 08:13
  • by feur