SPIDriver

Description

Basic Serial Peripheral Interface driver.

Simple, blocking SPI master implementation for communication with external devices.

Functions

void spi_init (void)
void spi_deinit (void)
void spi_writeByte (uint8_t data)
void spi_writeHalfword (uint16_t data)
void spi_write3Byte (uint32_t data)
uint8_t spi_readByte (void)
uint16_t spi_readHalfword (void)
void spi_setCsActive (void)
void spi_setCsInactive (void)

Function Documentation

void spi_init ( void )

Initialize a USART peripheral for SPI

void spi_deinit ( void )

De-initialize a USART peripheral for SPI

void spi_writeByte ( uint8_t data )

Write a single byte, discarding the received byte

Parameters
[in] data The byte to send
void spi_writeHalfword ( uint16_t data )

Write two bytes, discarding the received bytes

Parameters
[in] data The bytes to send, most significant byte first
void spi_write3Byte ( uint32_t data )

Write three bytes, discarding the received bytes

Parameters
[in] data The bytes to send, most significant byte first
uint8_t spi_readByte ( void )

Read a byte by sending a 0xFF byte

Returns
The received byte
uint16_t spi_readHalfword ( void )

Read two bytes by sending two 0xFF bytes

Returns
The received bytes, most significant byte first
void spi_setCsActive ( void )

Assert the slave select line. Polarity is configured by spi_init .

void spi_setCsInactive ( void )

Dessert the slave select line. Polarity is configured by spi_init .