|
Serial Peripheral Interface Reusable Driver 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 creating a modular and efficient Serial Peripheral Interface (SPI) driver that can be easily adapted across various microcontroller families. The DIO driver is utilized to configure the selected SPI port for physical connectivity.
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 necessary low-level code to initialize and manage hardware peripherals like SPI modules.
The Application Layer contains no hardware-specific code but instead interacts with the hardware through the driver interfaces, ensuring abstraction and easier maintenance.
This project is developed as bare-metal firmware and adheres to industry-standard coding practices, specifically the MISRA-C guidelines.
Best practices such as consistent naming conventions, clear code formatting, modularity, and detailed documentation are followed throughout.
This demonstration configures the SPI1 peripheral as a master device with the following settings:
The physical connections between the STM32 Nucleo board and the KY-57 logic analyzer are configured using the DIO driver and follow this mapping:
| SPI Connection | Master | Logic Analyzer |
|---|---|---|
| NSS | PA9 | CH4 |
| SCK | PA5 | CH1 |
| MISO | PA6 | CH2 |
| MOSI | PA7 | CH3 |
During operation, the master continuously transmits the data byte 0x56 to the KY-57 logic analyzer for capture and analysis.
The project is fully documented using Doxygen.
Extensive inline comments provide insights into the functionality, assumptions, and limitations of the code.
The Doxygen-generated documentation offers a structured and easy-to-navigate reference for developers.