On the reference board, an accelerometer is connected as slave to the SPI1 bus, so we can examine how to implement the master side of the communication on the microcontroller by configuring the transceiver and executing a bidirectional transaction toward the peripheral.
The SPI1 bus has its configuration registers mapped in the peripherals region:
#define SPI1 (0x40013000)#define SPI1_CR1 (*(volatile uint32_t *)(SPI1))#define SPI1_CR2 (*(volatile uint32_t *)(SPI1 + 0x04))#define SPI1_SR (*(volatile uint32_t *)(SPI1 + 0x08))#define SPI1_DR (*(volatile uint32_t *)(SPI1 + 0x0c))
The peripheral exposes a total of four registers:
- Two bit-field configuration registers
- One status register
- One bidirectional data register ...