Developing input and output drivers
In this section, we will apply the knowledge gained about the GPIO peripheral to develop practical input and output drivers for STM32 microcontrollers. Since we are already familiar with developing the output driver to toggle an LED using the ODR, this section will focus on developing the output driver using the BSRR.
The GPIO output driver using the BSRR
Let’s start by making a copy of our last project in our IDE:
- Right-click on the last project and select Copy.
- Right-click in the Project Explorer pane and select Paste.
- Rename the copied project to
GpioInput-Output
.
Next, we will modularize our code by creating dedicated files for the GPIO driver code:
- Right-click on the
Src
folder in the project and select New | File. - In the File Name field, type
gpio.c
.
Then, we will create the corresponding header file:
- Right-click on the
Inc
folder in the project and select New | File. - In the...