Go to the documentation of this file.
12 #ifndef FSL_COMPONENT_ID
13 #define FSL_COMPONENT_ID "platform.drivers.sai_edma"
20 #define STCD_ADDR(address) (edma_tcd_t *)(((uint32_t)(address) + 32UL) & ~0x1FU)
152 assert((handle !=
NULL) && (txDmaHandle !=
NULL));
157 (void)memset(handle, 0,
sizeof(*handle));
193 assert((handle !=
NULL) && (rxDmaHandle !=
NULL));
198 (void)memset(handle, 0,
sizeof(*handle));
236 uint32_t mclkSourceClockHz,
237 uint32_t bclkSourceClockHz)
239 assert((handle !=
NULL) && (format !=
NULL));
259 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
276 assert((handle !=
NULL) && (saiConfig !=
NULL));
295 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
320 uint32_t mclkSourceClockHz,
321 uint32_t bclkSourceClockHz)
323 assert((handle !=
NULL) && (format !=
NULL));
343 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
344 handle->
count = format->watermark;
360 assert((handle !=
NULL) && (saiConfig !=
NULL));
380 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
381 handle->
count = saiConfig->fifo.fifoWatermark;
402 assert((handle !=
NULL) && (xfer !=
NULL));
469 assert((handle !=
NULL) && (xfer !=
NULL));
532 assert(handle !=
NULL);
572 assert(handle !=
NULL);
612 assert(handle !=
NULL);
618 (void)memset(handle->
tcd, 0,
sizeof(handle->
tcd));
637 assert(handle !=
NULL);
643 (void)memset(handle->
tcd, 0,
sizeof(handle->
tcd));
662 assert(handle !=
NULL);
673 (uint32_t)handle->
nbytes *
691 assert(handle !=
NULL);
702 (uint32_t)handle->
nbytes *
@ kStatus_InvalidArgument
eDMA transfer handle structure
static uint32_t SAI_GetInstance(I2S_Type *base)
Get the instance number for SAI.
void EDMA_InstallTCDMemory(edma_handle_t *handle, edma_tcd_t *tcdPool, uint32_t tcdSize)
Installs the TCDs memory pool into the eDMA handle.
status_t EDMA_SubmitTransfer(edma_handle_t *handle, const edma_transfer_config_t *config)
Submits the eDMA transfer request.
@ kStatus_NoTransferInProgress
void SAI_TransferRxSetConfigEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transceiver_t *saiConfig)
Configures the SAI Rx.
SAI DMA transfer handle, users should not touch the content of the handle.
sai_transfer_t saiQueue[SAI_XFER_QUEUE_SIZE]
#define I2S_RCR3_RCE_MASK
void SAI_RxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Rx.
static void SAI_RxEnableDMA(I2S_Type *base, uint32_t mask, bool enable)
Enables/disables the SAI Rx DMA requests.
void SAI_TransferRxSetFormatEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Rx audio format.
void EDMA_PrepareTransfer(edma_transfer_config_t *config, void *srcAddr, uint32_t srcWidth, void *destAddr, uint32_t destWidth, uint32_t bytesEachRequest, uint32_t transferBytes, edma_transfer_type_t type)
Prepares the eDMA transfer structure.
static uint32_t SAI_TxGetDataRegisterAddress(I2S_Type *base, uint32_t channel)
Gets the SAI Tx data register address.
void SAI_TransferTerminateReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Terminate all SAI receive.
void EDMA_SetCallback(edma_handle_t *handle, edma_callback callback, void *userData)
Installs a callback function for the eDMA transfer.
void SAI_RxSetFormat(I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Rx audio format.
static void SAI_RxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds)
SAI EDMA callback for receive.
@ kEDMA_PeripheralToMemory
status_t SAI_TransferSendEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_t *xfer)
Performs a non-blocking SAI transfer using DMA.
static void SAI_TxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds)
SAI EDMA callback for send.
eDMA transfer configuration
#define SAI_XFER_QUEUE_SIZE
SAI transfer queue size, user can refine it according to use case.
void SAI_TransferRxCreateHandleEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *rxDmaHandle)
Initializes the SAI Rx eDMA handle.
sai_edma_callback_t callback
static sai_edma_private_handle_t s_edmaPrivateHandle[ARRAY_SIZE(s_saiBases)][2]
status_t SAI_TransferGetSendCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count)
Gets byte count sent by SAI.
#define ARRAY_SIZE(x)
Computes the number of elements in an array.
void SAI_TransferTxSetFormatEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Tx audio format.
sai_edma_handle_t * handle
sai transceiver configurations
void EDMA_AbortTransfer(edma_handle_t *handle)
eDMA aborts transfer.
struct sai_edma_private_handle sai_edma_private_handle_t
size_t transferSize[SAI_XFER_QUEUE_SIZE]
#define FSL_FEATURE_SAI_FIFO_COUNT
status_t SAI_TransferGetReceiveCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count)
Gets byte count received by SAI.
#define STCD_ADDR(address)
volatile uint8_t queueDriver
void SAI_TransferAbortReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Aborts a SAI receive using eDMA.
void SAI_RxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI receiver configurations.
@ kEDMA_MemoryToPeripheral
sai_serial_data_t serialData
static void SAI_TxEnableDMA(I2S_Type *base, uint32_t mask, bool enable)
Enables/disables the SAI Tx DMA requests.
static uint32_t SAI_RxGetDataRegisterAddress(I2S_Type *base, uint32_t channel)
Gets the SAI Rx data register address.
volatile uint8_t queueUser
void(* sai_edma_callback_t)(I2S_Type *base, sai_edma_handle_t *handle, status_t status, void *userData)
SAI eDMA transfer callback function for finish and error.
void SAI_TransferTxSetConfigEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transceiver_t *saiConfig)
Configures the SAI Tx.
void SAI_TransferTxCreateHandleEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *txDmaHandle)
Initializes the SAI eDMA handle.
void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI transmitter configurations.
static sai_transceiver_t config
status_t SAI_TransferReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_t *xfer)
Performs a non-blocking SAI receive using eDMA.
#define I2S_TCR3_TCE_MASK
int32_t status_t
Type used for all status and error return values.
void EDMA_StartTransfer(edma_handle_t *handle)
eDMA starts transfer.
void SAI_TxSetFormat(I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Tx audio format.
uint8_t tcd[(SAI_XFER_QUEUE_SIZE+1U) *sizeof(edma_tcd_t)]
static I2S_Type *const s_saiBases[]
uint32_t EDMA_GetRemainingMajorLoopCount(DMA_Type *base, uint32_t channel)
Gets the remaining major loop count from the eDMA current channel TCD.
edma_handle_t * dmaHandle
void SAI_TxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Tx.
void SAI_TransferAbortSendEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Aborts a SAI transfer using eDMA.
void SAI_TransferTerminateSendEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Terminate all SAI send.