Kinetis SDK v.2.0 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the DSPI Peripheral driver. The DSPI driver configures DSPI module, provides the functional and transactional interfaces to build the DSPI application.

Files

file  fsl_dspi_edma.h
 

Data Structures

struct  dspi_master_edma_handle_t
 DSPI master eDMA transfer handle structure used for transactional API. More...
 
struct  dspi_slave_edma_handle_t
 DSPI slave eDMA transfer handle structure used for transactional API. More...
 

Typedefs

typedef void(* dspi_master_edma_transfer_callback_t )(SPI_Type *base, dspi_master_edma_handle_t *handle, status_t status, void *userData)
 Completion callback function pointer type. More...
 
typedef void(* dspi_slave_edma_transfer_callback_t )(SPI_Type *base, dspi_slave_edma_handle_t *handle, status_t status, void *userData)
 Completion callback function pointer type. More...
 

Functions

void DSPI_MasterTransferCreateHandleEDMA (SPI_Type *base, dspi_master_edma_handle_t *handle, dspi_master_edma_transfer_callback_t callback, void *userData, edma_handle_t *edmaRxRegToRxDataHandle, edma_handle_t *edmaTxDataToIntermediaryHandle, edma_handle_t *edmaIntermediaryToTxRegHandle)
 Initializes the DSPI master eDMA handle. More...
 
status_t DSPI_MasterTransferEDMA (SPI_Type *base, dspi_master_edma_handle_t *handle, dspi_transfer_t *transfer)
 DSPI master transfer data using eDMA. More...
 
void DSPI_MasterTransferAbortEDMA (SPI_Type *base, dspi_master_edma_handle_t *handle)
 DSPI master aborts a transfer which using eDMA. More...
 
status_t DSPI_MasterTransferGetCountEDMA (SPI_Type *base, dspi_master_edma_handle_t *handle, size_t *count)
 Gets the master eDMA transfer count. More...
 
void DSPI_SlaveTransferCreateHandleEDMA (SPI_Type *base, dspi_slave_edma_handle_t *handle, dspi_slave_edma_transfer_callback_t callback, void *userData, edma_handle_t *edmaRxRegToRxDataHandle, edma_handle_t *edmaTxDataToTxRegHandle)
 Initializes the DSPI slave eDMA handle. More...
 
status_t DSPI_SlaveTransferEDMA (SPI_Type *base, dspi_slave_edma_handle_t *handle, dspi_transfer_t *transfer)
 DSPI slave transfer data using eDMA. More...
 
void DSPI_SlaveTransferAbortEDMA (SPI_Type *base, dspi_slave_edma_handle_t *handle)
 DSPI slave aborts a transfer which using eDMA. More...
 
status_t DSPI_SlaveTransferGetCountEDMA (SPI_Type *base, dspi_slave_edma_handle_t *handle, size_t *count)
 Gets the slave eDMA transfer count. More...
 

Data Structure Documentation

struct _dspi_master_edma_handle

Forward declaration of the DSPI eDMA master handle typedefs.

Data Fields

uint32_t bitsPerFrame
 Desired number of bits per frame. More...
 
volatile uint32_t command
 Desired data command. More...
 
volatile uint32_t lastCommand
 Desired last data command. More...
 
uint8_t fifoSize
 FIFO dataSize. More...
 
volatile bool isPcsActiveAfterTransfer
 Is PCS signal keep active after the last frame transfer. More...
 
volatile bool isThereExtraByte
 Is there extra byte. More...
 
uint8_t *volatile txData
 Send buffer. More...
 
uint8_t *volatile rxData
 Receive buffer. More...
 
volatile size_t remainingSendByteCount
 Number of bytes remaining to send. More...
 
volatile size_t remainingReceiveByteCount
 Number of bytes remaining to receive. More...
 
size_t totalByteCount
 Number of transfer bytes.
 
uint32_t rxBuffIfNull
 Used if there is not rxData for DMA purpose. More...
 
uint32_t txBuffIfNull
 Used if there is not txData for DMA purpose. More...
 
volatile uint8_t state
 DSPI transfer state , _dspi_transfer_state. More...
 
dspi_master_edma_transfer_callback_t callback
 Completion callback. More...
 
void * userData
 Callback user data. More...
 
edma_handle_tedmaRxRegToRxDataHandle
 edma_handle_t handle point used for RxReg to RxData buff
 
edma_handle_tedmaTxDataToIntermediaryHandle
 edma_handle_t handle point used for TxData to Intermediary
 
edma_handle_tedmaIntermediaryToTxRegHandle
 edma_handle_t handle point used for Intermediary to TxReg
 
edma_tcd_t dspiSoftwareTCD [2]
 SoftwareTCD , internal used.
 

Field Documentation

