MCUXpresso SDK API Reference Manual  Rev 2.15.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the SPI DMA driver.

Files

file  fsl_spi_dma.h
 

Data Structures

struct  _spi_dma_handle
 SPI DMA transfer handle, users should not touch the content of the handle. More...
 

Typedefs

typedef void(* spi_dma_callback_t )(SPI_Type *base, spi_dma_handle_t *handle, status_t status, void *userData)
 SPI DMA callback called at the end of transfer. More...
 

Driver version

#define FSL_SPI_DMA_DRIVER_VERSION   (MAKE_VERSION(2, 2, 1))
 SPI DMA driver version 2.1.1. More...
 

DMA Transactional

status_t SPI_MasterTransferCreateHandleDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_dma_callback_t callback, void *userData, dma_handle_t *txHandle, dma_handle_t *rxHandle)
 Initialize the SPI master DMA handle. More...
 
status_t SPI_MasterTransferDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_transfer_t *xfer)
 Perform a non-blocking SPI transfer using DMA. More...
 
status_t SPI_MasterHalfDuplexTransferDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_half_duplex_transfer_t *xfer)
 Transfers a block of data using a DMA method. More...
 
static status_t SPI_SlaveTransferCreateHandleDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_dma_callback_t callback, void *userData, dma_handle_t *txHandle, dma_handle_t *rxHandle)
 Initialize the SPI slave DMA handle. More...
 
static status_t SPI_SlaveTransferDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_transfer_t *xfer)
 Perform a non-blocking SPI transfer using DMA. More...
 
void SPI_MasterTransferAbortDMA (SPI_Type *base, spi_dma_handle_t *handle)
 Abort a SPI transfer using DMA. More...
 
status_t SPI_MasterTransferGetCountDMA (SPI_Type *base, spi_dma_handle_t *handle, size_t *count)
 Gets the master DMA transfer remaining bytes. More...
 
static void SPI_SlaveTransferAbortDMA (SPI_Type *base, spi_dma_handle_t *handle)
 Abort a SPI transfer using DMA. More...
 
static status_t SPI_SlaveTransferGetCountDMA (SPI_Type *base, spi_dma_handle_t *handle, size_t *count)
 Gets the slave DMA transfer remaining bytes. More...
 

Data Structure Documentation

struct _spi_dma_handle

Data Fields

volatile bool txInProgress
 Send transfer finished.
 
volatile bool rxInProgress
 Receive transfer finished.
 
uint8_t bytesPerFrame
 Bytes in a frame for SPI transfer.
 
uint8_t lastwordBytes
 The Bytes of lastword for master.
 
dma_handle_ttxHandle
 DMA handler for SPI send.
 
dma_handle_trxHandle
 DMA handler for SPI receive.
 
spi_dma_callback_t callback
 Callback for SPI DMA transfer.
 
void * userData
 User Data for SPI DMA callback.
 
uint32_t state
 Internal state of SPI DMA transfer.
 
size_t transferSize
 Bytes need to be transfer.
 
uint32_t instance
 Index of SPI instance.
 
uint8_t * txNextData
 The pointer of next time tx data.
 
uint8_t * txEndData
 The pointer of end of data.
 
uint8_t * rxNextData
 The pointer of next time rx data.
 
uint8_t * rxEndData
 The pointer of end of rx data.
 
uint32_t dataBytesEveryTime
 Bytes in a time for DMA transfer, default is DMA_MAX_TRANSFER_COUNT.
 

Macro Definition Documentation

#define FSL_SPI_DMA_DRIVER_VERSION   (MAKE_VERSION(2, 2, 1))

Typedef Documentation

typedef void(* spi_dma_callback_t)(SPI_Type *base, spi_dma_handle_t *handle, status_t status, void *userData)

Function Documentation

status_t SPI_MasterTransferCreateHandleDMA ( SPI_Type *  base,
spi_dma_handle_t handle,
spi_dma_callback_t  callback,
void *  userData,
dma_handle_t txHandle,
dma_handle_t rxHandle 
)

This function initializes the SPI master DMA handle which can be used for other SPI master transactional APIs. Usually, for a specified SPI instance, user need only call this API once to get the initialized handle.

