SPI Config Struct
typedef struct{
u32 cpol; // Clock polarity during idle state setting
u32 cpha; // Clock phase setting
u32 mode; // SPI Mode setting
u32 clkDivider; // Clock divider setting on SCL generation
u32 ssSetup; // Clock cycle between activated chip-select and first rising-edge of SCLK
u32 ssHold; // Clock cycle between last falling-edge and deactivated chip-select is
//activated.
u32 ssDisable; // Clock cycle delay before the next chip select can be activated
} Spi_Config;
spi_applyConfig()
| Usage |
void spi_applyConfig(u32 reg, Spi_Config
*config) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address[IN]
config struct of the SPI
configuration |
| Description |
Applies the SPI configuration to a register for initial
configuration. |
spi_cmdAvailability()
| Usage |
u32 spi_cmdAvailability(u32 reg) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address |
| Returns |
[OUT] SPI TX FIFO availability (16 bits) |
| Description |
Reads the number of bytes for TX FIFO availability (up to 256
bytes). |
spi_diselect()
| Usage |
void spi_diselect(u32 reg, u32 slaveId) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address[IN]
slaveId ID for the slave |
| Description |
De-asserts the selected SPI (SS) pin based on the slaveId. SlaveId
range from 0 up to (SPI Chip Select Width) -1. SPI 0 only have 1 chip
select. |
spi_read()
| Usage |
u8 spi_read(u32 reg) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address |
| Returns |
[OUT] One byte of data |
| Description |
Receives one byte from the SPI slave. |
spi_read32()
| Usage |
u32 spi_read32(u32 reg) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address |
| Returns |
[OUT] Data (up to 16 bits) |
| Description |
Receives up to 16 bits of data from the SPI slave. |
spi_rspOccupancy()
| Usage |
u32 spi_rspOccupancy(u32 reg) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address |
| Returns |
[OUT] SPI RX FIFO occupancy (16 bits) |
| Description |
Read the number of bytes for RX FIFO occupancy. |
spi_select()
| Usage |
void spi_select(u32 reg, u32slaveId) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address [IN]
slaveId ID for the slave |
| Description |
Asserts the SPI select (SS) pin on the selected slave. |
spi_write()
| Usage |
void spi_write(u32reg, u8 data) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address[IN]
data 8 bits of data to send out |
| Description |
Transfers one byte to the SPI slave. |
spi_write32()
| Usage |
void spi_write32(u32 reg, u32 data) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address [IN]
data up to 16 bits of data to send
out |
| Description |
Transfers up to 16 bits to the SPI slave. |
spi_writeRead()
| Usage |
u8 spi_writeRead(u32 reg, u8 data) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address[IN]
data 8 bits of data to send out |
| Returns |
[OUT] One byte of data |
| Description |
Transfers one byte to the SPI slave and receives one byte from the SPI
slave. |
spi_writeRead32()
| Usage |
u32 spi_writeRead32(u32 reg, u32 data) |
| Include |
driver/spi.h |
| Parameters |
[IN] reg SPI base address [IN]
data up to 16 bits of data to send
out |
| Returns |
[OUT] Up to 16 bits of data |
| Description |
Transfers up to 16 bits of data to the SPI slave and receives up to 16
bits of data from the SPI slave. |