SPI Driver (Not Implemented)

Features

  • SPI register read/write function

  • Chip select signal toggle by GPIO driver

SPI Controller Functions

Initialization

void spi_init(uint8_t freq)

Initialize SPI module and set up pins.

Parameters
  • freq (uint8_t) – frequency divider, exact meaning TBD

Transmit

void spi_tx(uint8_t data)

Transmit SPI

Parameters
  • data (uint8_t) – 8 bit data to write

Receive

uint8_t spi_rx(void)

Receive SPI

Returns

Received byte

Return type

uint8_t

Write 8-bit Register

void spi_write8(uint8_t reg_addr, uint8_t value)

Write to a 8-bit register of a SPI peripheral. Note that toggle CS line have to be done before and after calling this function.

Parameters
  • reg_addr (uint8_t) – 8 bit register address

  • value (uint8_t) – 8 bit data to be written

Read 8-bit Register

uint8_t spi_read8(uint8_t reg_addr)

Read from a 8-bit register of a SPI peripheral. Note that toggle CS line have to be done before and after calling this function.

Parameters
  • reg_addr (uint8_t) – 8 bit register address

Returns

data read from the register

Return type

uint8_t