Parameters
baseSPI peripheral base address.
handleSPI handle pointer.
callbackUser callback function called at the end of a transfer.
userDataUser data for callback.
txHandleDMA handle pointer for SPI Tx, the handle shall be static allocated by users.
rxHandleDMA handle pointer for SPI Rx, the handle shall be static allocated by users.
status_t SPI_MasterTransferDMA ( SPI_Type *  base,
spi_dma_handle_t handle,
spi_transfer_t xfer 
)
Note
This interface returned immediately after transfer initiates, users should call SPI_GetTransferStatus to poll the transfer status to check whether SPI transfer finished.
Parameters
baseSPI peripheral base address.
handleSPI DMA handle pointer.
xferPointer to dma transfer structure.
Return values
kStatus_SuccessSuccessfully start a transfer.
kStatus_InvalidArgumentInput argument is invalid.
kStatus_SPI_BusySPI is not idle, is running another transfer.
status_t SPI_MasterHalfDuplexTransferDMA ( SPI_Type *  base,
spi_dma_handle_t handle,
spi_half_duplex_transfer_t xfer 
)

This function using polling way to do the first half transimission and using DMA way to do the srcond half transimission, the transfer mechanism is half-duplex. When do the second half transimission, code will return right away. When all data is transferred, the callback function is called.

Parameters
baseSPI base pointer
handleA pointer to the spi_master_dma_handle_t structure which stores the transfer state.
xferA pointer to the spi_half_duplex_transfer_t structure.
Returns
status of status_t.
static status_t SPI_SlaveTransferCreateHandleDMA ( SPI_Type *  base,
spi_dma_handle_t handle,
spi_dma_callback_t  callback,
void *  userData,
dma_handle_t txHandle,
dma_handle_t rxHandle 
)
inlinestatic

This function initializes the SPI slave DMA handle which can be used for other SPI master transactional APIs. Usually, for a specified SPI instance, user need only call this API once to get the initialized handle.

Parameters
baseSPI peripheral base address.
handleSPI handle pointer.
callbackUser callback function called at the end of a transfer.
userDataUser data for callback.
txHandleDMA handle pointer for SPI Tx, the handle shall be static allocated by users.
rxHandleDMA handle pointer for SPI Rx, the handle shall be static allocated by users.
static status_t SPI_SlaveTransferDMA ( SPI_Type *  base,
spi_dma_handle_t handle,
spi_transfer_t xfer 
)
inlinestatic
Note
This interface returned immediately after transfer initiates, users should call SPI_GetTransferStatus to poll the transfer status to check whether SPI transfer finished.
Parameters
baseSPI peripheral base address.
handleSPI DMA handle pointer.
xferPointer to dma transfer structure.
Return values
kStatus_SuccessSuccessfully start a transfer.
kStatus_InvalidArgumentInput argument is invalid.
kStatus_SPI_BusySPI is not idle, is running another transfer.
void SPI_MasterTransferAbortDMA ( SPI_Type *  base,
spi_dma_handle_t handle 
)
Parameters
baseSPI peripheral base address.
handleSPI DMA handle pointer.
status_t SPI_MasterTransferGetCountDMA ( SPI_Type *  base,
spi_dma_handle_t handle,
size_t *  count 
)

This function gets the master DMA transfer remaining bytes.

Parameters
baseSPI peripheral base address.
handleA pointer to the spi_dma_handle_t structure which stores the transfer state.
countA number of bytes transferred by the non-blocking transaction.
Returns
status of status_t.
static void SPI_SlaveTransferAbortDMA ( SPI_Type *  base,
spi_dma_handle_t handle 
)
inlinestatic
Parameters
baseSPI peripheral base address.
handleSPI DMA handle pointer.
static status_t SPI_SlaveTransferGetCountDMA ( SPI_Type *  base,
spi_dma_handle_t handle,
size_t *  count 
)
inlinestatic

This function gets the slave DMA transfer remaining bytes.

Parameters
baseSPI peripheral base address.
handleA pointer to the spi_dma_handle_t structure which stores the transfer state.
countA number of bytes transferred by the non-blocking transaction.
Returns
status of status_t.