SPIDriver

Description

Basic Serial Peripheral Interface Driver.

Simple, blocking SPI controller 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)
uint32_t spi_getUsartPPUSATD (uint32_t *ppusatdNr)

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 peripheral select line. Polarity is configured by spi_init .

void spi_setCsInactive ( void )

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

uint32_t spi_getUsartPPUSATD ( uint32_t * ppusatdNr )

Get PPUSATD word of the (E)USART in use.

Parameters
[out] ppusatdNr PPUSATD register number
Returns
The PPUSATD word of the (E)USART in use