O'Reilly logo

Embedded Systems Architecture by Daniele Lacamera

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming the transceiver

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required