How To Write An STM32 SPI Driver (Full-Duplex Master Mode)

This tutorial demonstrates how to write a full-duplex SPI driver for an STM32 microcontroller without any hardware abstraction layers (bare metal) to communicate over the Serial Peripheral Interface (SPI) with other SPI devices with the microcontroller being the master on the bus. The tutorial covers the necessary SPI theory, STM32 SPI registers required and includes a coded example developed throughout the tutorial. After the code is fully developed, the SPI driver is tested by getting the microcontroller to communicate with the MPU9250 and reading data from its registers. The microcontroller used is the STM32L432KC but the registers, programming, and configuration are the same (or similar) across the stm32 boards. The tutorial covers the MPU9250 IMU to provide context for configuration choices of the SPI peripheral in the microcontroller. Source code for this tutorial is available at: To Write An STM32 SPI Driver (Fu
Back to Top