Go to the documentation of this file.
12 #ifndef FSL_COMPONENT_ID
13 #define FSL_COMPONENT_ID "platform.drivers.sai"
34 #define IS_SAI_FLAG_SET(reg, flag) (((reg) & ((uint32_t)flag)) != 0UL)
70 #if ((defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)) || \
71 (defined(FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV) && (FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV)))
83 static void SAI_SetMasterClockDivider(
I2S_Type *base, uint32_t mclk_Hz, uint32_t mclkSrcClock_Hz);
106 uint32_t channelMask,
125 uint32_t channelMask,
142 uint32_t saiChannelMask);
153 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
167 uint32_t rcsr = base->
RCSR;
174 uint32_t tcsr = base->
TCSR;
179 #if ((defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)) || \
180 (defined(FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV) && (FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV)))
181 static void SAI_SetMasterClockDivider(
I2S_Type *base, uint32_t mclk_Hz, uint32_t mclkSrcClock_Hz)
183 assert(mclk_Hz <= mclkSrcClock_Hz);
185 uint32_t sourceFreq = mclkSrcClock_Hz / 100U;
186 uint32_t targetFreq = mclk_Hz / 100U;
188 #if FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV
189 uint32_t postDivider = sourceFreq / targetFreq;
192 if (postDivider == 1U)
194 base->MCR &= ~I2S_MCR_DIVEN_MASK;
198 base->MCR = (base->MCR & (~I2S_MCR_DIV_MASK)) | I2S_MCR_DIV(postDivider / 2U - 1U) | I2S_MCR_DIVEN_MASK;
201 #if FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER
202 uint16_t fract, divide;
203 uint32_t remaind = 0;
204 uint32_t current_remainder = 0xFFFFFFFFU;
205 uint16_t current_fract = 0;
206 uint16_t current_divide = 0;
207 uint32_t mul_freq = 0;
208 uint32_t max_fract = 256;
211 max_fract = targetFreq * 4096U / sourceFreq + 1U;
212 if (max_fract > 256U)
218 for (fract = 1; fract < max_fract; fract++)
220 mul_freq = sourceFreq * fract;
221 remaind = mul_freq % targetFreq;
222 divide = (uint16_t)(mul_freq / targetFreq);
227 current_fract = fract;
228 current_divide = (uint16_t)(mul_freq / targetFreq);
233 if (remaind > mclk_Hz / 2U)
235 remaind = targetFreq - remaind;
240 if (remaind < current_remainder)
242 current_fract = fract;
243 current_divide = divide;
244 current_remainder = remaind;
249 base->MDR = I2S_MDR_DIVIDE(current_divide - 1UL) | I2S_MDR_FRACT(current_fract - 1UL);
252 while ((base->MCR & I2S_MCR_DUF_MASK) != 0UL)
279 uint32_t channelMask,
285 uint32_t i = 0, j = 0U;
287 uint8_t bytesPerWord = bitWidth / 8U;
291 for (i = 0; i < size / bytesPerWord; i++)
293 for (j = channel; j <= endChannel; j++)
297 for (m = 0; m < bytesPerWord; m++)
299 temp = (uint32_t)(*buffer);
300 data |= (temp << (8U * m));
312 uint32_t channelMask,
318 uint32_t i = 0, j = 0;
320 uint8_t bytesPerWord = bitWidth / 8U;
323 for (i = 0; i < size / bytesPerWord; i++)
325 for (j = channel; j <= endChannel; j++)
330 for (m = 0; m < bytesPerWord; m++)
332 *buffer = (uint8_t)(data >> (8U * m)) & 0xFFU;
343 uint32_t saiChannelMask)
346 assert(saiChannelMask != 0U);
366 #if defined(FSL_FEATURE_SAI_HAS_FRAME_SYNC_ON_DEMAND) && FSL_FEATURE_SAI_HAS_FRAME_SYNC_ON_DEMAND
372 #if defined(FSL_FEATURE_SAI_HAS_CHANNEL_MODE) && FSL_FEATURE_SAI_HAS_CHANNEL_MODE
383 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
388 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
389 config->fifo.fifoContinueOneError =
true;
413 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
418 #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
419 #if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
421 val = (base->MCR & ~I2S_MCR_MICS_MASK);
422 base->MCR = (val | I2S_MCR_MICS(
config->mclkSource));
426 val = (base->MCR & ~I2S_MCR_MOE_MASK);
427 base->MCR = (val | I2S_MCR_MOE(
config->mclkOutputEnable));
497 #if defined(FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI) && (FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI)
512 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
513 SAI_TxSetFIFOErrorContinue(base,
true);
537 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
542 #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
543 #if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
545 val = (base->MCR & ~I2S_MCR_MICS_MASK);
546 base->MCR = (val | I2S_MCR_MICS(
config->mclkSource));
550 val = (base->MCR & ~I2S_MCR_MOE_MASK);
551 base->MCR = (val | I2S_MCR_MOE(
config->mclkOutputEnable));
621 #if defined(FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI) && (FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI)
636 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
637 SAI_RxSetFIFOErrorContinue(base,
true);
650 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
655 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
680 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
709 #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
710 config->mclkOutputEnable =
true;
711 #if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
743 #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
744 config->mclkOutputEnable =
true;
745 #if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
872 base->
TCSR |= (uint32_t)type;
891 base->
RCSR |= (uint32_t)type;
1007 #if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING
1014 void SAI_TxSetFIFOPacking(
I2S_Type *base, sai_fifo_packing_t pack)
1016 uint32_t val = base->
TCR4;
1029 void SAI_RxSetFIFOPacking(
I2S_Type *base, sai_fifo_packing_t pack)
1031 uint32_t val = base->
RCR4;
1049 I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
1051 uint32_t tcr2 = base->
TCR2;
1052 uint32_t bitClockDiv = 0;
1053 uint32_t bitClockFreq = sampleRate * bitWidth * channelNumbers;
1055 assert(sourceClockHz >= bitClockFreq);
1059 bitClockDiv = sourceClockHz / bitClockFreq;
1061 if (bitClockDiv == 0U)
1066 if ((sourceClockHz / bitClockDiv) > bitClockFreq)
1071 #if defined(FSL_FEATURE_SAI_HAS_BCLK_BYPASS) && (FSL_FEATURE_SAI_HAS_BCLK_BYPASS)
1073 if (bitClockDiv == 1U)
1075 tcr2 |= I2S_TCR2_BYP_MASK;
1096 I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
1098 uint32_t rcr2 = base->
RCR2;
1099 uint32_t bitClockDiv = 0;
1100 uint32_t bitClockFreq = sampleRate * bitWidth * channelNumbers;
1102 assert(sourceClockHz >= bitClockFreq);
1106 bitClockDiv = sourceClockHz / bitClockFreq;
1108 if (bitClockDiv == 0U)
1113 if ((sourceClockHz / bitClockDiv) > bitClockFreq)
1118 #if defined(FSL_FEATURE_SAI_HAS_BCLK_BYPASS) && (FSL_FEATURE_SAI_HAS_BCLK_BYPASS)
1120 if (bitClockDiv == 1U)
1122 rcr2 |= I2S_RCR2_BYP_MASK;
1142 uint32_t tcr2 = base->
TCR2;
1169 uint32_t rcr2 = base->
RCR2;
1187 #if (defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)) || \
1188 (defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER))
1195 void SAI_SetMasterClockConfig(
I2S_Type *base, sai_master_clock_t *
config)
1199 #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
1201 #if !(defined(FSL_FEATURE_SAI_HAS_NO_MCR_MICS) && (FSL_FEATURE_SAI_HAS_NO_MCR_MICS))
1203 val = (base->MCR & ~I2S_MCR_MICS_MASK);
1204 base->MCR = (val | I2S_MCR_MICS(
config->mclkSource));
1208 val = (base->MCR & ~I2S_MCR_MOE_MASK);
1209 base->MCR = (val | I2S_MCR_MOE(
config->mclkOutputEnable));
1212 #if ((defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)) || \
1213 (defined(FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV) && (FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV)))
1215 if (
config->mclkOutputEnable)
1217 SAI_SetMasterClockDivider(base,
config->mclkHz,
config->mclkSourceClkHz);
1223 #if FSL_SAI_HAS_FIFO_EXTEND_FEATURE
1233 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
1237 uint32_t tcr4 = base->
TCR4;
1239 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_COMBINE) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_COMBINE
1244 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
1248 if (base->
TMR == 0U)
1254 #if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING
1261 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
1275 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
1278 uint32_t rcr4 = base->
RCR4;
1280 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_COMBINE) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_COMBINE
1285 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
1290 #if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING
1297 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
1312 uint32_t tcr4 = base->
TCR4;
1321 #if defined(FSL_FEATURE_SAI_HAS_FRAME_SYNC_ON_DEMAND) && FSL_FEATURE_SAI_HAS_FRAME_SYNC_ON_DEMAND
1346 uint32_t rcr4 = base->
RCR4;
1355 #if defined(FSL_FEATURE_SAI_HAS_FRAME_SYNC_ON_DEMAND) && FSL_FEATURE_SAI_HAS_FRAME_SYNC_ON_DEMAND
1381 uint32_t tcr4 = base->
TCR4;
1386 #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
1389 if (
config->dataMaskedWord > 0U)
1397 #if defined(FSL_FEATURE_SAI_HAS_CHANNEL_MODE) && FSL_FEATURE_SAI_HAS_CHANNEL_MODE
1415 uint32_t rcr4 = base->
RCR4;
1440 uint8_t channelNums = 0U;
1471 #if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && (FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE)
1499 #if defined(FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI) && (FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI)
1520 #if FSL_SAI_HAS_FIFO_EXTEND_FEATURE
1522 SAI_TxSetFifoConfig(base, &
config->fifo);
1537 assert(handle !=
NULL);
1542 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
1543 handle->watermark =
config->fifo.fifoWatermark;
1569 uint8_t channelNums = 0U;
1600 #if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && (FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE)
1629 #if defined(FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI) && (FSL_FEATURE_SAI_HAS_SYNC_WITH_ANOTHER_SAI)
1650 #if FSL_SAI_HAS_FIFO_EXTEND_FEATURE
1652 SAI_RxSetFifoConfig(base, &
config->fifo);
1667 assert(handle !=
NULL);
1671 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
1672 handle->watermark =
config->fifo.fifoWatermark;
1696 uint32_t saiChannelMask)
1712 uint32_t saiChannelMask)
1715 assert(saiChannelMask != 0U);
1734 uint32_t saiChannelMask)
1737 assert(saiChannelMask != 0U);
1757 uint32_t saiChannelMask)
1760 assert(saiChannelMask != 0U);
1765 switch (frameSyncWidth)
1789 uint32_t dataWordNum,
1790 uint32_t saiChannelMask)
1793 assert(saiChannelMask != 0U);
1794 assert(dataWordNum <= 32U);
1799 switch (frameSyncWidth)
1831 uint32_t mclkSourceClockHz,
1832 uint32_t bclkSourceClockHz)
1838 uint8_t i = 0U, channelNums = 0U;
1839 uint32_t divider = 0U;
1854 #if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
1858 SAI_SetMasterClockDivider(base, format->masterClockHz, mclkSourceClockHz);
1867 divider = bclkSourceClockHz / bclk;
1874 if ((bclkSourceClockHz / divider) > bclk)
1879 #if defined(FSL_FEATURE_SAI_HAS_BCLK_BYPASS) && (FSL_FEATURE_SAI_HAS_BCLK_BYPASS)
1883 base->
TCR2 |= I2S_TCR2_BYP_MASK;
1940 #if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && (FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE)
1952 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
1954 base->
TCR1 = format->watermark;
1974 uint32_t mclkSourceClockHz,
1975 uint32_t bclkSourceClockHz)
1981 uint8_t i = 0U, channelNums = 0U;
1982 uint32_t divider = 0U;
1997 #if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
2001 SAI_SetMasterClockDivider(base, format->masterClockHz, mclkSourceClockHz);
2010 divider = bclkSourceClockHz / bclk;
2017 if ((bclkSourceClockHz / divider) > bclk)
2021 #if defined(FSL_FEATURE_SAI_HAS_BCLK_BYPASS) && (FSL_FEATURE_SAI_HAS_BCLK_BYPASS)
2025 base->
RCR2 |= I2S_RCR2_BYP_MASK;
2083 #if defined(FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE) && (FSL_FEATURE_SAI_HAS_FIFO_COMBINE_MODE)
2096 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2098 base->
RCR1 = format->watermark;
2116 uint32_t bytesPerWord = bitWidth / 8U;
2117 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2128 SAI_WriteNonBlocking(base, channel, 1UL << channel, channel, (uint8_t)bitWidth, buffer, bytesPerWord);
2129 buffer += bytesPerWord;
2152 I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
2156 uint32_t i = 0, j = 0;
2157 uint32_t bytesPerWord = bitWidth / 8U;
2158 uint32_t channelNums = 0U, endChannel = 0U;
2160 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2173 bytesPerWord *= channelNums;
2182 SAI_WriteNonBlocking(base, channel, channelMask, endChannel, (uint8_t)bitWidth, buffer, bytesPerWord);
2183 buffer += bytesPerWord;
2206 I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
2210 uint32_t i = 0, j = 0;
2211 uint32_t bytesPerWord = bitWidth / 8U;
2212 uint32_t channelNums = 0U, endChannel = 0U;
2213 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2214 bytesPerWord = base->
RCR1 * bytesPerWord;
2225 bytesPerWord *= channelNums;
2234 SAI_ReadNonBlocking(base, channel, channelMask, endChannel, (uint8_t)bitWidth, buffer, bytesPerWord);
2235 buffer += bytesPerWord;
2254 uint32_t bytesPerWord = bitWidth / 8U;
2255 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2256 bytesPerWord = base->
RCR1 * bytesPerWord;
2266 SAI_ReadNonBlocking(base, channel, 1UL << channel, channel, (uint8_t)bitWidth, buffer, bytesPerWord);
2267 buffer += bytesPerWord;
2285 assert(handle !=
NULL);
2288 (void)memset(handle, 0,
sizeof(*handle));
2294 handle->
base = base;
2316 assert(handle !=
NULL);
2319 (void)memset(handle, 0,
sizeof(*handle));
2325 handle->
base = base;
2353 uint32_t mclkSourceClockHz,
2354 uint32_t bclkSourceClockHz)
2356 assert(handle !=
NULL);
2358 if ((bclkSourceClockHz < format->sampleRate_Hz)
2360 || (mclkSourceClockHz < format->sampleRate_Hz)
2370 handle->watermark = format->watermark;
2403 uint32_t mclkSourceClockHz,
2404 uint32_t bclkSourceClockHz)
2406 assert(handle !=
NULL);
2408 if ((bclkSourceClockHz < format->sampleRate_Hz)
2410 || (mclkSourceClockHz < format->sampleRate_Hz)
2420 handle->watermark = format->watermark;
2451 assert(handle !=
NULL);
2470 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2500 assert(handle !=
NULL);
2519 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2543 assert(handle !=
NULL);
2571 assert(handle !=
NULL);
2599 assert(handle !=
NULL);
2603 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2629 assert(handle !=
NULL);
2633 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2659 assert(handle !=
NULL);
2683 assert(handle !=
NULL);
2704 assert(handle !=
NULL);
2726 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2781 assert(handle !=
NULL);
2803 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2850 void I2S0_DriverIRQHandler(
void)
2852 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2862 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2875 void I2S0_Tx_DriverIRQHandler(
void)
2882 void I2S0_Rx_DriverIRQHandler(
void)
2891 void I2S1_DriverIRQHandler(
void)
2893 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2904 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2917 void I2S1_Tx_DriverIRQHandler(
void)
2924 void I2S1_Rx_DriverIRQHandler(
void)
2933 void I2S2_DriverIRQHandler(
void)
2935 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2946 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2959 void I2S2_Tx_DriverIRQHandler(
void)
2966 void I2S2_Rx_DriverIRQHandler(
void)
2975 void I2S3_DriverIRQHandler(
void)
2977 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
2987 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3000 void I2S3_Tx_DriverIRQHandler(
void)
3007 void I2S3_Rx_DriverIRQHandler(
void)
3016 void I2S4_DriverIRQHandler(
void)
3018 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3029 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3042 void I2S4_Tx_DriverIRQHandler(
void)
3049 void I2S4_Rx_DriverIRQHandler(
void)
3057 #if defined(FSL_FEATURE_SAI_SAI5_SAI6_SHARE_IRQ) && (FSL_FEATURE_SAI_SAI5_SAI6_SHARE_IRQ) && defined(I2S5) && \
3059 void I2S56_DriverIRQHandler(
void)
3063 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3075 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3088 void I2S56_Tx_DriverIRQHandler(
void)
3096 void I2S56_Rx_DriverIRQHandler(
void)
3107 void I2S5_DriverIRQHandler(
void)
3109 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3119 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3132 void I2S5_Tx_DriverIRQHandler(
void)
3139 void I2S5_Rx_DriverIRQHandler(
void)
3148 void I2S6_DriverIRQHandler(
void)
3150 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3160 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3173 void I2S6_Tx_DriverIRQHandler(
void)
3180 void I2S6_Rx_DriverIRQHandler(
void)
3189 #if defined(AUDIO__SAI0)
3190 void AUDIO_SAI0_INT_DriverIRQHandler(
void)
3192 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3205 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3221 #if defined(AUDIO__SAI1)
3222 void AUDIO_SAI1_INT_DriverIRQHandler(
void)
3224 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3236 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3252 #if defined(AUDIO__SAI2)
3253 void AUDIO_SAI2_INT_DriverIRQHandler(
void)
3255 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3267 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3283 #if defined(AUDIO__SAI3)
3284 void AUDIO_SAI3_INT_DriverIRQHandler(
void)
3286 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3298 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3314 #if defined(AUDIO__SAI6)
3315 void AUDIO_SAI6_INT_DriverIRQHandler(
void)
3317 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3329 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3345 #if defined(AUDIO__SAI7)
3346 void AUDIO_SAI7_INT_DriverIRQHandler(
void)
3348 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3360 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3376 #if defined(ADMA__SAI0)
3377 void ADMA_SAI0_INT_DriverIRQHandler(
void)
3379 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3391 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3407 #if defined(ADMA__SAI1)
3408 void ADMA_SAI1_INT_DriverIRQHandler(
void)
3410 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3422 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3438 #if defined(ADMA__SAI2)
3439 void ADMA_SAI2_INT_DriverIRQHandler(
void)
3441 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3453 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3469 #if defined(ADMA__SAI3)
3470 void ADMA_SAI3_INT_DriverIRQHandler(
void)
3472 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3484 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3500 #if defined(ADMA__SAI4)
3501 void ADMA_SAI4_INT_DriverIRQHandler(
void)
3503 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3516 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3532 #if defined(ADMA__SAI5)
3533 void ADMA_SAI5_INT_DriverIRQHandler(
void)
3535 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3547 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3564 void SAI0_DriverIRQHandler(
void)
3566 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3576 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3591 void SAI1_DriverIRQHandler(
void)
3593 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3603 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3618 void SAI2_DriverIRQHandler(
void)
3620 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3630 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3645 void SAI3_DriverIRQHandler(
void)
3647 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3657 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3670 void SAI3_TX_DriverIRQHandler(
void)
3677 void SAI3_RX_DriverIRQHandler(
void)
3686 void SAI4_DriverIRQHandler(
void)
3688 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3698 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3713 void SAI5_DriverIRQHandler(
void)
3715 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3725 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3740 void SAI6_DriverIRQHandler(
void)
3742 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
3752 #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
void SAI_RxGetDefaultConfig(sai_config_t *config)
Sets the SAI Rx configuration structure to default values.
void(* sai_tx_isr_t)(I2S_Type *base, sai_handle_t *saiHandle)
Typedef for sai tx interrupt handler.
enum _sai_master_slave sai_master_slave_t
Master or slave mode.
void SAI_TxSetBitclockConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
Transmitter Bit clock configurations.
#define I2S_RCR4_FCONT_MASK
void SAI_TransferTerminateReceive(I2S_Type *base, sai_handle_t *handle)
Terminate all SAI receive.
static sai_handle_t * s_saiHandle[ARRAY_SIZE(s_saiBases)][2]
SAI handle pointer.
size_t transferSize[SAI_XFER_QUEUE_SIZE]
@ kStatus_InvalidArgument
void SAI_TransferTxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
Initializes the SAI Tx handle.
#define I2S_RCSR_FWF_MASK
#define I2S_RCR2_DIV_MASK
static bool SAI_RxGetEnabledInterruptStatus(I2S_Type *base, uint32_t enableFlag, uint32_t statusFlag)
sai get rx enabled interrupt status.
#define I2S_TCR2_BCI_MASK
#define I2S_TCSR_FEIE_MASK
#define I2S_RCR2_BCD_MASK
uint8_t dataFirstBitShifted
#define I2S_RCR4_FSE_MASK
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.
#define I2S_TCR4_SYWD_SHIFT
static void SAI_GetCommonConfig(sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
Get classic I2S mode configurations.
enum _sai_mono_stereo sai_mono_stereo_t
Mono or stereo audio format.
sai frame sync configurations
void SAI_TxSoftwareReset(I2S_Type *base, sai_reset_type_t type)
Do software reset or FIFO reset .
#define I2S_TCSR_FWIE_MASK
#define I2S_TCR1_TFW_MASK
#define IS_SAI_FLAG_SET(reg, flag)
check flag avalibility
#define I2S_TCSR_FRF_MASK
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.
#define I2S_TCSR_FWF_MASK
void SAI_TxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
Set the Tx channel FIFO enable mask.
volatile uint8_t queueDriver
@ kStatus_NoTransferInProgress
enum _sai_data_order sai_data_order_t
SAI data order, MSB or LSB.
#define I2S_TCR4_CHMOD_MASK
enum _sai_word_width sai_word_width_t
Audio word width.
status_t SAI_TransferGetReceiveCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
Gets a received byte count.
void SAI_RxSetBitclockConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
Receiver Bit clock configurations.
static sai_tx_isr_t s_saiTxIsr
Pointer to tx IRQ handler for each instance.
#define I2S_RCR3_RCE_MASK
#define FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER
void SAI_RxSetSerialDataConfig(I2S_Type *base, sai_serial_data_t *config)
SAI receiver Serial data configurations.
void SAI_RxSetFrameSyncPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Rx data order.
#define I2S_TCR4_SYWD_MASK
#define I2S_RCSR_FEIE_MASK
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.
void SAI_RxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Rx.
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.
status_t SAI_TransferGetSendCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
Gets a set byte count.
#define I2S_TCR2_BCD_MASK
sai_clock_polarity_t frameSyncPolarity
enum _sai_clock_polarity sai_clock_polarity_t
SAI clock polarity, active high or low.
sai_transfer_callback_t callback
#define I2S_RCR4_FCOMB(x)
#define I2S_RCSR_FRIE_MASK
#define I2S_RCR2_MSEL_MASK
sai_master_slave_t masterSlave
void SAI_TxSetBitClockRate(I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
Transmitter bit clock rate configurations.
#define I2S_TCR4_FCOMB_MASK
void SAI_TxSetFrameSyncPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Tx data order.
#define I2S_RCSR_FWIE_MASK
#define I2S_RCR3_WDFL_MASK
void SAI_RxSetFormat(I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Rx audio format.
static bool SAI_TxGetEnabledInterruptStatus(I2S_Type *base, uint32_t enableFlag, uint32_t statusFlag)
sai get tx enabled interrupt status.
sai serial data configurations
@ kSAI_PolarityActiveHigh
#define I2S_RCR4_FCOMB_MASK
#define I2S_TCR4_FCOMB(x)
sai_frame_sync_t frameSync
status_t SAI_TransferReceiveNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
Performs an interrupt non-blocking receive transfer on SAI.
void SAI_TransferAbortSend(I2S_Type *base, sai_handle_t *handle)
Aborts the current send.
#define SAI_XFER_QUEUE_SIZE
SAI transfer queue size, user can refine it according to use case.
void SAI_TransferRxHandleIRQ(I2S_Type *base, sai_handle_t *handle)
Tx interrupt handler.
void SAI_TxInit(I2S_Type *base, const sai_config_t *config)
Initializes the SAI Tx peripheral.
void SAI_TransferRxSetConfig(I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
SAI receiver transfer configurations.
sai_transfer_t saiQueue[SAI_XFER_QUEUE_SIZE]
#define I2S_TCSR_FRDE_MASK
#define I2S_TCR2_BCS_MASK
#define SDK_ISR_EXIT_BARRIER
enum _sai_reset_type sai_reset_type_t
The reset type.
void SAI_RxSetFrameSyncConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
SAI receiver Frame sync configurations.
@ kSAI_FrameSyncLenOneBitClk
static void SAI_RxDisableInterrupts(I2S_Type *base, uint32_t mask)
Disables the SAI Rx interrupt requests.
void SAI_TransferTerminateSend(I2S_Type *base, sai_handle_t *handle)
Terminate all SAI send.
#define I2S_RCSR_FEF_MASK
#define I2S_RCR4_SYWD_MASK
static uint32_t SAI_GetInstance(I2S_Type *base)
Get the instance number for SAI.
#define ARRAY_SIZE(x)
Computes the number of elements in an array.
@ kSAI_Bclk_Master_FrameSync_Slave
enum _sai_frame_sync_len sai_frame_sync_len_t
sai frame sync len
#define SAI_CLOCKS
Clock ip name array for SAI.
static I2S_Type *const s_saiBases[]
#define I2S_TCSR_FEF_MASK
IRQn_Type
STM32F4XX Interrupt Number Definition, according to the selected device in Library_configuration_sect...
#define I2S_TCR2_MSEL_MASK
#define I2S_RCR4_FPACK(x)
#define I2S_TCR4_FPACK(x)
@ kSAI_Bclk_Slave_FrameSync_Master
static void SAI_TxEnableInterrupts(I2S_Type *base, uint32_t mask)
Enables the SAI Tx interrupt requests.
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.
#define I2S_RCR2_SYNC_MASK
#define I2S_RCR4_SYWD_SHIFT
static void SAI_RxClearStatusFlags(I2S_Type *base, uint32_t mask)
Clears the SAI Rx status flag state.
void SAI_Deinit(I2S_Type *base)
De-initializes the SAI peripheral.
#define I2S_RCSR_FRF_MASK
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.
static void SAI_WriteNonBlocking(I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t endChannel, uint8_t bitWidth, uint8_t *buffer, uint32_t size)
sends a piece of data in non-blocking way.
#define I2S_RCR4_FCONT(x)
sai transceiver configurations
#define I2S_RCR2_BCI_MASK
void SAI_TransferTxHandleIRQ(I2S_Type *base, sai_handle_t *handle)
Tx interrupt handler.
sai_bclk_source_t bclkSource
static void CLOCK_EnableClock(clock_ip_name_t name)
Enable the clock for specific IP.
#define I2S_RCR4_FRSZ_MASK
#define I2S_TCR4_CHMOD(x)
#define FSL_FEATURE_SAI_FIFO_COUNT
#define I2S_RCSR_FWDE_MASK
#define I2S_RCR4_ONDEM_MASK
#define I2S_RCSR_FRDE_MASK
#define I2S_TCR2_DIV_MASK
void SAI_WriteBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
Sends data using a blocking method.
static const IRQn_Type s_saiTxIRQ[]
#define I2S_TCR4_ONDEM_MASK
#define FSL_FEATURE_SAI_CHANNEL_COUNTn(x)
void SAI_TransferRxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
Initializes the SAI Rx handle.
void SAI_TransferAbortReceive(I2S_Type *base, sai_handle_t *handle)
Aborts the current IRQ receive.
void SAI_ReadBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
Receives data using a blocking method.
void SAI_RxReset(I2S_Type *base)
Resets the SAI Rx.
SAI user configuration structure.
void SAI_RxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI receiver configurations.
void(* sai_rx_isr_t)(I2S_Type *base, sai_handle_t *saiHandle)
Typedef for sai rx interrupt handler.
void SAI_TxSetSerialDataConfig(I2S_Type *base, sai_serial_data_t *config)
SAI transmitter Serial data configurations.
#define I2S_TCR4_FCONT(x)
#define I2S_RCR2_BCS_MASK
void SAI_TransferTxSetConfig(I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
SAI transmitter transfer configurations.
static const clock_ip_name_t s_saiClock[]
#define I2S_TCR4_FSE_MASK
static void SAI_TxDisableInterrupts(I2S_Type *base, uint32_t mask)
Disables the SAI Tx interrupt requests.
#define I2S_RCR4_FSD_MASK
#define I2S_RCR4_FSP_MASK
#define I2S_TCSR_FRIE_MASK
#define I2S_TCR4_FRSZ_MASK
void SAI_TxSetBitClockPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Tx data order.
void SAI_TxSetFrameSyncConfig(I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
SAI transmitter Frame sync configurations.
sai_serial_data_t serialData
#define I2S_TCR3_WDFL_MASK
static void SAI_RxEnableInterrupts(I2S_Type *base, uint32_t mask)
Enables the SAI Rx interrupt requests.
static status_t EnableIRQ(IRQn_Type interrupt)
Enable specific interrupt.
#define I2S_TCSR_FWDE_MASK
sai_data_order_t dataOrder
#define I2S_TCR1_TFW_SHIFT
void SAI_RxInit(I2S_Type *base, const sai_config_t *config)
Initializes the SAI Rx peripheral.
#define I2S_RCR1_RFW_MASK
#define I2S_TCR4_FSP_MASK
#define I2S_TCR4_FCONT_MASK
#define I2S_RCR4_FPACK_MASK
#define I2S_RCR2_SYNC_SHIFT
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.
static void CLOCK_DisableClock(clock_ip_name_t name)
Disable the clock for specific IP.
static const IRQn_Type s_saiRxIRQ[]
void SAI_RxSetDataOrder(I2S_Type *base, sai_data_order_t order)
Set the Rx data order.
sai bit clock configurations
void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI transmitter configurations.
void SAI_RxSoftwareReset(I2S_Type *base, sai_reset_type_t type)
Do software reset or FIFO reset .
void SAI_RxSetBitClockRate(I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
Receiver bit clock rate configurations.
#define I2S_TCR4_ONDEM(x)
static void SAI_TxClearStatusFlags(I2S_Type *base, uint32_t mask)
Clears the SAI Tx status flag state.
volatile uint8_t queueUser
static sai_rx_isr_t s_saiRxIsr
Pointer to tx IRQ handler for each instance.
static sai_transceiver_t config
void SAI_TxReset(I2S_Type *base)
Resets the SAI Tx.
enum _clock_ip_name clock_ip_name_t
CCM CCGR gate control for each module independently.
#define I2S_TCR2_SYNC_MASK
#define I2S_TCR3_TCE_MASK
#define I2S_TCR2_BCP_MASK
void SAI_RxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
Set the Rx channel FIFO enable mask.
void SAI_TxSetDataOrder(I2S_Type *base, sai_data_order_t order)
Set the Tx data order.
void(* sai_transfer_callback_t)(I2S_Type *base, sai_handle_t *handle, status_t status, void *userData)
SAI transfer callback prototype.
int32_t status_t
Type used for all status and error return values.
#define I2S_RCR2_BCP_MASK
@ kSAI_FrameSyncLenPerWordWidth
void SAI_TxSetFormat(I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
Configures the SAI Tx audio format.
#define I2S_TCR2_SYNC_SHIFT
sai_clock_polarity_t bclkPolarity
void SAI_RxSetBitClockPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
Set the Rx data order.
#define I2S_TCR4_FSD_MASK
#define I2S_RCR4_ONDEM(x)
static void SAI_ReadNonBlocking(I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t endChannel, uint8_t bitWidth, uint8_t *buffer, uint32_t size)
Receive a piece of data in non-blocking way.
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.
#define I2S_TCR4_FPACK_MASK
void SAI_Init(I2S_Type *base)
Initializes the SAI peripheral.
void SAI_TxEnable(I2S_Type *base, bool enable)
Enables/disables the SAI Tx.
@ kSAI_SampleOnRisingEdge
status_t SAI_TransferSendNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
Performs an interrupt non-blocking send transfer on SAI.
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.
void SAI_TxGetDefaultConfig(sai_config_t *config)
Sets the SAI Tx configuration structure to default values.