Module Description
On-chip serial USART driver for the 8-bit AVR8 microcontrollers.
- Note
- This file should not be included directly. It is automatically included as needed by the SPI Master driver dispatch header located in LUFA/Drivers/Peripheral/SerialSPI.h.
Example Usage
The following snippet is an example of how this module may be used within a typical application.
#define USART_SPI_ORDER_LSB_FIRST (1 << UDORD1) |
SPI data order mask for SerialSPI_Init(). Indicates that data should be shifted out LSB first.
#define USART_SPI_ORDER_MSB_FIRST (0 << UDORD1) |
SPI data order mask for SerialSPI_Init(). Indicates that data should be shifted out MSB first.
#define USART_SPI_SAMPLE_LEADING (0 << UCPHA1) |
SPI data sample mode mask for SerialSPI_Init(). Indicates that the data should sampled on the leading edge.
#define USART_SPI_SAMPLE_TRAILING (1 << UCPHA1) |
SPI data sample mode mask for SerialSPI_Init(). Indicates that the data should be sampled on the trailing edge.
#define USART_SPI_SCK_LEAD_FALLING (1 << UCPOL1) |
SPI clock polarity mask for SPI_Init(). Indicates that the SCK should lead on the falling edge.
#define USART_SPI_SCK_LEAD_RISING (0 << UCPOL1) |
SPI clock polarity mask for SPI_Init(). Indicates that the SCK should lead on the rising edge.
static void SerialSPI_Disable |
( |
void |
| ) |
|
|
inlinestatic |
Turns off the USART driver, disabling and returning used hardware to their default configuration.
static void SerialSPI_Init |
( |
const uint8_t |
SPIOptions, |
|
|
const uint32_t |
BaudRate |
|
) |
| |
|
inlinestatic |
Initialize the USART module in Master SPI mode.
- Parameters
-
[in] | SPIOptions | USART SPI Options, a mask consisting of one of each of the USART_SPI_SCK_* , USART_SPI_SAMPLE_* and USART_SPI_ORDER_* masks. |
[in] | BaudRate | SPI baud rate, in bits per second. |
static uint8_t SerialSPI_ReceiveByte |
( |
void |
| ) |
|
|
inlinestatic |
Sends a dummy byte through the USART SPI interface, blocking until the transfer is complete. The response byte from the attached SPI device is returned.
- Returns
- The response byte from the attached SPI device.
static void SerialSPI_SendByte |
( |
const uint8_t |
DataByte | ) |
|
|
inlinestatic |
Sends a byte through the USART SPI interface, blocking until the transfer is complete. The response byte sent to from the attached SPI device is ignored.
- Parameters
-
[in] | DataByte | Byte to send through the USART SPI interface. |
static uint8_t SerialSPI_TransferByte |
( |
const uint8_t |
DataByte | ) |
|
|
inlinestatic |
Sends and receives a byte through the USART SPI interface, blocking until the transfer is complete.
- Parameters
-
[in] | DataByte | Byte to send through the USART SPI interface. |
- Returns
- Response byte from the attached SPI device.