|
Serial Peripheral Interface Reusable Driver (Master-Slave) v1.1
This project implements SPI reusable driver that can be adapted to various microcontrollers.
|
This project is a personal initiative aimed at developing reusable firmware components for microcontroller platforms. It focuses on building a modular and efficient SPI (Serial Peripheral Interface) driver that facilitates communication between two STM32 Nucleo-F401RE boards configured in a Master-Slave setup. The DIO driver is used to configure the selected SPI pins and establish the necessary physical connections.
The software architecture follows a layered approach. This design pattern separates low-level driver code (HALs) from application-specific code, promoting reusability and simplifying portability between different applications or microcontrollers. The layered architecture can be seen in figure 1 and contains a driver and application layer operating on the hardware.
| Application Code |
| Drivers |
| Hardware |
The Driver Layer includes all code required to initialize and control microcontroller peripherals.
The Application Layer uses these drivers to implement the program logic, keeping hardware interactions abstracted and maintainable.
This firmware is developed using a bare-metal approach and adheres to the MISRA-C guidelines. Standardized naming, consistent formatting, modular design, and structured documentation practices are followed throughout the project.
This setup uses two STM32 Nucleo-F401RE boards: one as SPI master, and the other as SPI slave.
The configuration includes:
The GPIO (DIO) driver configures the pin mappings, as shown in the table below:
| SPI Connection | Master | Slave | Logic Analyzer |
|---|---|---|---|
| NSS | PA4 | PA4 | CH4 |
| SCK | PA5 | PA5 | CH1 |
| MISO | PA6 | PA6 | CH2 |
| MOSI | PA7 | PA7 | CH3 |
Operation Summary:
The codebase is thoroughly documented using Doxygen, with inline comments detailing the logic and configuration of each module. The generated documentation provides an intuitive, navigable interface to explore API details and implementation specifics.