Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SPI - Serial Peripheral Interface

Driver for the Serial Peripheral Interface (SPI).

Provides functions for configuring and using the SPI.

Modules

 

Functions

static void spi_disable (SPI_t *spi)
 Disables the SPI. More...
 
static void spi_enable (SPI_t *spi)
 Enables the SPI. More...
 
static void spi_enable_master_mode (SPI_t *spi)
 Activate SPI master mode of a SPI peripheral. More...
 
static uint8_t spi_get (SPI_t *spi)
 Get one data byte to a SPI peripheral. More...
 
static bool spi_is_enabled (SPI_t *spi)
 Tests if the SPI is enabled. More...
 
static bool spi_is_tx_ok (SPI_t *spi)
 Tests if the SPI contains a received character. More...
 
static void spi_put (SPI_t *spi, uint8_t data)
 Put one data byte to a SPI peripheral. More...
 
int8_t spi_xmega_set_baud_div (SPI_t *spi, uint32_t baudrate, uint32_t clkper_hz)
 Calculates the SPI baudrate divider. More...
 

static void spi_disable ( SPI_t *  spi)
inlinestatic

Disables the SPI.

Ensures that nothing is transferred while setting up buffers.

Parameters
spiBase address of the SPI instance.
Warning
This may cause data loss if used on a slave SPI.
static void spi_enable ( SPI_t *  spi)
inlinestatic

Enables the SPI.

Parameters
spiBase address of the SPI instance.
static void spi_enable_master_mode ( SPI_t *  spi)
inlinestatic

Activate SPI master mode of a SPI peripheral.

Parameters
spiBase address of the SPI instance.
Warning
This may cause data loss if used on a slave SPI.

Referenced by spi_master_init().

static uint8_t spi_get ( SPI_t *  spi)
inlinestatic

Get one data byte to a SPI peripheral.

Parameters
spiBase address of the SPI instance.
Returns
The data byte

Referenced by spi_read_single().

static bool spi_is_enabled ( SPI_t *  spi)
inlinestatic

Tests if the SPI is enabled.

Parameters
spiBase address of the SPI instance.
Returns
1 if the SPI is enabled, otherwise 0.
static bool spi_is_tx_ok ( SPI_t *  spi)
inlinestatic

Tests if the SPI contains a received character.

Parameters
spiBase address of the SPI instance.
Returns
1 if the SPI Receive Holding Register is full, otherwise 0.

Referenced by hx8347a_send_byte(), spi_is_rx_full(), spi_is_rx_ready(), spi_is_tx_empty(), and spi_is_tx_ready().

static void spi_put ( SPI_t *  spi,
uint8_t  data 
)
inlinestatic

Put one data byte to a SPI peripheral.

Parameters
spiBase address of the SPI instance.
dataThe data byte to be loaded

References data.

Referenced by spi_write_single().

int8_t spi_xmega_set_baud_div ( SPI_t *  spi,
uint32_t  baudrate,
uint32_t  clkper_hz 
)

Calculates the SPI baudrate divider.

Parameters
baudrateThe expected baudrate on the SPI.
clkper_hzSPI module input clock frequency (Peripheral clock, Hz).
spiThe SPI module address
Returns
Divider or error code.
Return values
>=0Success.
<0Error.
Parameters
baudrateThe expected baudrate on the SPI.
clkper_hzSPI module input clock frequency (Peripheral clock, Hz).
spiThe SPI module address
Returns
Status of operation.
Return values
>=0Success.
<0Error.

References Assert.

Referenced by run_baudrate_set_test(), and spi_master_setup_device().