Detailed Description
Module Description
Driver for the hardware SPI port available on most 8-bit AVR microcontroller models. This module provides an easy to use driver for the setup and transfer of data over the AVR's SPI port.
- Note:
- This file should not be included directly. It is automatically included as needed by the SPI driver dispatch header located in LUFA/Drivers/Peripheral/SPI.h.
Example Usage
The following snippet is an example of how this module may be used within a typical application.
Define Documentation
SPI mode mask for SPI_Init(). Indicates that the SPI interface should be initialized into master mode.
SPI mode mask for SPI_Init(). Indicates that the SPI interface should be initialized into slave mode.
SPI data order mask for SPI_Init(). Indicates that data should be shifted out LSB first.
SPI data order mask for SPI_Init(). Indicates that data should be shifted out MSB first.
SPI data sample mode mask for SPI_Init(). Indicates that the data should sampled on the leading edge.
SPI data sample mode mask for SPI_Init(). Indicates that the data should be sampled on the trailing edge.
SPI clock polarity mask for SPI_Init(). Indicates that the SCK should lead on the falling edge.
SPI clock polarity mask for SPI_Init(). Indicates that the SCK should lead on the rising edge.
SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 128.
SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 16.
SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 2.
SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 32.
SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 4.
SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 64.
SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 8.
Function Documentation
Turns off the SPI driver, disabling and returning used hardware to their default configuration.
Retrieves the currently selected SPI mode, once the SPI interface has been configured.
- Returns:
- SPI_MODE_MASTER if the interface is currently in SPI Master mode, SPI_MODE_SLAVE otherwise
static void SPI_Init |
( |
const uint8_t |
SPIOptions | ) |
[inline, static] |
Initializes the SPI subsystem, ready for transfers. Must be called before calling any other SPI routines.
- Parameters:
-
[in] | SPIOptions | SPI Options, a mask consisting of one of each of the SPI_SPEED_* , SPI_SCK_* , SPI_SAMPLE_* , SPI_ORDER_* and SPI_MODE_* masks. |
Sends a dummy byte through the 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 SPI_SendByte |
( |
const uint8_t |
Byte | ) |
[inline, static] |
Sends a byte through the SPI interface, blocking until the transfer is complete. The response byte sent to from the attached SPI device is ignored.
- Parameters:
-
[in] | Byte | Byte to send through the SPI interface. |
Sends and receives a byte through the SPI interface, blocking until the transfer is complete.
- Parameters:
-
[in] | Byte | Byte to send through the SPI interface. |
- Returns:
- Response byte from the attached SPI device.