uint32_t dspi_master_edma_handle_t::bitsPerFrame
volatile uint32_t dspi_master_edma_handle_t::command
volatile uint32_t dspi_master_edma_handle_t::lastCommand
uint8_t dspi_master_edma_handle_t::fifoSize
volatile bool dspi_master_edma_handle_t::isPcsActiveAfterTransfer
volatile bool dspi_master_edma_handle_t::isThereExtraByte
uint8_t* volatile dspi_master_edma_handle_t::txData
uint8_t* volatile dspi_master_edma_handle_t::rxData
volatile size_t dspi_master_edma_handle_t::remainingSendByteCount
volatile size_t dspi_master_edma_handle_t::remainingReceiveByteCount
uint32_t dspi_master_edma_handle_t::rxBuffIfNull
uint32_t dspi_master_edma_handle_t::txBuffIfNull
volatile uint8_t dspi_master_edma_handle_t::state
dspi_master_edma_transfer_callback_t dspi_master_edma_handle_t::callback
void* dspi_master_edma_handle_t::userData
struct _dspi_slave_edma_handle

Forward declaration of the DSPI eDMA slave handle typedefs.

Data Fields

uint32_t bitsPerFrame
 Desired number of bits per frame. More...
 
volatile bool isThereExtraByte
 Is there extra byte. More...
 
uint8_t *volatile txData
 Send buffer. More...
 
uint8_t *volatile rxData
 Receive buffer. More...
 
volatile size_t remainingSendByteCount
 Number of bytes remaining to send. More...
 
volatile size_t remainingReceiveByteCount
 Number of bytes remaining to receive. More...
 
size_t totalByteCount
 Number of transfer bytes.
 
uint32_t rxBuffIfNull
 Used if there is not rxData for DMA purpose. More...
 
uint32_t txBuffIfNull
 Used if there is not txData for DMA purpose. More...
 
uint32_t txLastData
 Used if there is an extra byte when 16bits per frame for DMA purpose. More...
 
volatile uint8_t state
 DSPI transfer state. More...
 
uint32_t errorCount
 Error count for slave transfer. More...
 
dspi_slave_edma_transfer_callback_t callback
 Completion callback. More...
 
void * userData
 Callback user data. More...
 
edma_handle_tedmaRxRegToRxDataHandle
 edma_handle_t handle point used for RxReg to RxData buff
 
edma_handle_tedmaTxDataToTxRegHandle
 edma_handle_t handle point used for TxData to TxReg
 
edma_tcd_t dspiSoftwareTCD [2]
 SoftwareTCD , internal used.
 

Field Documentation

uint32_t dspi_slave_edma_handle_t::bitsPerFrame
volatile bool dspi_slave_edma_handle_t::isThereExtraByte
uint8_t* volatile dspi_slave_edma_handle_t::txData
uint8_t* volatile dspi_slave_edma_handle_t::rxData
volatile size_t dspi_slave_edma_handle_t::remainingSendByteCount
volatile size_t dspi_slave_edma_handle_t::remainingReceiveByteCount
uint32_t dspi_slave_edma_handle_t::rxBuffIfNull
uint32_t dspi_slave_edma_handle_t::txBuffIfNull
uint32_t dspi_slave_edma_handle_t::txLastData
volatile uint8_t dspi_slave_edma_handle_t::state
uint32_t dspi_slave_edma_handle_t::errorCount
dspi_slave_edma_transfer_callback_t dspi_slave_edma_handle_t::callback
void* dspi_slave_edma_handle_t::userData

Typedef Documentation

typedef void(* dspi_master_edma_transfer_callback_t)(SPI_Type *base, dspi_master_edma_handle_t *handle, status_t status, void *userData)
Parameters
baseDSPI peripheral base address.
handlePointer to the handle for the DSPI master.
statusSuccess or error code describing whether the transfer completed.
userDataArbitrary pointer-dataSized value passed from the application.
typedef void(* dspi_slave_edma_transfer_callback_t)(SPI_Type *base, dspi_slave_edma_handle_t *handle, status_t status, void *userData)
Parameters
baseDSPI peripheral base address.
handlePointer to the handle for the DSPI slave.
statusSuccess or error code describing whether the transfer completed.
userDataArbitrary pointer-dataSized value passed from the application.

Function Documentation

void DSPI_MasterTransferCreateHandleEDMA ( SPI_Type *  base,
dspi_master_edma_handle_t *  handle,
dspi_master_edma_transfer_callback_t  callback,
void *  userData,
edma_handle_t edmaRxRegToRxDataHandle,
edma_handle_t edmaTxDataToIntermediaryHandle,
edma_handle_t edmaIntermediaryToTxRegHandle 
)

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

