O'Reilly logo

Embedded Systems Architecture by Daniele Lacamera

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Digital input

A GPIO pin configured in input mode detects the logic level of the voltage applied to it. The logic value of all the input pins on a GPIO controller can be read from the input data register (IDR). On the reference board, the pin A0 is connected to the user button, so the status of the button can be read at any time while the application is running.

The GPIOA controller can be turned on by clock gating:

#define AHB1_CLOCK_ER (*(volatile uint32_t *)(0x40023830))#define GPIOA_AHB1_CLOCK_ER (1 << 0)

The controller itself is mapped at address 0x40020000:

#define GPIOA_BASE 0x40020000#define GPIOA_MODE (*(volatile uint32_t *)(GPIOA_BASE + 0x00))#define GPIOA_IDR (*(volatile uint32_t *)(GPIOA_BASE + 0x10))

To set up the pin for input, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required