RTEMS 6.1-rc5
Loading...
Searching...
No Matches
fsl_sai.h
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2022 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_SAI_H_
10#define _FSL_SAI_H_
11
12#include "fsl_common.h"
13
19/*******************************************************************************
20 * Definitions
21 ******************************************************************************/
22
25#define FSL_SAI_DRIVER_VERSION (MAKE_VERSION(2, 3, 8))
27
29enum
30{
38};
39
41enum
42{
51};
52
54typedef enum _sai_protocol
55{
62
65{
66 kSAI_Master = 0x0U,
67 kSAI_Slave = 0x1U,
71
73typedef enum _sai_mono_stereo
74{
75 kSAI_Stereo = 0x0U,
79
81typedef enum _sai_data_order
82{
83 kSAI_DataLSB = 0x0U,
86
89{
95
97typedef enum _sai_sync_mode
98{
101#if defined(FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI) && (FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI)
102 kSAI_ModeSyncWithOtherTx,
103 kSAI_ModeSyncWithOtherRx
104#endif /* FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI */
106
107#if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
110{
116#endif
117
120{
122 /* General device bit source definition */
126 /* Kinetis device bit clock source definition */
131
133enum
134{
136 I2S_TCSR_WSIE_MASK,
137 kSAI_SyncErrorInterruptEnable = I2S_TCSR_SEIE_MASK,
138 kSAI_FIFOWarningInterruptEnable = I2S_TCSR_FWIE_MASK,
139 kSAI_FIFOErrorInterruptEnable = I2S_TCSR_FEIE_MASK,
140#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
141 kSAI_FIFORequestInterruptEnable = I2S_TCSR_FRIE_MASK,
142#endif /* FSL_FEATURE_SAI_HAS_FIFO */
143};
144
146enum
147{
148 kSAI_FIFOWarningDMAEnable = I2S_TCSR_FWDE_MASK,
149#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
150 kSAI_FIFORequestDMAEnable = I2S_TCSR_FRDE_MASK,
151#endif /* FSL_FEATURE_SAI_HAS_FIFO */
152};
153
155enum
156{
157 kSAI_WordStartFlag = I2S_TCSR_WSF_MASK,
158 kSAI_SyncErrorFlag = I2S_TCSR_SEF_MASK,
159 kSAI_FIFOErrorFlag = I2S_TCSR_FEF_MASK,
160#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
161 kSAI_FIFORequestFlag = I2S_TCSR_FRF_MASK,
162#endif /* FSL_FEATURE_SAI_HAS_FIFO */
163 kSAI_FIFOWarningFlag = I2S_TCSR_FWF_MASK,
164};
165
167typedef enum _sai_reset_type
168{
169 kSAI_ResetTypeSoftware = I2S_TCSR_SR_MASK,
170 kSAI_ResetTypeFIFO = I2S_TCSR_FR_MASK,
171 kSAI_ResetAll = I2S_TCSR_SR_MASK | I2S_TCSR_FR_MASK
173
174#if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING
179typedef enum _sai_fifo_packing
180{
181 kSAI_FifoPackingDisabled = 0x0U,
182 kSAI_FifoPacking8bit = 0x2U,
183 kSAI_FifoPacking16bit = 0x3U
184} sai_fifo_packing_t;
185#endif /* FSL_FEATURE_SAI_HAS_FIFO_PACKING */
186
188typedef struct _sai_config
189{
192#if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
193 bool mclkOutputEnable;
194#if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
195 sai_mclk_source_t mclkSource;
196#endif /* FSL_FEATURE_SAI_HAS_MCR */
197#endif
201
202#ifndef SAI_XFER_QUEUE_SIZE
204#define SAI_XFER_QUEUE_SIZE (4U)
205#endif
206
209{
223
225typedef enum _sai_word_width
226{
232
233#if defined(FSL_FEATURE_SAI_HAS_CHANNEL_MODE) && FSL_FEATURE_SAI_HAS_CHANNEL_MODE
235typedef enum _sai_data_pin_state
236{
237 kSAI_DataPinStateTriState =
238 0U,
239 kSAI_DataPinStateOutputZero = 1U,
241} sai_data_pin_state_t;
242#endif
243
244#if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE
246typedef enum _sai_fifo_combine
247{
248 kSAI_FifoCombineDisabled = 0U,
249 kSAI_FifoCombineModeEnabledOnRead,
250 kSAI_FifoCombineModeEnabledOnWrite,
251 kSAI_FifoCombineModeEnabledOnReadWrite,
252} sai_fifo_combine_t;
253#endif
254
257{
261
264{
268
271{
272 uint32_t sampleRate_Hz;
273 uint32_t bitWidth;
275#if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
276 uint32_t masterClockHz;
277#endif /* FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER */
278#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
279 uint8_t watermark;
280#endif /* FSL_FEATURE_SAI_HAS_FIFO */
281
282 /* for the multi channel usage, user can provide channelMask Oonly, then sai driver will handle
283 * other parameter carefully, such as
284 * channelMask = kSAI_Channel0Mask | kSAI_Channel1Mask | kSAI_Channel4Mask
285 * then in SAI_RxSetFormat/SAI_TxSetFormat function, channel/endChannel/channelNums will be calculated.
286 * for the single channel usage, user can provide channel or channel mask only, such as,
287 * channel = 0 or channelMask = kSAI_Channel0Mask.
288 */
289 uint8_t channel;
290 uint8_t channelMask;
291 uint8_t endChannel;
292 uint8_t channelNums;
298
299#if (defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)) || \
300 (defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER))
302typedef struct _sai_master_clock
303{
304#if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
305 bool mclkOutputEnable;
306#if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
307 sai_mclk_source_t mclkSource;
308#endif
309#endif
310
311#if (defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)) || \
312 (defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER))
313 uint32_t mclkHz;
314 uint32_t mclkSourceClkHz;
315#endif
316} sai_master_clock_t;
317#endif
318
320#if (defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) || \
321 (defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) || \
322 (defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING) || \
323 (defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO))
324#define FSL_SAI_HAS_FIFO_EXTEND_FEATURE 1
325#else
326#define FSL_SAI_HAS_FIFO_EXTEND_FEATURE 0
327#endif
328
329#if FSL_SAI_HAS_FIFO_EXTEND_FEATURE
331typedef struct _sai_fifo
332{
333#if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
334 bool fifoContinueOneError;
335#endif
336
337#if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE
338 sai_fifo_combine_t fifoCombine;
339#endif
340
341#if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING
342 sai_fifo_packing_t fifoPacking;
343#endif
344#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
345 uint8_t fifoWatermark;
346#endif
347} sai_fifo_t;
348#endif
349
351typedef struct _sai_bit_clock
352{
360
362typedef struct _sai_frame_sync
363{
368#if defined(FSL_FEATURE_SAI_HAS_ON_DEMAND_MODE) && FSL_FEATURE_SAI_HAS_ON_DEMAND_MODE
369 bool frameSyncGenerateOnDemand;
370#endif
371
375
377typedef struct _sai_serial_data
378{
379#if defined(FSL_FEATURE_SAI_HAS_CHANNEL_MODE) && FSL_FEATURE_SAI_HAS_CHANNEL_MODE
380 sai_data_pin_state_t dataMode;
381#endif
382
387 uint8_t
389 uint8_t dataWordNum;
390 uint32_t dataMaskedWord;
392
394typedef struct _sai_transceiver
395{
399#if FSL_SAI_HAS_FIFO_EXTEND_FEATURE
400 sai_fifo_t fifo;
401#endif
406 uint8_t startChannel;
407 uint8_t channelMask;
408 uint8_t endChannel;
409 uint8_t channelNums;
412
414typedef struct _sai_transfer
415{
416 uint8_t *data;
417 size_t dataSize;
419
420typedef struct _sai_handle sai_handle_t;
421
423typedef void (*sai_transfer_callback_t)(I2S_Type *base, sai_handle_t *handle, status_t status, void *userData);
424
427{
430 uint32_t state;
432 void *userData;
433 uint8_t bitWidth;
435 /* for the multi channel usage, user can provide channelMask Oonly, then sai driver will handle
436 * other parameter carefully, such as
437 * channelMask = kSAI_Channel0Mask | kSAI_Channel1Mask | kSAI_Channel4Mask
438 * then in SAI_RxSetFormat/SAI_TxSetFormat function, channel/endChannel/channelNums will be calculated.
439 * for the single channel usage, user can provide channel or channel mask only, such as,
440 * channel = 0 or channelMask = kSAI_Channel0Mask.
441 */
442 uint8_t channel;
443 uint8_t channelMask;
444 uint8_t endChannel;
445 uint8_t channelNums;
449 volatile uint8_t queueUser;
450 volatile uint8_t queueDriver;
451#if defined(FSL_FEATURE_SAI_HAS_FIFO) && (FSL_FEATURE_SAI_HAS_FIFO)
452 uint8_t watermark;
453#endif
454};
455
456/*******************************************************************************
457 * API
458 ******************************************************************************/
459
460#if defined(__cplusplus)
461extern "C" {
462#endif /*_cplusplus*/
463
484void SAI_TxInit(I2S_Type *base, const sai_config_t *config);
485
501void SAI_RxInit(I2S_Type *base, const sai_config_t *config);
502
521
540
548void SAI_Init(I2S_Type *base);
549
558void SAI_Deinit(I2S_Type *base);
559
567void SAI_TxReset(I2S_Type *base);
568
576void SAI_RxReset(I2S_Type *base);
577
584void SAI_TxEnable(I2S_Type *base, bool enable);
585
592void SAI_RxEnable(I2S_Type *base, bool enable);
593
602static inline void SAI_TxSetBitClockDirection(I2S_Type *base, sai_master_slave_t masterSlave)
603{
604 if (masterSlave == kSAI_Master)
605 {
606 base->TCR2 |= I2S_TCR2_BCD_MASK;
607 }
608 else
609 {
610 base->TCR2 &= ~I2S_TCR2_BCD_MASK;
611 }
612}
613
622static inline void SAI_RxSetBitClockDirection(I2S_Type *base, sai_master_slave_t masterSlave)
623{
624 if (masterSlave == kSAI_Master)
625 {
626 base->RCR2 |= I2S_RCR2_BCD_MASK;
627 }
628 else
629 {
630 base->RCR2 &= ~I2S_RCR2_BCD_MASK;
631 }
632}
633
642static inline void SAI_RxSetFrameSyncDirection(I2S_Type *base, sai_master_slave_t masterSlave)
643{
644 if (masterSlave == kSAI_Master)
645 {
646 base->RCR4 |= I2S_RCR4_FSD_MASK;
647 }
648 else
649 {
650 base->RCR4 &= ~I2S_RCR4_FSD_MASK;
651 }
652}
653
662static inline void SAI_TxSetFrameSyncDirection(I2S_Type *base, sai_master_slave_t masterSlave)
663{
664 if (masterSlave == kSAI_Master)
665 {
666 base->TCR4 |= I2S_TCR4_FSD_MASK;
667 }
668 else
669 {
670 base->TCR4 &= ~I2S_TCR4_FSD_MASK;
671 }
672}
673
684 I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers);
685
696 I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers);
697
706
715
716#if (defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)) || \
717 (defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER))
724void SAI_SetMasterClockConfig(I2S_Type *base, sai_master_clock_t *config);
725#endif
726
727#if FSL_SAI_HAS_FIFO_EXTEND_FEATURE
734void SAI_TxSetFifoConfig(I2S_Type *base, sai_fifo_t *config);
735
742void SAI_RxSetFifoConfig(I2S_Type *base, sai_fifo_t *config);
743#endif
744
753
762
770
778
786
794
804 sai_word_width_t bitWidth,
806 uint32_t saiChannelMask);
807
817 sai_word_width_t bitWidth,
819 uint32_t saiChannelMask);
820
830 sai_word_width_t bitWidth,
832 uint32_t saiChannelMask);
833
844 sai_frame_sync_len_t frameSyncWidth,
845 sai_word_width_t bitWidth,
846 uint32_t dataWordNum,
847 uint32_t saiChannelMask);
848
873 sai_frame_sync_len_t frameSyncWidth,
874 sai_word_width_t bitWidth,
876 uint32_t saiChannelMask);
890static inline uint32_t SAI_TxGetStatusFlag(I2S_Type *base)
891{
892 return base->TCSR;
893}
894
904static inline void SAI_TxClearStatusFlags(I2S_Type *base, uint32_t mask)
905{
906 base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | mask);
907}
908
915static inline uint32_t SAI_RxGetStatusFlag(I2S_Type *base)
916{
917 return base->RCSR;
918}
919
929static inline void SAI_RxClearStatusFlags(I2S_Type *base, uint32_t mask)
930{
931 base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | mask);
932}
933
945void SAI_TxSoftwareReset(I2S_Type *base, sai_reset_type_t resetType);
946
958void SAI_RxSoftwareReset(I2S_Type *base, sai_reset_type_t resetType);
959
967void SAI_TxSetChannelFIFOMask(I2S_Type *base, uint8_t mask);
968
976void SAI_RxSetChannelFIFOMask(I2S_Type *base, uint8_t mask);
977
985
993
1001
1009
1017
1025
1026#if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING
1033void SAI_TxSetFIFOPacking(I2S_Type *base, sai_fifo_packing_t pack);
1034
1041void SAI_RxSetFIFOPacking(I2S_Type *base, sai_fifo_packing_t pack);
1042#endif /* FSL_FEATURE_SAI_HAS_FIFO_PACKING */
1043
1044#if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
1054static inline void SAI_TxSetFIFOErrorContinue(I2S_Type *base, bool isEnabled)
1055{
1056 if (isEnabled)
1057 {
1058 base->TCR4 |= I2S_TCR4_FCONT_MASK;
1059 }
1060 else
1061 {
1062 base->TCR4 &= ~I2S_TCR4_FCONT_MASK;
1063 }
1064}
1065
1075static inline void SAI_RxSetFIFOErrorContinue(I2S_Type *base, bool isEnabled)
1076{
1077 if (isEnabled)
1078 {
1079 base->RCR4 |= I2S_RCR4_FCONT_MASK;
1080 }
1081 else
1082 {
1083 base->RCR4 &= ~I2S_RCR4_FCONT_MASK;
1084 }
1085}
1086#endif
1087
1107static inline void SAI_TxEnableInterrupts(I2S_Type *base, uint32_t mask)
1108{
1109 base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | mask);
1110}
1111
1124static inline void SAI_RxEnableInterrupts(I2S_Type *base, uint32_t mask)
1125{
1126 base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | mask);
1127}
1128
1141static inline void SAI_TxDisableInterrupts(I2S_Type *base, uint32_t mask)
1142{
1143 base->TCSR = ((base->TCSR & 0xFFE3FFFFU) & (~mask));
1144}
1145
1158static inline void SAI_RxDisableInterrupts(I2S_Type *base, uint32_t mask)
1159{
1160 base->RCSR = ((base->RCSR & 0xFFE3FFFFU) & (~mask));
1161}
1162
1179static inline void SAI_TxEnableDMA(I2S_Type *base, uint32_t mask, bool enable)
1180{
1181 if (enable)
1182 {
1183 base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | mask);
1184 }
1185 else
1186 {
1187 base->TCSR = ((base->TCSR & 0xFFE3FFFFU) & (~mask));
1188 }
1189}
1190
1200static inline void SAI_RxEnableDMA(I2S_Type *base, uint32_t mask, bool enable)
1201{
1202 if (enable)
1203 {
1204 base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | mask);
1205 }
1206 else
1207 {
1208 base->RCSR = ((base->RCSR & 0xFFE3FFFFU) & (~mask));
1209 }
1210}
1211
1221static inline uintptr_t SAI_TxGetDataRegisterAddress(I2S_Type *base, uint32_t channel)
1222{
1223 return (uintptr_t)(&(base->TDR)[channel]);
1224}
1225
1235static inline uintptr_t SAI_RxGetDataRegisterAddress(I2S_Type *base, uint32_t channel)
1236{
1237 return (uintptr_t)(&(base->RDR)[channel]);
1238}
1239
1260void SAI_TxSetFormat(I2S_Type *base,
1262 uint32_t mclkSourceClockHz,
1263 uint32_t bclkSourceClockHz);
1264
1278void SAI_RxSetFormat(I2S_Type *base,
1280 uint32_t mclkSourceClockHz,
1281 uint32_t bclkSourceClockHz);
1282
1294void SAI_WriteBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size);
1295
1309 I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size);
1310
1318static inline void SAI_WriteData(I2S_Type *base, uint32_t channel, uint32_t data)
1319{
1320 base->TDR[channel] = data;
1321}
1322
1334void SAI_ReadBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size);
1335
1349 I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size);
1350
1358static inline uint32_t SAI_ReadData(I2S_Type *base, uint32_t channel)
1359{
1360 return base->RDR[channel];
1361}
1362
1381void SAI_TransferTxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData);
1382
1394void SAI_TransferRxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData);
1395
1407
1419
1436 sai_handle_t *handle,
1438 uint32_t mclkSourceClockHz,
1439 uint32_t bclkSourceClockHz);
1440
1457 sai_handle_t *handle,
1459 uint32_t mclkSourceClockHz,
1460 uint32_t bclkSourceClockHz);
1461
1478
1495
1505status_t SAI_TransferGetSendCount(I2S_Type *base, sai_handle_t *handle, size_t *count);
1506
1516status_t SAI_TransferGetReceiveCount(I2S_Type *base, sai_handle_t *handle, size_t *count);
1517
1527void SAI_TransferAbortSend(I2S_Type *base, sai_handle_t *handle);
1528
1539
1550
1561
1568void SAI_TransferTxHandleIRQ(I2S_Type *base, sai_handle_t *handle);
1569
1576void SAI_TransferRxHandleIRQ(I2S_Type *base, sai_handle_t *handle);
1577
1580#if defined(__cplusplus)
1581}
1582#endif /*_cplusplus*/
1583
1586#endif /* _FSL_SAI_H_ */
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:47
@ kStatusGroup_SAI
Definition: fsl_common.h:102
_sai_sample_rate
Audio sample rate.
Definition: fsl_sai.h:209
enum _sai_clock_polarity sai_clock_polarity_t
SAI clock polarity, active high or low.
struct _sai_transfer_format sai_transfer_format_t
sai transfer format
void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI transmitter configurations.
Definition: fsl_sai.c:1428
void SAI_RxSetBitClockRate(I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
Receiver bit clock rate configurations.
Definition: fsl_sai.c:1090
void SAI_ReadBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
Receives data using a blocking method.
Definition: fsl_sai.c:2273
void SAI_TxSetBitClockPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Tx data order.
Definition: fsl_sai.c:952
void SAI_RxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI receiver configurations.
Definition: fsl_sai.c:1562
_sai_transceiver_type
sai transceiver type
Definition: fsl_sai.h:257
void SAI_TxSetDataOrder(I2S_Type *base, sai_data_order_t order)
Set the Tx data order.
Definition: fsl_sai.c:924
struct _sai_serial_data sai_serial_data_t
sai serial data configurations
void SAI_RxSetSerialDataConfig(I2S_Type *base, sai_serial_data_t *config)
SAI receiver Serial data configurations.
Definition: fsl_sai.c:1406
struct _sai_bit_clock sai_bit_clock_t
sai bit clock configurations
void SAI_TxSetSerialDataConfig(I2S_Type *base, sai_serial_data_t *config)
SAI transmitter Serial data configurations.
Definition: fsl_sai.c:1372
void SAI_RxSetBitclockConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
Receiver Bit clock configurations.
Definition: fsl_sai.c:1163
void SAI_TxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Tx.
Definition: fsl_sai.c:800
void SAI_WriteBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
Sends data using a blocking method.
Definition: fsl_sai.c:2133
void SAI_TxSetFrameSyncConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
SAI transmitter Frame sync configurations.
Definition: fsl_sai.c:1315
_sai_sync_mode
Synchronous or asynchronous mode.
Definition: fsl_sai.h:98
void SAI_TransferTxHandleIRQ(I2S_Type *base, sai_handle_t *handle)
Tx interrupt handler.
Definition: fsl_sai.c:2724
void SAI_TransferTerminateReceive(I2S_Type *base, sai_handle_t *handle)
Terminate all SAI receive.
Definition: fsl_sai.c:2703
void SAI_GetRightJustifiedConfig(sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
Get right justified mode configurations.
Definition: fsl_sai.c:1736
void SAI_TransferRxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
Initializes the SAI Rx handle.
Definition: fsl_sai.c:2336
void SAI_RxSoftwareReset(I2S_Type *base, sai_reset_type_t resetType)
Do software reset or FIFO reset .
Definition: fsl_sai.c:884
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:1992
#define SAI_XFER_QUEUE_SIZE
SAI transfer queue size, user can refine it according to use case.
Definition: fsl_sai.h:204
_sai_protocol
Define the SAI bus type.
Definition: fsl_sai.h:55
enum _sai_transceiver_type sai_transceiver_type_t
sai transceiver type
enum _sai_data_order sai_data_order_t
SAI data order, MSB or LSB.
void SAI_GetLeftJustifiedConfig(sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
Get left justified mode configurations.
Definition: fsl_sai.c:1714
void SAI_RxSetFrameSyncConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
SAI receiver Frame sync configurations.
Definition: fsl_sai.c:1344
void SAI_TxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
Set the Tx channel FIFO enable mask.
Definition: fsl_sai.c:899
status_t SAI_TransferTxSetFormat(I2S_Type *base, sai_handle_t *handle, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Tx audio format.
Definition: fsl_sai.c:2372
enum _sai_sample_rate sai_sample_rate_t
Audio sample rate.
void SAI_TxReset(I2S_Type *base)
Resets the SAI Tx.
Definition: fsl_sai.c:755
void SAI_TransferTxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
Initializes the SAI Tx handle.
Definition: fsl_sai.c:2305
void SAI_TxSetBitClockRate(I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
Transmitter bit clock rate configurations.
Definition: fsl_sai.c:1043
_sai_clock_polarity
SAI clock polarity, active high or low.
Definition: fsl_sai.h:89
void SAI_RxReset(I2S_Type *base)
Resets the SAI Rx.
Definition: fsl_sai.c:778
void SAI_TransferTxSetConfig(I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
SAI transmitter transfer configurations.
Definition: fsl_sai.c:1530
void SAI_RxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
Set the Rx channel FIFO enable mask.
Definition: fsl_sai.c:912
_sai_data_order
SAI data order, MSB or LSB.
Definition: fsl_sai.h:82
void SAI_ReadMultiChannelBlocking(I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
Receives multi channel data using a blocking method.
Definition: fsl_sai.c:2226
enum _sai_sync_mode sai_sync_mode_t
Synchronous or asynchronous mode.
enum _sai_frame_sync_len sai_frame_sync_len_t
sai frame sync len
enum _sai_mclk_source sai_mclk_source_t
Mater clock source.
void SAI_RxSetBitClockPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Rx data order.
Definition: fsl_sai.c:966
void SAI_TransferTerminateSend(I2S_Type *base, sai_handle_t *handle)
Terminate all SAI send.
Definition: fsl_sai.c:2679
void SAI_TransferAbortSend(I2S_Type *base, sai_handle_t *handle)
Aborts the current send.
Definition: fsl_sai.c:2619
enum _sai_bclk_source sai_bclk_source_t
Bit clock source.
enum _sai_protocol sai_protocol_t
Define the SAI bus type.
void SAI_RxSetDataOrder(I2S_Type *base, sai_data_order_t order)
Set the Rx data order.
Definition: fsl_sai.c:938
void SAI_TxSetBitclockConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
Transmitter Bit clock configurations.
Definition: fsl_sai.c:1135
_sai_reset_type
The reset type.
Definition: fsl_sai.h:168
_sai_mclk_source
Mater clock source.
Definition: fsl_sai.h:110
void SAI_TransferAbortReceive(I2S_Type *base, sai_handle_t *handle)
Aborts the current IRQ receive.
Definition: fsl_sai.c:2649
void SAI_TransferRxHandleIRQ(I2S_Type *base, sai_handle_t *handle)
Tx interrupt handler.
Definition: fsl_sai.c:2801
_sai_mono_stereo
Mono or stereo audio format.
Definition: fsl_sai.h:74
_sai_master_slave
Master or slave mode.
Definition: fsl_sai.h:65
void SAI_GetTDMConfig(sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, uint32_t dataWordNum, uint32_t saiChannelMask)
Get TDM mode configurations.
Definition: fsl_sai.c:1806
_sai_frame_sync_len
sai frame sync len
Definition: fsl_sai.h:264
void SAI_GetDSPConfig(sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
Get DSP mode configurations.
Definition: fsl_sai.c:1773
struct _sai_transfer sai_transfer_t
SAI transfer structure.
void SAI_RxGetDefaultConfig(sai_config_t *config)
Sets the SAI Rx configuration structure to default values.
Definition: fsl_sai.c:731
status_t SAI_TransferGetSendCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
Gets a set byte count.
Definition: fsl_sai.c:2563
struct _sai_frame_sync sai_frame_sync_t
sai frame sync configurations
void SAI_RxInit(I2S_Type *base, const sai_config_t *config)
Initializes the SAI Rx peripheral.
Definition: fsl_sai.c:528
struct _sai_config sai_config_t
SAI user configuration structure.
void SAI_TxGetDefaultConfig(sai_config_t *config)
Sets the SAI Tx configuration structure to default values.
Definition: fsl_sai.c:697
void SAI_Init(I2S_Type *base)
Initializes the SAI peripheral.
Definition: fsl_sai.c:643
status_t SAI_TransferReceiveNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
Performs an interrupt non-blocking receive transfer on SAI.
Definition: fsl_sai.c:2520
_sai_word_width
Audio word width.
Definition: fsl_sai.h:226
void(* sai_transfer_callback_t)(I2S_Type *base, sai_handle_t *handle, status_t status, void *userData)
SAI transfer callback prototype.
Definition: fsl_sai.h:423
void SAI_TransferRxSetConfig(I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
SAI receiver transfer configurations.
Definition: fsl_sai.c:1665
void SAI_RxSetFrameSyncPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Rx data order.
Definition: fsl_sai.c:994
_sai_bclk_source
Bit clock source.
Definition: fsl_sai.h:120
struct _sai_transceiver sai_transceiver_t
sai transceiver configurations
void SAI_TxInit(I2S_Type *base, const sai_config_t *config)
Initializes the SAI Tx peripheral.
Definition: fsl_sai.c:404
enum _sai_mono_stereo sai_mono_stereo_t
Mono or stereo audio format.
void SAI_Deinit(I2S_Type *base)
De-initializes the SAI peripheral.
Definition: fsl_sai.c:671
enum _sai_word_width sai_word_width_t
Audio word width.
enum _sai_reset_type sai_reset_type_t
The reset type.
void SAI_TxSoftwareReset(I2S_Type *base, sai_reset_type_t resetType)
Do software reset or FIFO reset .
Definition: fsl_sai.c:865
void SAI_RxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Rx.
Definition: fsl_sai.c:830
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:1849
status_t SAI_TransferSendNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
Performs an interrupt non-blocking send transfer on SAI.
Definition: fsl_sai.c:2471
void SAI_GetClassicI2SConfig(sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
Get classic I2S mode configurations.
Definition: fsl_sai.c:1698
void SAI_WriteMultiChannelBlocking(I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
Sends data to multi channel using a blocking method.
Definition: fsl_sai.c:2171
status_t SAI_TransferRxSetFormat(I2S_Type *base, sai_handle_t *handle, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Rx audio format.
Definition: fsl_sai.c:2422
status_t SAI_TransferGetReceiveCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
Gets a received byte count.
Definition: fsl_sai.c:2591
void SAI_TxSetFrameSyncPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Tx data order.
Definition: fsl_sai.c:980
enum _sai_master_slave sai_master_slave_t
Master or slave mode.
@ kSAI_SampleRate384KHz
Definition: fsl_sai.h:221
@ kSAI_SampleRate11025Hz
Definition: fsl_sai.h:211
@ kSAI_SampleRate8KHz
Definition: fsl_sai.h:210
@ kSAI_SampleRate96KHz
Definition: fsl_sai.h:219
@ kSAI_SampleRate48KHz
Definition: fsl_sai.h:218
@ kSAI_SampleRate16KHz
Definition: fsl_sai.h:213
@ kSAI_SampleRate22050Hz
Definition: fsl_sai.h:214
@ kSAI_SampleRate44100Hz
Definition: fsl_sai.h:217
@ kSAI_SampleRate32KHz
Definition: fsl_sai.h:216
@ kSAI_SampleRate12KHz
Definition: fsl_sai.h:212
@ kSAI_SampleRate24KHz
Definition: fsl_sai.h:215
@ kSAI_SampleRate192KHz
Definition: fsl_sai.h:220
@ kSAI_FIFOWarningFlag
Definition: fsl_sai.h:163
@ kSAI_FIFOErrorFlag
Definition: fsl_sai.h:159
@ kSAI_WordStartFlag
Definition: fsl_sai.h:157
@ kSAI_SyncErrorFlag
Definition: fsl_sai.h:158
@ kStatus_SAI_RxError
Definition: fsl_sai.h:34
@ kStatus_SAI_RxIdle
Definition: fsl_sai.h:37
@ kStatus_SAI_QueueFull
Definition: fsl_sai.h:35
@ kStatus_SAI_TxIdle
Definition: fsl_sai.h:36
@ kStatus_SAI_TxError
Definition: fsl_sai.h:33
@ kStatus_SAI_RxBusy
Definition: fsl_sai.h:32
@ kStatus_SAI_TxBusy
Definition: fsl_sai.h:31
@ kSAI_Transmitter
Definition: fsl_sai.h:258
@ kSAI_Receiver
Definition: fsl_sai.h:259
@ kSAI_Channel4Mask
Definition: fsl_sai.h:47
@ kSAI_Channel6Mask
Definition: fsl_sai.h:49
@ kSAI_Channel5Mask
Definition: fsl_sai.h:48
@ kSAI_Channel2Mask
Definition: fsl_sai.h:45
@ kSAI_Channel1Mask
Definition: fsl_sai.h:44
@ kSAI_Channel0Mask
Definition: fsl_sai.h:43
@ kSAI_Channel3Mask
Definition: fsl_sai.h:46
@ kSAI_Channel7Mask
Definition: fsl_sai.h:50
@ kSAI_ModeAsync
Definition: fsl_sai.h:99
@ kSAI_ModeSync
Definition: fsl_sai.h:100
@ kSAI_BusPCMA
Definition: fsl_sai.h:59
@ kSAI_BusLeftJustified
Definition: fsl_sai.h:56
@ kSAI_BusI2S
Definition: fsl_sai.h:58
@ kSAI_BusPCMB
Definition: fsl_sai.h:60
@ kSAI_BusRightJustified
Definition: fsl_sai.h:57
@ kSAI_FIFOWarningInterruptEnable
Definition: fsl_sai.h:138
@ kSAI_FIFOErrorInterruptEnable
Definition: fsl_sai.h:139
@ kSAI_SyncErrorInterruptEnable
Definition: fsl_sai.h:137
@ kSAI_WordStartInterruptEnable
Definition: fsl_sai.h:135
@ kSAI_SampleOnFallingEdge
Definition: fsl_sai.h:92
@ kSAI_PolarityActiveLow
Definition: fsl_sai.h:91
@ kSAI_SampleOnRisingEdge
Definition: fsl_sai.h:93
@ kSAI_PolarityActiveHigh
Definition: fsl_sai.h:90
@ kSAI_DataMSB
Definition: fsl_sai.h:84
@ kSAI_DataLSB
Definition: fsl_sai.h:83
@ kSAI_ResetTypeSoftware
Definition: fsl_sai.h:169
@ kSAI_ResetTypeFIFO
Definition: fsl_sai.h:170
@ kSAI_ResetAll
Definition: fsl_sai.h:171
@ kSAI_MclkSourceSelect3
Definition: fsl_sai.h:114
@ kSAI_MclkSourceSelect2
Definition: fsl_sai.h:113
@ kSAI_MclkSourceSysclk
Definition: fsl_sai.h:111
@ kSAI_MclkSourceSelect1
Definition: fsl_sai.h:112
@ kSAI_MonoLeft
Definition: fsl_sai.h:77
@ kSAI_MonoRight
Definition: fsl_sai.h:76
@ kSAI_Stereo
Definition: fsl_sai.h:75
@ kSAI_Bclk_Master_FrameSync_Slave
Definition: fsl_sai.h:68
@ kSAI_Master
Definition: fsl_sai.h:66
@ kSAI_Bclk_Slave_FrameSync_Master
Definition: fsl_sai.h:69
@ kSAI_Slave
Definition: fsl_sai.h:67
@ kSAI_FrameSyncLenOneBitClk
Definition: fsl_sai.h:265
@ kSAI_FrameSyncLenPerWordWidth
Definition: fsl_sai.h:266
@ kSAI_WordWidth16bits
Definition: fsl_sai.h:228
@ kSAI_WordWidth32bits
Definition: fsl_sai.h:230
@ kSAI_WordWidth24bits
Definition: fsl_sai.h:229
@ kSAI_WordWidth8bits
Definition: fsl_sai.h:227
@ kSAI_BclkSourceMclkOption1
Definition: fsl_sai.h:123
@ kSAI_BclkSourceMclkOption2
Definition: fsl_sai.h:124
@ kSAI_BclkSourceMclkOption3
Definition: fsl_sai.h:125
@ kSAI_BclkSourceOtherSai1
Definition: fsl_sai.h:129
@ kSAI_BclkSourceBusclk
Definition: fsl_sai.h:121
@ kSAI_BclkSourceMclkDiv
Definition: fsl_sai.h:127
@ kSAI_BclkSourceOtherSai0
Definition: fsl_sai.h:128
@ kSAI_FIFOWarningDMAEnable
Definition: fsl_sai.h:148
Definition: MIMXRT1052.h:23296
sai bit clock configurations
Definition: fsl_sai.h:352
sai_bclk_source_t bclkSource
Definition: fsl_sai.h:358
bool bclkSrcSwap
Definition: fsl_sai.h:353
sai_clock_polarity_t bclkPolarity
Definition: fsl_sai.h:357
bool bclkInputDelay
Definition: fsl_sai.h:354
SAI user configuration structure.
Definition: fsl_sai.h:189
sai_protocol_t protocol
Definition: fsl_sai.h:190
sai_bclk_source_t bclkSource
Definition: fsl_sai.h:198
sai_master_slave_t masterSlave
Definition: fsl_sai.h:199
sai_sync_mode_t syncMode
Definition: fsl_sai.h:191
sai frame sync configurations
Definition: fsl_sai.h:363
uint8_t frameSyncWidth
Definition: fsl_sai.h:364
sai_clock_polarity_t frameSyncPolarity
Definition: fsl_sai.h:372
bool frameSyncEarly
Definition: fsl_sai.h:365
SAI handle structure.
Definition: fsl_sai.h:427
void * userData
Definition: fsl_sai.h:432
sai_transfer_t saiQueue[SAI_XFER_QUEUE_SIZE]
Definition: fsl_sai.h:447
sai_transfer_callback_t callback
Definition: fsl_sai.h:431
I2S_Type * base
Definition: fsl_sai.h:428
uint8_t channel
Definition: fsl_sai.h:442
uint32_t state
Definition: fsl_sai.h:430
uint8_t bitWidth
Definition: fsl_sai.h:433
uint8_t channelNums
Definition: fsl_sai.h:445
size_t transferSize[SAI_XFER_QUEUE_SIZE]
Definition: fsl_sai.h:448
uint8_t channelMask
Definition: fsl_sai.h:443
uint8_t endChannel
Definition: fsl_sai.h:444
volatile uint8_t queueUser
Definition: fsl_sai.h:449
volatile uint8_t queueDriver
Definition: fsl_sai.h:450
sai serial data configurations
Definition: fsl_sai.h:378
uint8_t dataWord0Length
Definition: fsl_sai.h:384
uint8_t dataWordNum
Definition: fsl_sai.h:389
uint8_t dataWordNLength
Definition: fsl_sai.h:385
uint8_t dataFirstBitShifted
Definition: fsl_sai.h:388
sai_data_order_t dataOrder
Definition: fsl_sai.h:383
uint8_t dataWordLength
Definition: fsl_sai.h:386
uint32_t dataMaskedWord
Definition: fsl_sai.h:390
sai transceiver configurations
Definition: fsl_sai.h:395
uint8_t channelMask
Definition: fsl_sai.h:407
sai_master_slave_t masterSlave
Definition: fsl_sai.h:402
sai_frame_sync_t frameSync
Definition: fsl_sai.h:397
uint8_t endChannel
Definition: fsl_sai.h:408
sai_serial_data_t serialData
Definition: fsl_sai.h:396
uint8_t channelNums
Definition: fsl_sai.h:409
uint8_t startChannel
Definition: fsl_sai.h:406
sai_bit_clock_t bitClock
Definition: fsl_sai.h:398
sai_sync_mode_t syncMode
Definition: fsl_sai.h:404
sai transfer format
Definition: fsl_sai.h:271
bool isFrameSyncCompact
Definition: fsl_sai.h:295
uint8_t channelNums
Definition: fsl_sai.h:292
uint8_t endChannel
Definition: fsl_sai.h:291
uint32_t bitWidth
Definition: fsl_sai.h:273
sai_mono_stereo_t stereo
Definition: fsl_sai.h:274
uint8_t channelMask
Definition: fsl_sai.h:290
uint8_t channel
Definition: fsl_sai.h:289
sai_protocol_t protocol
Definition: fsl_sai.h:294
uint32_t sampleRate_Hz
Definition: fsl_sai.h:272
SAI transfer structure.
Definition: fsl_sai.h:415
size_t dataSize
Definition: fsl_sai.h:417
uint8_t * data
Definition: fsl_sai.h:416
Definition: deflate.c:114
Definition: mknod-pack_dev.c:254