fsl_sai_edma.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #include "fsl_sai_edma.h"
10 
11 /* Component ID definition, used by tools. */
12 #ifndef FSL_COMPONENT_ID
13 #define FSL_COMPONENT_ID "platform.drivers.sai_edma"
14 #endif
15 
16 /*******************************************************************************
17  * Definitions
18  ******************************************************************************/
19 /* Used for 32byte aligned */
20 #define STCD_ADDR(address) (edma_tcd_t *)(((uint32_t)(address) + 32UL) & ~0x1FU)
21 
22 static I2S_Type *const s_saiBases[] = I2S_BASE_PTRS;
23 
24 /*<! Structure definition for uart_edma_private_handle_t. The structure is private. */
26 {
30 
32 enum
33 {
34  kSAI_Busy = 0x0U,
36 };
37 
38 /*<! Private handle only used for internally. */
40 
41 /*******************************************************************************
42  * Prototypes
43  ******************************************************************************/
49 static uint32_t SAI_GetInstance(I2S_Type *base);
50 
59 static void SAI_TxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds);
60 
69 static void SAI_RxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds);
70 
71 /*******************************************************************************
72  * Code
73  ******************************************************************************/
74 static uint32_t SAI_GetInstance(I2S_Type *base)
75 {
76  uint32_t instance;
77 
78  /* Find the instance index from base address mappings. */
79  for (instance = 0; instance < ARRAY_SIZE(s_saiBases); instance++)
80  {
81  if (s_saiBases[instance] == base)
82  {
83  break;
84  }
85  }
86 
87  assert(instance < ARRAY_SIZE(s_saiBases));
88 
89  return instance;
90 }
91 
92 static void SAI_TxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds)
93 {
94  sai_edma_private_handle_t *privHandle = (sai_edma_private_handle_t *)userData;
95  sai_edma_handle_t *saiHandle = privHandle->handle;
96 
97  /* If finished a block, call the callback function */
98  (void)memset(&saiHandle->saiQueue[saiHandle->queueDriver], 0, sizeof(sai_transfer_t));
99  saiHandle->queueDriver = (saiHandle->queueDriver + 1U) % SAI_XFER_QUEUE_SIZE;
100  if (saiHandle->callback != NULL)
101  {
102  (saiHandle->callback)(privHandle->base, saiHandle, kStatus_SAI_TxIdle, saiHandle->userData);
103  }
104 
105  /* If all data finished, just stop the transfer */
106  if (saiHandle->saiQueue[saiHandle->queueDriver].data == NULL)
107  {
108  /* Disable DMA enable bit */
109  SAI_TxEnableDMA(privHandle->base, kSAI_FIFORequestDMAEnable, false);
110  EDMA_AbortTransfer(handle);
111  }
112 }
113 
114 static void SAI_RxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds)
115 {
116  sai_edma_private_handle_t *privHandle = (sai_edma_private_handle_t *)userData;
117  sai_edma_handle_t *saiHandle = privHandle->handle;
118 
119  /* If finished a block, call the callback function */
120  (void)memset(&saiHandle->saiQueue[saiHandle->queueDriver], 0, sizeof(sai_transfer_t));
121  saiHandle->queueDriver = (saiHandle->queueDriver + 1U) % SAI_XFER_QUEUE_SIZE;
122  if (saiHandle->callback != NULL)
123  {
124  (saiHandle->callback)(privHandle->base, saiHandle, kStatus_SAI_RxIdle, saiHandle->userData);
125  }
126 
127  /* If all data finished, just stop the transfer */
128  if (saiHandle->saiQueue[saiHandle->queueDriver].data == NULL)
129  {
130  /* Disable DMA enable bit */
131  SAI_RxEnableDMA(privHandle->base, kSAI_FIFORequestDMAEnable, false);
132  EDMA_AbortTransfer(handle);
133  }
134 }
135 
150  I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *txDmaHandle)
151 {
152  assert((handle != NULL) && (txDmaHandle != NULL));
153 
154  uint32_t instance = SAI_GetInstance(base);
155 
156  /* Zero the handle */
157  (void)memset(handle, 0, sizeof(*handle));
158 
159  /* Set sai base to handle */
160  handle->dmaHandle = txDmaHandle;
161  handle->callback = callback;
162  handle->userData = userData;
163 
164  /* Set SAI state to idle */
165  handle->state = (uint32_t)kSAI_Idle;
166 
167  s_edmaPrivateHandle[instance][0].base = base;
168  s_edmaPrivateHandle[instance][0].handle = handle;
169 
170  /* Need to use scatter gather */
172 
173  /* Install callback for Tx dma channel */
174  EDMA_SetCallback(txDmaHandle, SAI_TxEDMACallback, &s_edmaPrivateHandle[instance][0]);
175 }
176 
191  I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *rxDmaHandle)
192 {
193  assert((handle != NULL) && (rxDmaHandle != NULL));
194 
195  uint32_t instance = SAI_GetInstance(base);
196 
197  /* Zero the handle */
198  (void)memset(handle, 0, sizeof(*handle));
199 
200  /* Set sai base to handle */
201  handle->dmaHandle = rxDmaHandle;
202  handle->callback = callback;
203  handle->userData = userData;
204 
205  /* Set SAI state to idle */
206  handle->state = (uint32_t)kSAI_Idle;
207 
208  s_edmaPrivateHandle[instance][1].base = base;
209  s_edmaPrivateHandle[instance][1].handle = handle;
210 
211  /* Need to use scatter gather */
212  EDMA_InstallTCDMemory(rxDmaHandle, STCD_ADDR(handle->tcd), SAI_XFER_QUEUE_SIZE);
213 
214  /* Install callback for Tx dma channel */
215  EDMA_SetCallback(rxDmaHandle, SAI_RxEDMACallback, &s_edmaPrivateHandle[instance][1]);
216 }
217 
234  sai_edma_handle_t *handle,
235  sai_transfer_format_t *format,
236  uint32_t mclkSourceClockHz,
237  uint32_t bclkSourceClockHz)
238 {
239  assert((handle != NULL) && (format != NULL));
240 
241  /* Configure the audio format to SAI registers */
242  SAI_TxSetFormat(base, format, mclkSourceClockHz, bclkSourceClockHz);
243 
244  /* Get the transfer size from format, this should be used in EDMA configuration */
245  if (format->bitWidth == 24U)
246  {
247  handle->bytesPerFrame = 4U;
248  }
249  else
250  {
251  handle->bytesPerFrame = (uint8_t)(format->bitWidth / 8U);
252  }
253 
254  /* Update the data channel SAI used */
255  handle->channel = format->channel;
256 
257  /* Clear the channel enable bits until do a send/receive */
258  base->TCR3 &= ~I2S_TCR3_TCE_MASK;
259 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
260  handle->count = (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNT - format->watermark);
261 #else
262  handle->count = 1U;
263 #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
264 }
265 
275 {
276  assert((handle != NULL) && (saiConfig != NULL));
277 
278  /* Configure the audio format to SAI registers */
279  SAI_TxSetConfig(base, saiConfig);
280 
281  /* Get the transfer size from format, this should be used in EDMA configuration */
282  if (saiConfig->serialData.dataWordLength == 24U)
283  {
284  handle->bytesPerFrame = 4U;
285  }
286  else
287  {
288  handle->bytesPerFrame = saiConfig->serialData.dataWordLength / 8U;
289  }
290  /* Update the data channel SAI used */
291  handle->channel = saiConfig->startChannel;
292 
293  /* Clear the channel enable bits until do a send/receive */
294  base->TCR3 &= ~I2S_TCR3_TCE_MASK;
295 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
296  handle->count = (uint8_t)((uint32_t)FSL_FEATURE_SAI_FIFO_COUNT - saiConfig->fifo.fifoWatermark);
297 #else
298  handle->count = 1U;
299 #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
300 }
301 
318  sai_edma_handle_t *handle,
319  sai_transfer_format_t *format,
320  uint32_t mclkSourceClockHz,
321  uint32_t bclkSourceClockHz)
322 {
323  assert((handle != NULL) && (format != NULL));
324 
325  /* Configure the audio format to SAI registers */
326  SAI_RxSetFormat(base, format, mclkSourceClockHz, bclkSourceClockHz);
327 
328  /* Get the transfer size from format, this should be used in EDMA configuration */
329  if (format->bitWidth == 24U)
330  {
331  handle->bytesPerFrame = 4U;
332  }
333  else
334  {
335  handle->bytesPerFrame = (uint8_t)(format->bitWidth / 8U);
336  }
337 
338  /* Update the data channel SAI used */
339  handle->channel = format->channel;
340 
341  /* Clear the channel enable bits until do a send/receive */
342  base->RCR3 &= ~I2S_RCR3_RCE_MASK;
343 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
344  handle->count = format->watermark;
345 #else
346  handle->count = 1U;
347 #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
348 }
349 
359 {
360  assert((handle != NULL) && (saiConfig != NULL));
361 
362  /* Configure the audio format to SAI registers */
363  SAI_RxSetConfig(base, saiConfig);
364 
365  /* Get the transfer size from format, this should be used in EDMA configuration */
366  if (saiConfig->serialData.dataWordLength == 24U)
367  {
368  handle->bytesPerFrame = 4U;
369  }
370  else
371  {
372  handle->bytesPerFrame = saiConfig->serialData.dataWordLength / 8U;
373  }
374 
375  /* Update the data channel SAI used */
376  handle->channel = saiConfig->startChannel;
377 
378  /* Clear the channel enable bits until do a send/receive */
379  base->RCR3 &= ~I2S_RCR3_RCE_MASK;
380 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
381  handle->count = saiConfig->fifo.fifoWatermark;
382 #else
383  handle->count = 1U;
384 #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
385 }
386 
401 {
402  assert((handle != NULL) && (xfer != NULL));
403 
405  uint32_t destAddr = SAI_TxGetDataRegisterAddress(base, handle->channel);
406 
407  /* Check if input parameter invalid */
408  if ((xfer->data == NULL) || (xfer->dataSize == 0U))
409  {
411  }
412 
413  if (handle->saiQueue[handle->queueUser].data != NULL)
414  {
415  return kStatus_SAI_QueueFull;
416  }
417 
418  /* Change the state of handle */
419  handle->state = (uint32_t)kSAI_Busy;
420 
421  /* Update the queue state */
422  handle->transferSize[handle->queueUser] = xfer->dataSize;
423  handle->saiQueue[handle->queueUser].data = xfer->data;
424  handle->saiQueue[handle->queueUser].dataSize = xfer->dataSize;
425  handle->queueUser = (handle->queueUser + 1U) % SAI_XFER_QUEUE_SIZE;
426 
427  /* Prepare edma configure */
428  EDMA_PrepareTransfer(&config, xfer->data, handle->bytesPerFrame, (uint32_t *)destAddr, handle->bytesPerFrame,
429  (uint32_t)handle->count * handle->bytesPerFrame, xfer->dataSize, kEDMA_MemoryToPeripheral);
430 
431  /* Store the initially configured eDMA minor byte transfer count into the SAI handle */
432  handle->nbytes = handle->count * handle->bytesPerFrame;
433 
435  {
436  return kStatus_SAI_QueueFull;
437  }
438 
439  /* Start DMA transfer */
440  EDMA_StartTransfer(handle->dmaHandle);
441 
442  /* Enable DMA enable bit */
443  SAI_TxEnableDMA(base, kSAI_FIFORequestDMAEnable, true);
444 
445  /* Enable SAI Tx clock */
446  SAI_TxEnable(base, true);
447 
448  /* Enable the channel FIFO */
449  base->TCR3 |= I2S_TCR3_TCE(1UL << handle->channel);
450 
451  return kStatus_Success;
452 }
453 
468 {
469  assert((handle != NULL) && (xfer != NULL));
470 
472  uint32_t srcAddr = SAI_RxGetDataRegisterAddress(base, handle->channel);
473 
474  /* Check if input parameter invalid */
475  if ((xfer->data == NULL) || (xfer->dataSize == 0U))
476  {
478  }
479 
480  if (handle->saiQueue[handle->queueUser].data != NULL)
481  {
482  return kStatus_SAI_QueueFull;
483  }
484 
485  /* Change the state of handle */
486  handle->state = (uint32_t)kSAI_Busy;
487 
488  /* Update queue state */
489  handle->transferSize[handle->queueUser] = xfer->dataSize;
490  handle->saiQueue[handle->queueUser].data = xfer->data;
491  handle->saiQueue[handle->queueUser].dataSize = xfer->dataSize;
492  handle->queueUser = (handle->queueUser + 1U) % SAI_XFER_QUEUE_SIZE;
493 
494  /* Prepare edma configure */
495  EDMA_PrepareTransfer(&config, (uint32_t *)srcAddr, handle->bytesPerFrame, xfer->data, handle->bytesPerFrame,
496  (uint32_t)handle->count * handle->bytesPerFrame, xfer->dataSize, kEDMA_PeripheralToMemory);
497 
498  /* Store the initially configured eDMA minor byte transfer count into the SAI handle */
499  handle->nbytes = handle->count * handle->bytesPerFrame;
500 
502  {
503  return kStatus_SAI_QueueFull;
504  }
505 
506  /* Start DMA transfer */
507  EDMA_StartTransfer(handle->dmaHandle);
508 
509  /* Enable DMA enable bit */
510  SAI_RxEnableDMA(base, kSAI_FIFORequestDMAEnable, true);
511 
512  /* Enable the channel FIFO */
513  base->RCR3 |= I2S_RCR3_RCE(1UL << handle->channel);
514 
515  /* Enable SAI Rx clock */
516  SAI_RxEnable(base, true);
517 
518  return kStatus_Success;
519 }
520 
531 {
532  assert(handle != NULL);
533 
534  /* Disable dma */
535  EDMA_AbortTransfer(handle->dmaHandle);
536 
537  /* Disable the channel FIFO */
538  base->TCR3 &= ~I2S_TCR3_TCE_MASK;
539 
540  /* Disable DMA enable bit */
541  SAI_TxEnableDMA(base, kSAI_FIFORequestDMAEnable, false);
542 
543  /* Disable Tx */
544  SAI_TxEnable(base, false);
545 
546  /* If Tx is disabled, reset the FIFO pointer and clear error flags */
547  if ((base->TCSR & I2S_TCSR_TE_MASK) == 0UL)
548  {
550  base->TCSR &= ~I2S_TCSR_SR_MASK;
551  }
552 
553  /* Handle the queue index */
554  (void)memset(&handle->saiQueue[handle->queueDriver], 0, sizeof(sai_transfer_t));
555  handle->queueDriver = (handle->queueDriver + 1U) % SAI_XFER_QUEUE_SIZE;
556 
557  /* Set the handle state */
558  handle->state = (uint32_t)kSAI_Idle;
559 }
560 
571 {
572  assert(handle != NULL);
573 
574  /* Disable dma */
575  EDMA_AbortTransfer(handle->dmaHandle);
576 
577  /* Disable the channel FIFO */
578  base->RCR3 &= ~I2S_RCR3_RCE_MASK;
579 
580  /* Disable DMA enable bit */
581  SAI_RxEnableDMA(base, kSAI_FIFORequestDMAEnable, false);
582 
583  /* Disable Rx */
584  SAI_RxEnable(base, false);
585 
586  /* If Rx is disabled, reset the FIFO pointer and clear error flags */
587  if ((base->RCSR & I2S_RCSR_RE_MASK) == 0UL)
588  {
590  base->RCSR &= ~I2S_RCSR_SR_MASK;
591  }
592 
593  /* Handle the queue index */
594  (void)memset(&handle->saiQueue[handle->queueDriver], 0, sizeof(sai_transfer_t));
595  handle->queueDriver = (handle->queueDriver + 1U) % SAI_XFER_QUEUE_SIZE;
596 
597  /* Set the handle state */
598  handle->state = (uint32_t)kSAI_Idle;
599 }
600 
611 {
612  assert(handle != NULL);
613 
614  /* Abort the current transfer */
615  SAI_TransferAbortSendEDMA(base, handle);
616 
617  /* Clear all the internal information */
618  (void)memset(handle->tcd, 0, sizeof(handle->tcd));
619  (void)memset(handle->saiQueue, 0, sizeof(handle->saiQueue));
620  (void)memset(handle->transferSize, 0, sizeof(handle->transferSize));
621 
622  handle->queueUser = 0U;
623  handle->queueDriver = 0U;
624 }
625 
636 {
637  assert(handle != NULL);
638 
639  /* Abort the current transfer */
640  SAI_TransferAbortReceiveEDMA(base, handle);
641 
642  /* Clear all the internal information */
643  (void)memset(handle->tcd, 0, sizeof(handle->tcd));
644  (void)memset(handle->saiQueue, 0, sizeof(handle->saiQueue));
645  (void)memset(handle->transferSize, 0, sizeof(handle->transferSize));
646 
647  handle->queueUser = 0U;
648  handle->queueDriver = 0U;
649 }
650 
661 {
662  assert(handle != NULL);
663 
664  status_t status = kStatus_Success;
665 
666  if (handle->state != (uint32_t)kSAI_Busy)
667  {
669  }
670  else
671  {
672  *count = (handle->transferSize[handle->queueDriver] -
673  (uint32_t)handle->nbytes *
675  }
676 
677  return status;
678 }
679 
690 {
691  assert(handle != NULL);
692 
693  status_t status = kStatus_Success;
694 
695  if (handle->state != (uint32_t)kSAI_Busy)
696  {
698  }
699  else
700  {
701  *count = (handle->transferSize[handle->queueDriver] -
702  (uint32_t)handle->nbytes *
704  }
705 
706  return status;
707 }
_sai_transfer::data
uint8_t * data
Definition: fsl_sai.h:416
_sai_transfer_format::channel
uint8_t channel
Definition: fsl_sai.h:289
sai_edma_private_handle
Definition: fsl_sai_edma.c:25
fsl_sai_edma.h
I2S_RCSR_SR_MASK
#define I2S_RCSR_SR_MASK
Definition: MIMXRT1052.h:20389
kStatus_InvalidArgument
@ kStatus_InvalidArgument
Definition: fsl_common.h:183
_edma_handle
eDMA transfer handle structure
Definition: fsl_edma.h:243
sai_edma_handle::userData
void * userData
Definition: fsl_sai_edma.h:43
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
I2S_Type::RCSR
__IO uint32_t RCSR
Definition: MIMXRT1052.h:19882
SAI_GetInstance
static uint32_t SAI_GetInstance(I2S_Type *base)
Get the instance number for SAI.
Definition: fsl_sai_edma.c:74
I2S_Type
Definition: MIMXRT1052.h:19867
I2S_Type::RCR3
__IO uint32_t RCR3
Definition: MIMXRT1052.h:19885
sai_edma_handle::nbytes
uint8_t nbytes
Definition: fsl_sai_edma.h:37
EDMA_InstallTCDMemory
void EDMA_InstallTCDMemory(edma_handle_t *handle, edma_tcd_t *tcdPool, uint32_t tcdSize)
Installs the TCDs memory pool into the eDMA handle.
Definition: fsl_edma.c:843
EDMA_SubmitTransfer
status_t EDMA_SubmitTransfer(edma_handle_t *handle, const edma_transfer_config_t *config)
Submits the eDMA transfer request.
Definition: fsl_edma.c:1040
kSAI_Idle
@ kSAI_Idle
Definition: fsl_sai_edma.c:35
_sai_transfer::dataSize
size_t dataSize
Definition: fsl_sai.h:417
kStatus_NoTransferInProgress
@ kStatus_NoTransferInProgress
Definition: fsl_common.h:185
SAI_TransferRxSetConfigEDMA
void SAI_TransferRxSetConfigEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transceiver_t *saiConfig)
Configures the SAI Rx.
Definition: fsl_sai_edma.c:358
sai_edma_handle
SAI DMA transfer handle, users should not touch the content of the handle.
Definition: fsl_sai_edma.h:34
sai_edma_handle::saiQueue
sai_transfer_t saiQueue[SAI_XFER_QUEUE_SIZE]
Definition: fsl_sai_edma.h:45
I2S_RCSR_RE_MASK
#define I2S_RCSR_RE_MASK
Definition: MIMXRT1052.h:20424
I2S_RCR3_RCE_MASK
#define I2S_RCR3_RCE_MASK
Definition: MIMXRT1052.h:20504
SAI_RxEnable
void SAI_RxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Rx.
Definition: fsl_sai.c:835
SAI_RxEnableDMA
static void SAI_RxEnableDMA(I2S_Type *base, uint32_t mask, bool enable)
Enables/disables the SAI Rx DMA requests.
Definition: fsl_sai.h:1186
kStatus_SAI_QueueFull
@ kStatus_SAI_QueueFull
Definition: fsl_sai.h:35
I2S_TCR3_TCE
#define I2S_TCR3_TCE(x)
Definition: MIMXRT1052.h:20148
sai_edma_handle::channel
uint8_t channel
Definition: fsl_sai_edma.h:39
SAI_TransferRxSetFormatEDMA
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.
Definition: fsl_sai_edma.c:317
EDMA_PrepareTransfer
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.
Definition: fsl_edma.c:986
SAI_TxGetDataRegisterAddress
static uint32_t SAI_TxGetDataRegisterAddress(I2S_Type *base, uint32_t channel)
Gets the SAI Tx data register address.
Definition: fsl_sai.h:1207
SAI_TransferTerminateReceiveEDMA
void SAI_TransferTerminateReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Terminate all SAI receive.
Definition: fsl_sai_edma.c:635
EDMA_SetCallback
void EDMA_SetCallback(edma_handle_t *handle, edma_callback callback, void *userData)
Installs a callback function for the eDMA transfer.
Definition: fsl_edma.c:867
SAI_RxSetFormat
void SAI_RxSetFormat(I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Rx audio format.
Definition: fsl_sai.c:1972
sai_edma_private_handle::base
I2S_Type * base
Definition: fsl_sai_edma.c:27
SAI_RxEDMACallback
static void SAI_RxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds)
SAI EDMA callback for receive.
Definition: fsl_sai_edma.c:114
kEDMA_PeripheralToMemory
@ kEDMA_PeripheralToMemory
Definition: fsl_edma.h:136
SAI_TransferSendEDMA
status_t SAI_TransferSendEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_t *xfer)
Performs a non-blocking SAI transfer using DMA.
Definition: fsl_sai_edma.c:400
SAI_TxEDMACallback
static void SAI_TxEDMACallback(edma_handle_t *handle, void *userData, bool done, uint32_t tcds)
SAI EDMA callback for send.
Definition: fsl_sai_edma.c:92
_edma_transfer_config
eDMA transfer configuration
Definition: fsl_edma.h:168
SAI_XFER_QUEUE_SIZE
#define SAI_XFER_QUEUE_SIZE
SAI transfer queue size, user can refine it according to use case.
Definition: fsl_sai.h:204
SAI_TransferRxCreateHandleEDMA
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.
Definition: fsl_sai_edma.c:190
sai_edma_handle::callback
sai_edma_callback_t callback
Definition: fsl_sai_edma.h:42
s_edmaPrivateHandle
static sai_edma_private_handle_t s_edmaPrivateHandle[ARRAY_SIZE(s_saiBases)][2]
Definition: fsl_sai_edma.c:39
SAI_TransferGetSendCountEDMA
status_t SAI_TransferGetSendCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count)
Gets byte count sent by SAI.
Definition: fsl_sai_edma.c:660
ARRAY_SIZE
#define ARRAY_SIZE(x)
Computes the number of elements in an array.
Definition: fsl_common.h:211
SAI_TransferTxSetFormatEDMA
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.
Definition: fsl_sai_edma.c:233
sai_edma_private_handle::handle
sai_edma_handle_t * handle
Definition: fsl_sai_edma.c:28
count
size_t count
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/tests/test_common/ma_test_common.c:31
I2S_TCSR_TE_MASK
#define I2S_TCSR_TE_MASK
Definition: MIMXRT1052.h:20064
_edma_handle::base
DMA_Type * base
Definition: fsl_edma.h:247
_sai_transceiver
sai transceiver configurations
Definition: fsl_sai.h:394
EDMA_AbortTransfer
void EDMA_AbortTransfer(edma_handle_t *handle)
eDMA aborts transfer.
Definition: fsl_edma.c:1264
sai_edma_private_handle_t
struct sai_edma_private_handle sai_edma_private_handle_t
sai_edma_handle::transferSize
size_t transferSize[SAI_XFER_QUEUE_SIZE]
Definition: fsl_sai_edma.h:46
FSL_FEATURE_SAI_FIFO_COUNT
#define FSL_FEATURE_SAI_FIFO_COUNT
Definition: MIMXRT1052_features.h:537
SAI_TransferGetReceiveCountEDMA
status_t SAI_TransferGetReceiveCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count)
Gets byte count received by SAI.
Definition: fsl_sai_edma.c:689
STCD_ADDR
#define STCD_ADDR(address)
Definition: fsl_sai_edma.c:20
I2S_RCSR_FR_MASK
#define I2S_RCSR_FR_MASK
Definition: MIMXRT1052.h:20396
sai_edma_handle::queueDriver
volatile uint8_t queueDriver
Definition: fsl_sai_edma.h:48
kSAI_Busy
@ kSAI_Busy
Definition: fsl_sai_edma.c:34
sai_edma_handle::state
uint32_t state
Definition: fsl_sai_edma.h:41
SAI_TransferAbortReceiveEDMA
void SAI_TransferAbortReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Aborts a SAI receive using eDMA.
Definition: fsl_sai_edma.c:570
I2S_Type::TCSR
__IO uint32_t TCSR
Definition: MIMXRT1052.h:19870
I2S_RCR3_RCE
#define I2S_RCR3_RCE(x)
Definition: MIMXRT1052.h:20508
SAI_RxSetConfig
void SAI_RxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI receiver configurations.
Definition: fsl_sai.c:1562
sai_edma_handle::bytesPerFrame
uint8_t bytesPerFrame
Definition: fsl_sai_edma.h:38
_sai_transfer_format::bitWidth
uint32_t bitWidth
Definition: fsl_sai.h:273
kEDMA_MemoryToPeripheral
@ kEDMA_MemoryToPeripheral
Definition: fsl_edma.h:137
_sai_serial_data::dataWordLength
uint8_t dataWordLength
Definition: fsl_sai.h:386
_sai_transceiver::serialData
sai_serial_data_t serialData
Definition: fsl_sai.h:396
SAI_TxEnableDMA
static void SAI_TxEnableDMA(I2S_Type *base, uint32_t mask, bool enable)
Enables/disables the SAI Tx DMA requests.
Definition: fsl_sai.h:1165
_sai_transfer_format
sai transfer format
Definition: fsl_sai.h:270
SAI_RxGetDataRegisterAddress
static uint32_t SAI_RxGetDataRegisterAddress(I2S_Type *base, uint32_t channel)
Gets the SAI Rx data register address.
Definition: fsl_sai.h:1221
sai_edma_handle::count
uint8_t count
Definition: fsl_sai_edma.h:40
sai_edma_handle::queueUser
volatile uint8_t queueUser
Definition: fsl_sai_edma.h:47
sai_edma_callback_t
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.
Definition: fsl_sai_edma.h:31
_sai_transfer
SAI transfer structure.
Definition: fsl_sai.h:414
I2S_BASE_PTRS
#define I2S_BASE_PTRS
Definition: MIMXRT1052.h:20678
SAI_TransferTxSetConfigEDMA
void SAI_TransferTxSetConfigEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transceiver_t *saiConfig)
Configures the SAI Tx.
Definition: fsl_sai_edma.c:274
kStatus_SAI_RxIdle
@ kStatus_SAI_RxIdle
Definition: fsl_sai.h:37
SAI_TransferTxCreateHandleEDMA
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.
Definition: fsl_sai_edma.c:149
SAI_TxSetConfig
void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI transmitter configurations.
Definition: fsl_sai.c:1433
I2S_TCSR_SR_MASK
#define I2S_TCSR_SR_MASK
Definition: MIMXRT1052.h:20029
_edma_tcd
eDMA TCD.
Definition: fsl_edma.h:204
I2S_TCSR_FR_MASK
#define I2S_TCSR_FR_MASK
Definition: MIMXRT1052.h:20036
config
static sai_transceiver_t config
Definition: imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:75
_sai_transceiver::startChannel
uint8_t startChannel
Definition: fsl_sai.h:406
_edma_handle::channel
uint8_t channel
Definition: fsl_edma.h:249
SAI_TransferReceiveEDMA
status_t SAI_TransferReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_t *xfer)
Performs a non-blocking SAI receive using eDMA.
Definition: fsl_sai_edma.c:467
I2S_TCR3_TCE_MASK
#define I2S_TCR3_TCE_MASK
Definition: MIMXRT1052.h:20144
kStatus_SAI_TxIdle
@ kStatus_SAI_TxIdle
Definition: fsl_sai.h:36
status_t
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:189
EDMA_StartTransfer
void EDMA_StartTransfer(edma_handle_t *handle)
eDMA starts transfer.
Definition: fsl_edma.c:1201
SAI_TxSetFormat
void SAI_TxSetFormat(I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Tx audio format.
Definition: fsl_sai.c:1829
sai_edma_handle::tcd
uint8_t tcd[(SAI_XFER_QUEUE_SIZE+1U) *sizeof(edma_tcd_t)]
Definition: fsl_sai_edma.h:44
s_saiBases
static I2S_Type *const s_saiBases[]
Definition: fsl_sai_edma.c:22
kStatus_Success
@ kStatus_Success
Definition: fsl_common.h:179
EDMA_GetRemainingMajorLoopCount
uint32_t EDMA_GetRemainingMajorLoopCount(DMA_Type *base, uint32_t channel)
Gets the remaining major loop count from the eDMA current channel TCD.
Definition: fsl_edma.c:679
sai_edma_handle::dmaHandle
edma_handle_t * dmaHandle
Definition: fsl_sai_edma.h:36
SAI_TxEnable
void SAI_TxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Tx.
Definition: fsl_sai.c:805
SAI_TransferAbortSendEDMA
void SAI_TransferAbortSendEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Aborts a SAI transfer using eDMA.
Definition: fsl_sai_edma.c:530
SAI_TransferTerminateSendEDMA
void SAI_TransferTerminateSendEDMA(I2S_Type *base, sai_edma_handle_t *handle)
Terminate all SAI send.
Definition: fsl_sai_edma.c:610
I2S_Type::TCR3
__IO uint32_t TCR3
Definition: MIMXRT1052.h:19873


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:56