RTEMS 6.1-rc5
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
spi_dma.h File Reference
#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
 

Macros

#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 *)
 
typedef struct _SpidCmd SpidCmd
 Spi Transfer Request prepared by the application upper layer.
 
typedef struct _Spid Spid
 

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)
 
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.

Macro Definition Documentation

◆ SPID_CSR_DLYBCT

#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.

◆ SPID_CSR_DLYBS

#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.

◆ SPID_CSR_SCBR

#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.

◆ SPID_ERROR

#define SPID_ERROR   1

An unspecified error has occurred.

◆ SPID_ERROR_LOCK

#define SPID_ERROR_LOCK   2

SPI driver is currently in use.

Typedef Documentation

◆ Spid

typedef struct _Spid Spid

Constant structure associated with SPI port. This structure prevents client applications to have access in the same time.

◆ SpidCallback

typedef void(* SpidCallback) (uint8_t, void *)

SPI transfer complete callback.

◆ SpidCmd

typedef struct _SpidCmd SpidCmd

Spi Transfer Request prepared by the application upper layer.

This structure is sent to the SPI_SendCommand function to start the transfer. At the end of the transfer, the callback is invoked by the interrupt handler.

Function Documentation

◆ SPID_Configure()

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
pSpidPointer to a Spid instance.
pSpiHwAssociated SPI peripheral.
spiIdSPI peripheral identifier.
pDmadPointer to a Dmad instance.

◆ SPID_ConfigureCS()

void SPID_ConfigureCS ( Spid pSpid,
uint32_t  dwCS,
uint32_t  dwCsr 
)

Configures the parameters for the device corresponding to the cs value.

Parameters
pSpidPointer to a Spid instance.
csnumber corresponding to the SPI chip select.
csrSPI_CSR value to setup.

◆ SPID_IsBusy()

uint32_t SPID_IsBusy ( const Spid pSpid)

Check if the SPI driver is busy.

Parameters
pSpidPointer to a Spid instance.
Returns
1 if the SPI driver is currently busy executing a command; otherwise

◆ SPID_SendCommand()

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
pSpidPointer to a Spid instance.
pCommandPointer 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.