Note that DSPI eDMA has separated (RX and TX as two sources) or shared (RX and TX are the same source) DMA request source. (1)For the separated DMA request source, enable and set the RX DMAMUX source for edmaRxRegToRxDataHandle and TX DMAMUX source for edmaIntermediaryToTxRegHandle. (2)For the shared DMA request source, enable and set the RX/RX DMAMUX source for the edmaRxRegToRxDataHandle.

Parameters
baseDSPI peripheral base address.
handleDSPI handle pointer to dspi_master_edma_handle_t.
callbackDSPI callback.
userDatacallback function parameter.
edmaRxRegToRxDataHandleedmaRxRegToRxDataHandle pointer to edma_handle_t.
edmaTxDataToIntermediaryHandleedmaTxDataToIntermediaryHandle pointer to edma_handle_t.
edmaIntermediaryToTxRegHandleedmaIntermediaryToTxRegHandle pointer to edma_handle_t.
status_t DSPI_MasterTransferEDMA ( SPI_Type *  base,
dspi_master_edma_handle_t *  handle,
dspi_transfer_t transfer 
)

This function transfer data using eDMA. This is non-blocking function, which returns right away. When all data have been transfer, the callback function is called.

Parameters
baseDSPI peripheral base address.
handlepointer to dspi_master_edma_handle_t structure which stores the transfer state.
transferpointer to dspi_transfer_t structure.
Returns
status of status_t.
void DSPI_MasterTransferAbortEDMA ( SPI_Type *  base,
dspi_master_edma_handle_t *  handle 
)

This function aborts a transfer which using eDMA.

Parameters
baseDSPI peripheral base address.
handlepointer to dspi_master_edma_handle_t structure which stores the transfer state.
status_t DSPI_MasterTransferGetCountEDMA ( SPI_Type *  base,
dspi_master_edma_handle_t *  handle,
size_t *  count 
)

This function get the master eDMA transfer count.

Parameters
baseDSPI peripheral base address.
handlepointer to dspi_master_edma_handle_t structure which stores the transfer state.
countNumber of bytes transferred so far by the non-blocking transaction.
Returns
status of status_t.
void DSPI_SlaveTransferCreateHandleEDMA ( SPI_Type *  base,
dspi_slave_edma_handle_t *  handle,
dspi_slave_edma_transfer_callback_t  callback,
void *  userData,
edma_handle_t edmaRxRegToRxDataHandle,
edma_handle_t edmaTxDataToTxRegHandle 
)

This function initializes the DSPI eDMA handle which can be used for other DSPI transactional APIs. Usually, for a specified DSPI instance, call this API once to get the initialized handle.

Note that DSPI eDMA has separated (RN and TX in 2 sources) or shared (RX and TX are the same source) DMA request source. (1)For the separated DMA request source, enable and set the RX DMAMUX source for edmaRxRegToRxDataHandle and TX DMAMUX source for edmaTxDataToTxRegHandle. (2)For the shared DMA request source, enable and set the RX/RX DMAMUX source for the edmaRxRegToRxDataHandle.

Parameters
baseDSPI peripheral base address.
handleDSPI handle pointer to dspi_slave_edma_handle_t.
callbackDSPI callback.
userDatacallback function parameter.
edmaRxRegToRxDataHandleedmaRxRegToRxDataHandle pointer to edma_handle_t.
edmaTxDataToTxRegHandleedmaTxDataToTxRegHandle pointer to edma_handle_t.
status_t DSPI_SlaveTransferEDMA ( SPI_Type *  base,
dspi_slave_edma_handle_t *  handle,
dspi_transfer_t transfer 
)

This function transfer data using eDMA. This is non-blocking function, which returns right away. When all data have been transfer, the callback function is called. Note that slave EDMA transfer cannot support the situation that transfer_size is 1 when the bitsPerFrame is greater than 8 .

Parameters
baseDSPI peripheral base address.
handlepointer to dspi_slave_edma_handle_t structure which stores the transfer state.
transferpointer to dspi_transfer_t structure.
Returns
status of status_t.
void DSPI_SlaveTransferAbortEDMA ( SPI_Type *  base,
dspi_slave_edma_handle_t *  handle 
)

This function aborts a transfer which using eDMA.

Parameters
baseDSPI peripheral base address.
handlepointer to dspi_slave_edma_handle_t structure which stores the transfer state.
status_t DSPI_SlaveTransferGetCountEDMA ( SPI_Type *  base,
dspi_slave_edma_handle_t *  handle,
size_t *  count 
)

This function gets the slave eDMA transfer count.

Parameters
baseDSPI peripheral base address.
handlepointer to dspi_slave_edma_handle_t structure which stores the transfer state.
countNumber of bytes transferred so far by the non-blocking transaction.
Returns
status of status_t.