Developing the SPI driver
Create a copy of your previous project in your IDE and rename this copied project to SPI
. Next, create a new file named spi.c
in the Src
folder and another file named spi.h
in the Inc
folder. Populate your spi.c
file with the following code:
#include "spi.h" #define SPI1EN (1U<<12) #define GPIOAEN (1U<<0) #define SR_TXE (1U<<1) #define SR_RXNE (1U<<0) #define SR_BSY (1U<<7) void spi_gpio_init(void) { /*Enable clock access to GPIOA*/ RCC->AHB1ENR |= GPIOAEN; /*Set PA5,PA6,PA7 mode to alternate...