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

Pin configuration

Depending on the logic of the GPIO controller, the pins can be activated all together, separately, or in groups. In order to implement a driver to set up the pins and use them as needed, it is possible to refer to the datasheet of the microcontroller, or any example implementation provided by the silicon vendor.

In the case of the STM32F4, general-purpose I/O pins are divided in groups. Each group is connected to a separate clock gate, so, to use the pins associated to a group, the clock gate must be enabled. The following code will distribute the clock source to the GPIO controller for the group D:

#define AHB1_CLOCK_ER (*(volatile uint32_t *)(0x40023840))#define GPIOD_AHB1_CLOCK_ER (1 << 3)AHB1_CLOCK_ER |= GPIOD_AHB1_CLOCK_ER; ...

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