#include "chip.h"
Go to the source code of this file.
Data Structures |
struct | SpidCmd |
| Spi Transfer Request prepared by the application upper layer. More...
|
struct | Spid |
Defines |
#define | SPID_ERROR 1 |
#define | SPID_ERROR_LOCK 2 |
#define | SPID_CSR_SCBR(mck, spck) SPI_CSR_SCBR((mck) / (spck)) |
#define | SPID_CSR_DLYBS(mck, delay) |
#define | SPID_CSR_DLYBCT(mck, delay) |
Typedefs |
typedef void(* | SpidCallback )(uint8_t, void *) |
Functions |
uint32_t | SPID_Configure (Spid *pSpid, Spi *pSpiHw, uint8_t spiId, uint32_t SpiMode, sXdmad *pXdmad) |
| Initializes the Spid structure and the corresponding SPI & DMA hardware. select value. The driver will uses DMA channel 0 for RX and DMA channel 1 for TX. The DMA channels are freed automatically when no SPI command processing.
|
void | SPID_ConfigureCS (Spid *pSpid, uint32_t dwCS, uint32_t dwCsr) |
| Configures the parameters for the device corresponding to the cs value.
|
uint32_t | SPID_SendCommand (Spid *pSpid, SpidCmd *pCommand) |
| Starts a SPI master transfer. This is a non blocking function. It will return as soon as the transfer is started.
|
void | SPID_Handler (Spid *pSpid) |
| SPI DMA transfer ISR, Handle RX complete.
|
void | SPID_DmaHandler (Spid *pSpid) |
uint32_t | SPID_IsBusy (const Spid *pSpid) |
| Check if the SPI driver is busy.
|
Detailed Description
Implementation of SPI driver, transfer data through DMA.
Definition in file spi_dma.h.
Define Documentation
#define SPID_CSR_DLYBCT |
( |
|
mck, |
|
|
|
delay | |
|
) |
| | |
Value:SPI_CSR_DLYBCT((((delay) / 32 * \
((mck) / 1000000)) / 1000) + 1)
Calculates the value of the DLYBCT field of the Chip Select Register given delay in ns and MCK.
Definition at line 71 of file spi_dma.h.
#define SPID_CSR_DLYBS |
( |
|
mck, |
|
|
|
delay | |
|
) |
| | |
Value:SPI_CSR_DLYBS((((delay) * \
((mck) / 1000000)) / 1000) + 1)
Calculates the value of the DLYBS field of the Chip Select Register given delay in ns and MCK.
Definition at line 66 of file spi_dma.h.
#define SPID_CSR_SCBR |
( |
|
mck, |
|
|
|
spck | |
|
) |
| | SPI_CSR_SCBR((mck) / (spck)) |
Calculates the value of the SCBR field of the Chip Select Register given MCK and SPCK.
Definition at line 62 of file spi_dma.h.
An unspecified error has occurred.
Definition at line 51 of file spi_dma.h.
#define SPID_ERROR_LOCK 2 |
SPI driver is currently in use.
Definition at line 54 of file spi_dma.h.
Typedef Documentation
SPI transfer complete callback.
Definition at line 83 of file spi_dma.h.
Function Documentation
uint32_t SPID_Configure |
( |
Spid * |
pSpid, |
|
|
Spi * |
pSpiHw, |
|
|
uint8_t |
spiId, |
|
|
uint32_t |
spiMode, |
|
|
sXdmad * |
pXdmad | |
|
) |
| | |
Initializes the Spid structure and the corresponding SPI & DMA hardware. select value. The driver will uses DMA channel 0 for RX and DMA channel 1 for TX. The DMA channels are freed automatically when no SPI command processing.
- Parameters:
-
| pSpid | Pointer to a Spid instance. |
| pSpiHw | Associated SPI peripheral. |
| spiId | SPI peripheral identifier. |
| pDmad | Pointer to a Dmad instance. |
Definition at line 282 of file spi_dma.c.
void SPID_ConfigureCS |
( |
Spid * |
pSpid, |
|
|
uint32_t |
dwCS, |
|
|
uint32_t |
dwCsr | |
|
) |
| | |
Configures the parameters for the device corresponding to the cs value.
- Parameters:
-
| pSpid | Pointer to a Spid instance. |
| cs | number corresponding to the SPI chip select. |
| csr | SPI_CSR value to setup. |
Definition at line 309 of file spi_dma.c.
void SPID_Handler |
( |
Spid * |
pSpid |
) |
|
SPI DMA transfer ISR, Handle RX complete.
The SPI_Handler must be called by the SPI Interrupt Service Routine with the corresponding Spi instance. The SPI_Handler will unlock the Spi semaphore and invoke the upper application callback.
- Parameters:
-
| pSpid | Pointer to a Spid instance. |
Definition at line 167 of file spid.c.
uint32_t SPID_IsBusy |
( |
const Spid * |
pSpid |
) |
|
Check if the SPI driver is busy.
- Parameters:
-
| pSpid | Pointer to a Spid instance. |
- Returns:
- 1 if the SPI driver is currently busy executing a command; otherwise
Returns 1 if the SPI driver is currently busy executing a command; otherwise returns 0.
- Parameters:
-
| pSpid | Pointer to a SPI driver instance. |
Definition at line 387 of file spi_dma.c.
uint32_t SPID_SendCommand |
( |
Spid * |
pSpid, |
|
|
SpidCmd * |
pCommand | |
|
) |
| | |
Starts a SPI master transfer. This is a non blocking function. It will return as soon as the transfer is started.
- Parameters:
-
| pSpid | Pointer to a Spid instance. |
| pCommand | Pointer to the SPI command to execute. |
- Returns:
- 0 if the transfer has been started successfully; otherwise returns SPID_ERROR_LOCK is the driver is in use, or SPID_ERROR if the command is not valid.
Starts a SPI master transfer. This is a non blocking function. It will return as soon as the transfer is started. Returns 0 if the transfer has been started successfully; otherwise returns SPID_ERROR_LOCK is the driver is in use, or SPID_ERROR if the command is not valid.
- Parameters:
-
| pSpid | Pointer to a Spid instance. |
| pCommand | Pointer to the SPI command to execute. |
Definition at line 335 of file spi_dma.c.