fsl_sai.c 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include "fsl_sai.h"
  35. /* Component ID definition, used by tools. */
  36. #ifndef FSL_COMPONENT_ID
  37. #define FSL_COMPONENT_ID "platform.drivers.sai"
  38. #endif
  39. /*******************************************************************************
  40. * Definitations
  41. ******************************************************************************/
  42. enum _sai_transfer_state
  43. {
  44. kSAI_Busy = 0x0U, /*!< SAI is busy */
  45. kSAI_Idle, /*!< Transfer is done. */
  46. kSAI_Error /*!< Transfer error occured. */
  47. };
  48. /*! @brief Typedef for sai tx interrupt handler. */
  49. typedef void (*sai_tx_isr_t)(I2S_Type *base, sai_handle_t *saiHandle);
  50. /*! @brief Typedef for sai rx interrupt handler. */
  51. typedef void (*sai_rx_isr_t)(I2S_Type *base, sai_handle_t *saiHandle);
  52. /*******************************************************************************
  53. * Prototypes
  54. ******************************************************************************/
  55. #if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
  56. /*!
  57. * @brief Set the master clock divider.
  58. *
  59. * This API will compute the master clock divider according to master clock frequency and master
  60. * clock source clock source frequency.
  61. *
  62. * @param base SAI base pointer.
  63. * @param mclk_Hz Mater clock frequency in Hz.
  64. * @param mclkSrcClock_Hz Master clock source frequency in Hz.
  65. */
  66. static void SAI_SetMasterClockDivider(I2S_Type *base, uint32_t mclk_Hz, uint32_t mclkSrcClock_Hz);
  67. #endif /* FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER */
  68. /*!
  69. * @brief Get the instance number for SAI.
  70. *
  71. * @param base SAI base pointer.
  72. */
  73. static uint32_t SAI_GetInstance(I2S_Type *base);
  74. /*!
  75. * @brief sends a piece of data in non-blocking way.
  76. *
  77. * @param base SAI base pointer
  78. * @param channel Data channel used.
  79. * @param bitWidth How many bits in a audio word, usually 8/16/24/32 bits.
  80. * @param buffer Pointer to the data to be written.
  81. * @param size Bytes to be written.
  82. */
  83. static void SAI_WriteNonBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size);
  84. /*!
  85. * @brief Receive a piece of data in non-blocking way.
  86. *
  87. * @param base SAI base pointer
  88. * @param channel Data channel used.
  89. * @param bitWidth How many bits in a audio word, usually 8/16/24/32 bits.
  90. * @param buffer Pointer to the data to be read.
  91. * @param size Bytes to be read.
  92. */
  93. static void SAI_ReadNonBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size);
  94. /*******************************************************************************
  95. * Variables
  96. ******************************************************************************/
  97. /* Base pointer array */
  98. static I2S_Type *const s_saiBases[] = I2S_BASE_PTRS;
  99. /*!@brief SAI handle pointer */
  100. static sai_handle_t *s_saiHandle[ARRAY_SIZE(s_saiBases)][2];
  101. /* IRQ number array */
  102. static const IRQn_Type s_saiTxIRQ[] = I2S_TX_IRQS;
  103. static const IRQn_Type s_saiRxIRQ[] = I2S_RX_IRQS;
  104. #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
  105. /* Clock name array */
  106. static const clock_ip_name_t s_saiClock[] = SAI_CLOCKS;
  107. #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
  108. /*! @brief Pointer to tx IRQ handler for each instance. */
  109. static sai_tx_isr_t s_saiTxIsr;
  110. /*! @brief Pointer to tx IRQ handler for each instance. */
  111. static sai_rx_isr_t s_saiRxIsr;
  112. /*******************************************************************************
  113. * Code
  114. ******************************************************************************/
  115. #if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
  116. static void SAI_SetMasterClockDivider(I2S_Type *base, uint32_t mclk_Hz, uint32_t mclkSrcClock_Hz)
  117. {
  118. uint32_t freq = mclkSrcClock_Hz;
  119. uint16_t fract, divide;
  120. uint32_t remaind = 0;
  121. uint32_t current_remainder = 0xFFFFFFFFU;
  122. uint16_t current_fract = 0;
  123. uint16_t current_divide = 0;
  124. uint32_t mul_freq = 0;
  125. uint32_t max_fract = 256;
  126. /*In order to prevent overflow */
  127. freq /= 100;
  128. mclk_Hz /= 100;
  129. /* Compute the max fract number */
  130. max_fract = mclk_Hz * 4096 / freq + 1;
  131. if (max_fract > 256)
  132. {
  133. max_fract = 256;
  134. }
  135. /* Looking for the closet frequency */
  136. for (fract = 1; fract < max_fract; fract++)
  137. {
  138. mul_freq = freq * fract;
  139. remaind = mul_freq % mclk_Hz;
  140. divide = mul_freq / mclk_Hz;
  141. /* Find the exactly frequency */
  142. if (remaind == 0)
  143. {
  144. current_fract = fract;
  145. current_divide = mul_freq / mclk_Hz;
  146. break;
  147. }
  148. /* Closer to next one, set the closest to next data */
  149. if (remaind > mclk_Hz / 2)
  150. {
  151. remaind = mclk_Hz - remaind;
  152. divide += 1;
  153. }
  154. /* Update the closest div and fract */
  155. if (remaind < current_remainder)
  156. {
  157. current_fract = fract;
  158. current_divide = divide;
  159. current_remainder = remaind;
  160. }
  161. }
  162. /* Fill the computed fract and divider to registers */
  163. base->MDR = I2S_MDR_DIVIDE(current_divide - 1) | I2S_MDR_FRACT(current_fract - 1);
  164. /* Waiting for the divider updated */
  165. while (base->MCR & I2S_MCR_DUF_MASK)
  166. {
  167. }
  168. }
  169. #endif /* FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER */
  170. static uint32_t SAI_GetInstance(I2S_Type *base)
  171. {
  172. uint32_t instance;
  173. /* Find the instance index from base address mappings. */
  174. for (instance = 0; instance < ARRAY_SIZE(s_saiBases); instance++)
  175. {
  176. if (s_saiBases[instance] == base)
  177. {
  178. break;
  179. }
  180. }
  181. assert(instance < ARRAY_SIZE(s_saiBases));
  182. return instance;
  183. }
  184. static void SAI_WriteNonBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
  185. {
  186. uint32_t i = 0;
  187. uint8_t j = 0;
  188. uint8_t bytesPerWord = bitWidth / 8U;
  189. uint32_t data = 0;
  190. uint32_t temp = 0;
  191. for (i = 0; i < size / bytesPerWord; i++)
  192. {
  193. for (j = 0; j < bytesPerWord; j++)
  194. {
  195. temp = (uint32_t)(*buffer);
  196. data |= (temp << (8U * j));
  197. buffer++;
  198. }
  199. base->TDR[channel] = data;
  200. data = 0;
  201. }
  202. }
  203. static void SAI_ReadNonBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
  204. {
  205. uint32_t i = 0;
  206. uint8_t j = 0;
  207. uint8_t bytesPerWord = bitWidth / 8U;
  208. uint32_t data = 0;
  209. for (i = 0; i < size / bytesPerWord; i++)
  210. {
  211. data = base->RDR[channel];
  212. for (j = 0; j < bytesPerWord; j++)
  213. {
  214. *buffer = (data >> (8U * j)) & 0xFF;
  215. buffer++;
  216. }
  217. }
  218. }
  219. void SAI_TxInit(I2S_Type *base, const sai_config_t *config)
  220. {
  221. uint32_t val = 0;
  222. #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
  223. /* Enable the SAI clock */
  224. CLOCK_EnableClock(s_saiClock[SAI_GetInstance(base)]);
  225. #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
  226. #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
  227. /* Master clock source setting */
  228. val = (base->MCR & ~I2S_MCR_MICS_MASK);
  229. base->MCR = (val | I2S_MCR_MICS(config->mclkSource));
  230. /* Configure Master clock output enable */
  231. val = (base->MCR & ~I2S_MCR_MOE_MASK);
  232. base->MCR = (val | I2S_MCR_MOE(config->mclkOutputEnable));
  233. #endif /* FSL_FEATURE_SAI_HAS_MCR */
  234. SAI_TxReset(base);
  235. /* Configure audio protocol */
  236. switch (config->protocol)
  237. {
  238. case kSAI_BusLeftJustified:
  239. base->TCR2 |= I2S_TCR2_BCP_MASK;
  240. base->TCR3 &= ~I2S_TCR3_WDFL_MASK;
  241. base->TCR4 = I2S_TCR4_MF(1U) | I2S_TCR4_SYWD(31U) | I2S_TCR4_FSE(0U) | I2S_TCR4_FSP(0U) | I2S_TCR4_FRSZ(1U);
  242. break;
  243. case kSAI_BusRightJustified:
  244. base->TCR2 |= I2S_TCR2_BCP_MASK;
  245. base->TCR3 &= ~I2S_TCR3_WDFL_MASK;
  246. base->TCR4 = I2S_TCR4_MF(1U) | I2S_TCR4_SYWD(31U) | I2S_TCR4_FSE(0U) | I2S_TCR4_FSP(0U) | I2S_TCR4_FRSZ(1U);
  247. break;
  248. case kSAI_BusI2S:
  249. base->TCR2 |= I2S_TCR2_BCP_MASK;
  250. base->TCR3 &= ~I2S_TCR3_WDFL_MASK;
  251. base->TCR4 = I2S_TCR4_MF(1U) | I2S_TCR4_SYWD(31U) | I2S_TCR4_FSE(1U) | I2S_TCR4_FSP(1U) | I2S_TCR4_FRSZ(1U);
  252. break;
  253. case kSAI_BusPCMA:
  254. base->TCR2 &= ~I2S_TCR2_BCP_MASK;
  255. base->TCR3 &= ~I2S_TCR3_WDFL_MASK;
  256. base->TCR4 = I2S_TCR4_MF(1U) | I2S_TCR4_SYWD(0U) | I2S_TCR4_FSE(1U) | I2S_TCR4_FSP(0U) | I2S_TCR4_FRSZ(1U);
  257. break;
  258. case kSAI_BusPCMB:
  259. base->TCR2 &= ~I2S_TCR2_BCP_MASK;
  260. base->TCR3 &= ~I2S_TCR3_WDFL_MASK;
  261. base->TCR4 = I2S_TCR4_MF(1U) | I2S_TCR4_SYWD(0U) | I2S_TCR4_FSE(0U) | I2S_TCR4_FSP(0U) | I2S_TCR4_FRSZ(1U);
  262. break;
  263. default:
  264. break;
  265. }
  266. /* Set master or slave */
  267. if (config->masterSlave == kSAI_Master)
  268. {
  269. base->TCR2 |= I2S_TCR2_BCD_MASK;
  270. base->TCR4 |= I2S_TCR4_FSD_MASK;
  271. /* Bit clock source setting */
  272. val = base->TCR2 & (~I2S_TCR2_MSEL_MASK);
  273. base->TCR2 = (val | I2S_TCR2_MSEL(config->bclkSource));
  274. }
  275. else
  276. {
  277. base->TCR2 &= ~I2S_TCR2_BCD_MASK;
  278. base->TCR4 &= ~I2S_TCR4_FSD_MASK;
  279. }
  280. /* Set Sync mode */
  281. switch (config->syncMode)
  282. {
  283. case kSAI_ModeAsync:
  284. val = base->TCR2;
  285. val &= ~I2S_TCR2_SYNC_MASK;
  286. base->TCR2 = (val | I2S_TCR2_SYNC(0U));
  287. break;
  288. case kSAI_ModeSync:
  289. val = base->TCR2;
  290. val &= ~I2S_TCR2_SYNC_MASK;
  291. base->TCR2 = (val | I2S_TCR2_SYNC(1U));
  292. /* If sync with Rx, should set Rx to async mode */
  293. val = base->RCR2;
  294. val &= ~I2S_RCR2_SYNC_MASK;
  295. base->RCR2 = (val | I2S_RCR2_SYNC(0U));
  296. break;
  297. case kSAI_ModeSyncWithOtherTx:
  298. val = base->TCR2;
  299. val &= ~I2S_TCR2_SYNC_MASK;
  300. base->TCR2 = (val | I2S_TCR2_SYNC(2U));
  301. break;
  302. case kSAI_ModeSyncWithOtherRx:
  303. val = base->TCR2;
  304. val &= ~I2S_TCR2_SYNC_MASK;
  305. base->TCR2 = (val | I2S_TCR2_SYNC(3U));
  306. break;
  307. default:
  308. break;
  309. }
  310. #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
  311. SAI_TxSetFIFOErrorContinue(base, true);
  312. #endif /* FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR */
  313. }
  314. void SAI_RxInit(I2S_Type *base, const sai_config_t *config)
  315. {
  316. uint32_t val = 0;
  317. #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
  318. /* Enable SAI clock first. */
  319. CLOCK_EnableClock(s_saiClock[SAI_GetInstance(base)]);
  320. #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
  321. #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
  322. /* Master clock source setting */
  323. val = (base->MCR & ~I2S_MCR_MICS_MASK);
  324. base->MCR = (val | I2S_MCR_MICS(config->mclkSource));
  325. /* Configure Master clock output enable */
  326. val = (base->MCR & ~I2S_MCR_MOE_MASK);
  327. base->MCR = (val | I2S_MCR_MOE(config->mclkOutputEnable));
  328. #endif /* FSL_FEATURE_SAI_HAS_MCR */
  329. SAI_RxReset(base);
  330. /* Configure audio protocol */
  331. switch (config->protocol)
  332. {
  333. case kSAI_BusLeftJustified:
  334. base->RCR2 |= I2S_RCR2_BCP_MASK;
  335. base->RCR3 &= ~I2S_RCR3_WDFL_MASK;
  336. base->RCR4 = I2S_RCR4_MF(1U) | I2S_RCR4_SYWD(31U) | I2S_RCR4_FSE(0U) | I2S_RCR4_FSP(0U) | I2S_RCR4_FRSZ(1U);
  337. break;
  338. case kSAI_BusRightJustified:
  339. base->RCR2 |= I2S_RCR2_BCP_MASK;
  340. base->RCR3 &= ~I2S_RCR3_WDFL_MASK;
  341. base->RCR4 = I2S_RCR4_MF(1U) | I2S_RCR4_SYWD(31U) | I2S_RCR4_FSE(0U) | I2S_RCR4_FSP(0U) | I2S_RCR4_FRSZ(1U);
  342. break;
  343. case kSAI_BusI2S:
  344. base->RCR2 |= I2S_RCR2_BCP_MASK;
  345. base->RCR3 &= ~I2S_RCR3_WDFL_MASK;
  346. base->RCR4 = I2S_RCR4_MF(1U) | I2S_RCR4_SYWD(31U) | I2S_RCR4_FSE(1U) | I2S_RCR4_FSP(1U) | I2S_RCR4_FRSZ(1U);
  347. break;
  348. case kSAI_BusPCMA:
  349. base->RCR2 &= ~I2S_RCR2_BCP_MASK;
  350. base->RCR3 &= ~I2S_RCR3_WDFL_MASK;
  351. base->RCR4 = I2S_RCR4_MF(1U) | I2S_RCR4_SYWD(0U) | I2S_RCR4_FSE(1U) | I2S_RCR4_FSP(0U) | I2S_RCR4_FRSZ(1U);
  352. break;
  353. case kSAI_BusPCMB:
  354. base->RCR2 &= ~I2S_RCR2_BCP_MASK;
  355. base->RCR3 &= ~I2S_RCR3_WDFL_MASK;
  356. base->RCR4 = I2S_RCR4_MF(1U) | I2S_RCR4_SYWD(0U) | I2S_RCR4_FSE(0U) | I2S_RCR4_FSP(0U) | I2S_RCR4_FRSZ(1U);
  357. break;
  358. default:
  359. break;
  360. }
  361. /* Set master or slave */
  362. if (config->masterSlave == kSAI_Master)
  363. {
  364. base->RCR2 |= I2S_RCR2_BCD_MASK;
  365. base->RCR4 |= I2S_RCR4_FSD_MASK;
  366. /* Bit clock source setting */
  367. val = base->RCR2 & (~I2S_RCR2_MSEL_MASK);
  368. base->RCR2 = (val | I2S_RCR2_MSEL(config->bclkSource));
  369. }
  370. else
  371. {
  372. base->RCR2 &= ~I2S_RCR2_BCD_MASK;
  373. base->RCR4 &= ~I2S_RCR4_FSD_MASK;
  374. }
  375. /* Set Sync mode */
  376. switch (config->syncMode)
  377. {
  378. case kSAI_ModeAsync:
  379. val = base->RCR2;
  380. val &= ~I2S_RCR2_SYNC_MASK;
  381. base->RCR2 = (val | I2S_RCR2_SYNC(0U));
  382. break;
  383. case kSAI_ModeSync:
  384. val = base->RCR2;
  385. val &= ~I2S_RCR2_SYNC_MASK;
  386. base->RCR2 = (val | I2S_RCR2_SYNC(1U));
  387. /* If sync with Tx, should set Tx to async mode */
  388. val = base->TCR2;
  389. val &= ~I2S_TCR2_SYNC_MASK;
  390. base->TCR2 = (val | I2S_TCR2_SYNC(0U));
  391. break;
  392. case kSAI_ModeSyncWithOtherTx:
  393. val = base->RCR2;
  394. val &= ~I2S_RCR2_SYNC_MASK;
  395. base->RCR2 = (val | I2S_RCR2_SYNC(2U));
  396. break;
  397. case kSAI_ModeSyncWithOtherRx:
  398. val = base->RCR2;
  399. val &= ~I2S_RCR2_SYNC_MASK;
  400. base->RCR2 = (val | I2S_RCR2_SYNC(3U));
  401. break;
  402. default:
  403. break;
  404. }
  405. #if defined(FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR) && FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR
  406. SAI_RxSetFIFOErrorContinue(base, true);
  407. #endif /* FSL_FEATURE_SAI_HAS_FIFO_FUNCTION_AFTER_ERROR */
  408. }
  409. void SAI_Deinit(I2S_Type *base)
  410. {
  411. SAI_TxEnable(base, false);
  412. SAI_RxEnable(base, false);
  413. #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
  414. CLOCK_DisableClock(s_saiClock[SAI_GetInstance(base)]);
  415. #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
  416. }
  417. void SAI_TxGetDefaultConfig(sai_config_t *config)
  418. {
  419. config->bclkSource = kSAI_BclkSourceMclkDiv;
  420. config->masterSlave = kSAI_Master;
  421. config->mclkSource = kSAI_MclkSourceSysclk;
  422. config->protocol = kSAI_BusI2S;
  423. config->syncMode = kSAI_ModeAsync;
  424. #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
  425. config->mclkOutputEnable = true;
  426. #endif /* FSL_FEATURE_SAI_HAS_MCR */
  427. }
  428. void SAI_RxGetDefaultConfig(sai_config_t *config)
  429. {
  430. config->bclkSource = kSAI_BclkSourceMclkDiv;
  431. config->masterSlave = kSAI_Master;
  432. config->mclkSource = kSAI_MclkSourceSysclk;
  433. config->protocol = kSAI_BusI2S;
  434. config->syncMode = kSAI_ModeSync;
  435. #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)
  436. config->mclkOutputEnable = true;
  437. #endif /* FSL_FEATURE_SAI_HAS_MCR */
  438. }
  439. void SAI_TxReset(I2S_Type *base)
  440. {
  441. /* Set the software reset and FIFO reset to clear internal state */
  442. base->TCSR = I2S_TCSR_SR_MASK | I2S_TCSR_FR_MASK;
  443. /* Clear software reset bit, this should be done by software */
  444. base->TCSR &= ~I2S_TCSR_SR_MASK;
  445. /* Reset all Tx register values */
  446. base->TCR2 = 0;
  447. base->TCR3 = 0;
  448. base->TCR4 = 0;
  449. base->TCR5 = 0;
  450. base->TMR = 0;
  451. }
  452. void SAI_RxReset(I2S_Type *base)
  453. {
  454. /* Set the software reset and FIFO reset to clear internal state */
  455. base->RCSR = I2S_RCSR_SR_MASK | I2S_RCSR_FR_MASK;
  456. /* Clear software reset bit, this should be done by software */
  457. base->RCSR &= ~I2S_RCSR_SR_MASK;
  458. /* Reset all Rx register values */
  459. base->RCR2 = 0;
  460. base->RCR3 = 0;
  461. base->RCR4 = 0;
  462. base->RCR5 = 0;
  463. base->RMR = 0;
  464. }
  465. void SAI_TxEnable(I2S_Type *base, bool enable)
  466. {
  467. if (enable)
  468. {
  469. /* If clock is sync with Rx, should enable RE bit. */
  470. if (((base->TCR2 & I2S_TCR2_SYNC_MASK) >> I2S_TCR2_SYNC_SHIFT) == 0x1U)
  471. {
  472. base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | I2S_RCSR_RE_MASK);
  473. }
  474. base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | I2S_TCSR_TE_MASK);
  475. /* Also need to clear the FIFO error flag before start */
  476. SAI_TxClearStatusFlags(base, kSAI_FIFOErrorFlag);
  477. }
  478. else
  479. {
  480. /* If RE not sync with TE, than disable TE, otherwise, shall not disable TE */
  481. if (((base->RCR2 & I2S_RCR2_SYNC_MASK) >> I2S_RCR2_SYNC_SHIFT) != 0x1U)
  482. {
  483. /* Should not close RE even sync with Rx */
  484. base->TCSR = ((base->TCSR & 0xFFE3FFFFU) & (~I2S_TCSR_TE_MASK));
  485. }
  486. }
  487. }
  488. void SAI_RxEnable(I2S_Type *base, bool enable)
  489. {
  490. if (enable)
  491. {
  492. /* If clock is sync with Tx, should enable TE bit. */
  493. if (((base->RCR2 & I2S_RCR2_SYNC_MASK) >> I2S_RCR2_SYNC_SHIFT) == 0x1U)
  494. {
  495. base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | I2S_TCSR_TE_MASK);
  496. }
  497. base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | I2S_RCSR_RE_MASK);
  498. /* Also need to clear the FIFO error flag before start */
  499. SAI_RxClearStatusFlags(base, kSAI_FIFOErrorFlag);
  500. }
  501. else
  502. {
  503. /* While TX is not sync with RX, close RX */
  504. if (((base->TCR2 & I2S_TCR2_SYNC_MASK) >> I2S_TCR2_SYNC_SHIFT) != 0x1U)
  505. {
  506. base->RCSR = ((base->RCSR & 0xFFE3FFFFU) & (~I2S_RCSR_RE_MASK));
  507. }
  508. }
  509. }
  510. void SAI_TxSoftwareReset(I2S_Type *base, sai_reset_type_t type)
  511. {
  512. base->TCSR |= (uint32_t)type;
  513. /* Clear the software reset */
  514. base->TCSR &= ~I2S_TCSR_SR_MASK;
  515. }
  516. void SAI_RxSoftwareReset(I2S_Type *base, sai_reset_type_t type)
  517. {
  518. base->RCSR |= (uint32_t)type;
  519. /* Clear the software reset */
  520. base->RCSR &= ~I2S_RCSR_SR_MASK;
  521. }
  522. void SAI_TxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
  523. {
  524. base->TCR3 &= ~I2S_TCR3_TCE_MASK;
  525. base->TCR3 |= I2S_TCR3_TCE(mask);
  526. }
  527. void SAI_RxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
  528. {
  529. base->RCR3 &= ~I2S_RCR3_RCE_MASK;
  530. base->RCR3 |= I2S_RCR3_RCE(mask);
  531. }
  532. void SAI_TxSetDataOrder(I2S_Type *base, sai_data_order_t order)
  533. {
  534. uint32_t val = (base->TCR4) & (~I2S_TCR4_MF_MASK);
  535. val |= I2S_TCR4_MF(order);
  536. base->TCR4 = val;
  537. }
  538. void SAI_RxSetDataOrder(I2S_Type *base, sai_data_order_t order)
  539. {
  540. uint32_t val = (base->RCR4) & (~I2S_RCR4_MF_MASK);
  541. val |= I2S_RCR4_MF(order);
  542. base->RCR4 = val;
  543. }
  544. void SAI_TxSetBitClockPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
  545. {
  546. uint32_t val = (base->TCR2) & (~I2S_TCR2_BCP_MASK);
  547. val |= I2S_TCR2_BCP(polarity);
  548. base->TCR2 = val;
  549. }
  550. void SAI_RxSetBitClockPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
  551. {
  552. uint32_t val = (base->RCR2) & (~I2S_RCR2_BCP_MASK);
  553. val |= I2S_RCR2_BCP(polarity);
  554. base->RCR2 = val;
  555. }
  556. void SAI_TxSetFrameSyncPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
  557. {
  558. uint32_t val = (base->TCR4) & (~I2S_TCR4_FSP_MASK);
  559. val |= I2S_TCR4_FSP(polarity);
  560. base->TCR4 = val;
  561. }
  562. void SAI_RxSetFrameSyncPolarity(I2S_Type *base, sai_clock_polarity_t polarity)
  563. {
  564. uint32_t val = (base->RCR4) & (~I2S_RCR4_FSP_MASK);
  565. val |= I2S_RCR4_FSP(polarity);
  566. base->RCR4 = val;
  567. }
  568. #if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING
  569. void SAI_TxSetFIFOPacking(I2S_Type *base, sai_fifo_packing_t pack)
  570. {
  571. uint32_t val = base->TCR4;
  572. val &= ~I2S_TCR4_FPACK_MASK;
  573. val |= I2S_TCR4_FPACK(pack);
  574. base->TCR4 = val;
  575. }
  576. void SAI_RxSetFIFOPacking(I2S_Type *base, sai_fifo_packing_t pack)
  577. {
  578. uint32_t val = base->RCR4;
  579. val &= ~I2S_RCR4_FPACK_MASK;
  580. val |= I2S_RCR4_FPACK(pack);
  581. base->RCR4 = val;
  582. }
  583. #endif /* FSL_FEATURE_SAI_HAS_FIFO_PACKING */
  584. void SAI_TxSetFormat(I2S_Type *base,
  585. sai_transfer_format_t *format,
  586. uint32_t mclkSourceClockHz,
  587. uint32_t bclkSourceClockHz)
  588. {
  589. uint32_t bclk = 0;
  590. uint32_t val = 0;
  591. uint32_t channels = 2U;
  592. if (format->stereo != kSAI_Stereo)
  593. {
  594. channels = 1U;
  595. }
  596. if (format->isFrameSyncCompact)
  597. {
  598. bclk = format->sampleRate_Hz * format->bitWidth * channels;
  599. val = (base->TCR4 & (~I2S_TCR4_SYWD_MASK));
  600. val |= I2S_TCR4_SYWD(format->bitWidth - 1U);
  601. base->TCR4 = val;
  602. }
  603. else
  604. {
  605. bclk = format->sampleRate_Hz * 32U * 2U;
  606. }
  607. /* Compute the mclk */
  608. #if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
  609. /* Check if master clock divider enabled, then set master clock divider */
  610. if (base->MCR & I2S_MCR_MOE_MASK)
  611. {
  612. SAI_SetMasterClockDivider(base, format->masterClockHz, mclkSourceClockHz);
  613. }
  614. #endif /* FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER */
  615. /* Set bclk if needed */
  616. if (base->TCR2 & I2S_TCR2_BCD_MASK)
  617. {
  618. base->TCR2 &= ~I2S_TCR2_DIV_MASK;
  619. base->TCR2 |= I2S_TCR2_DIV((bclkSourceClockHz / bclk) / 2U - 1U);
  620. }
  621. /* Set bitWidth */
  622. val = (format->isFrameSyncCompact) ? (format->bitWidth - 1) : 31U;
  623. if (format->protocol == kSAI_BusRightJustified)
  624. {
  625. base->TCR5 = I2S_TCR5_WNW(val) | I2S_TCR5_W0W(val) | I2S_TCR5_FBT(val);
  626. }
  627. else
  628. {
  629. if (base->TCR4 & I2S_TCR4_MF_MASK)
  630. {
  631. base->TCR5 = I2S_TCR5_WNW(val) | I2S_TCR5_W0W(val) | I2S_TCR5_FBT(format->bitWidth - 1);
  632. }
  633. else
  634. {
  635. base->TCR5 = I2S_TCR5_WNW(val) | I2S_TCR5_W0W(val) | I2S_TCR5_FBT(0);
  636. }
  637. }
  638. /* Set mono or stereo */
  639. base->TMR = (uint32_t)format->stereo;
  640. /* Set data channel */
  641. base->TCR3 &= ~I2S_TCR3_TCE_MASK;
  642. base->TCR3 |= I2S_TCR3_TCE(1U << format->channel);
  643. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  644. /* Set watermark */
  645. base->TCR1 = format->watermark;
  646. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  647. }
  648. void SAI_RxSetFormat(I2S_Type *base,
  649. sai_transfer_format_t *format,
  650. uint32_t mclkSourceClockHz,
  651. uint32_t bclkSourceClockHz)
  652. {
  653. uint32_t bclk = 0;
  654. uint32_t val = 0;
  655. uint32_t channels = 2U;
  656. if (format->stereo != kSAI_Stereo)
  657. {
  658. channels = 1U;
  659. }
  660. if (format->isFrameSyncCompact)
  661. {
  662. bclk = format->sampleRate_Hz * format->bitWidth * channels;
  663. val = (base->RCR4 & (~I2S_RCR4_SYWD_MASK));
  664. val |= I2S_RCR4_SYWD(format->bitWidth - 1U);
  665. base->RCR4 = val;
  666. }
  667. else
  668. {
  669. bclk = format->sampleRate_Hz * 32U * 2U;
  670. }
  671. /* Compute the mclk */
  672. #if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
  673. /* Check if master clock divider enabled */
  674. if (base->MCR & I2S_MCR_MOE_MASK)
  675. {
  676. SAI_SetMasterClockDivider(base, format->masterClockHz, mclkSourceClockHz);
  677. }
  678. #endif /* FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER */
  679. /* Set bclk if needed */
  680. if (base->RCR2 & I2S_RCR2_BCD_MASK)
  681. {
  682. base->RCR2 &= ~I2S_RCR2_DIV_MASK;
  683. base->RCR2 |= I2S_RCR2_DIV((bclkSourceClockHz / bclk) / 2U - 1U);
  684. }
  685. /* Set bitWidth */
  686. val = (format->isFrameSyncCompact) ? (format->bitWidth - 1) : 31U;
  687. if (format->protocol == kSAI_BusRightJustified)
  688. {
  689. base->RCR5 = I2S_RCR5_WNW(val) | I2S_RCR5_W0W(val) | I2S_RCR5_FBT(val);
  690. }
  691. else
  692. {
  693. if (base->RCR4 & I2S_RCR4_MF_MASK)
  694. {
  695. base->RCR5 = I2S_RCR5_WNW(val) | I2S_RCR5_W0W(val) | I2S_RCR5_FBT(format->bitWidth - 1);
  696. }
  697. else
  698. {
  699. base->RCR5 = I2S_RCR5_WNW(val) | I2S_RCR5_W0W(val) | I2S_RCR5_FBT(0);
  700. }
  701. }
  702. /* Set mono or stereo */
  703. base->RMR = (uint32_t)format->stereo;
  704. /* Set data channel */
  705. base->RCR3 &= ~I2S_RCR3_RCE_MASK;
  706. base->RCR3 |= I2S_RCR3_RCE(1U << format->channel);
  707. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  708. /* Set watermark */
  709. base->RCR1 = format->watermark;
  710. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  711. }
  712. void SAI_WriteBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
  713. {
  714. uint32_t i = 0;
  715. uint8_t bytesPerWord = bitWidth / 8U;
  716. while (i < size)
  717. {
  718. /* Wait until it can write data */
  719. while (!(base->TCSR & I2S_TCSR_FWF_MASK))
  720. {
  721. }
  722. SAI_WriteNonBlocking(base, channel, bitWidth, buffer, bytesPerWord);
  723. buffer += bytesPerWord;
  724. i += bytesPerWord;
  725. }
  726. /* Wait until the last data is sent */
  727. while (!(base->TCSR & I2S_TCSR_FWF_MASK))
  728. {
  729. }
  730. }
  731. void SAI_ReadBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
  732. {
  733. uint32_t i = 0;
  734. uint8_t bytesPerWord = bitWidth / 8U;
  735. while (i < size)
  736. {
  737. /* Wait until data is received */
  738. while (!(base->RCSR & I2S_RCSR_FWF_MASK))
  739. {
  740. }
  741. SAI_ReadNonBlocking(base, channel, bitWidth, buffer, bytesPerWord);
  742. buffer += bytesPerWord;
  743. i += bytesPerWord;
  744. }
  745. }
  746. void SAI_TransferTxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
  747. {
  748. assert(handle);
  749. /* Zero the handle */
  750. memset(handle, 0, sizeof(*handle));
  751. s_saiHandle[SAI_GetInstance(base)][0] = handle;
  752. handle->callback = callback;
  753. handle->userData = userData;
  754. /* Set the isr pointer */
  755. s_saiTxIsr = SAI_TransferTxHandleIRQ;
  756. /* Enable Tx irq */
  757. EnableIRQ(s_saiTxIRQ[SAI_GetInstance(base)]);
  758. }
  759. void SAI_TransferRxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
  760. {
  761. assert(handle);
  762. /* Zero the handle */
  763. memset(handle, 0, sizeof(*handle));
  764. s_saiHandle[SAI_GetInstance(base)][1] = handle;
  765. handle->callback = callback;
  766. handle->userData = userData;
  767. /* Set the isr pointer */
  768. s_saiRxIsr = SAI_TransferRxHandleIRQ;
  769. /* Enable Rx irq */
  770. EnableIRQ(s_saiRxIRQ[SAI_GetInstance(base)]);
  771. }
  772. status_t SAI_TransferTxSetFormat(I2S_Type *base,
  773. sai_handle_t *handle,
  774. sai_transfer_format_t *format,
  775. uint32_t mclkSourceClockHz,
  776. uint32_t bclkSourceClockHz)
  777. {
  778. assert(handle);
  779. if ((mclkSourceClockHz < format->sampleRate_Hz) || (bclkSourceClockHz < format->sampleRate_Hz))
  780. {
  781. return kStatus_InvalidArgument;
  782. }
  783. /* Copy format to handle */
  784. handle->bitWidth = format->bitWidth;
  785. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  786. handle->watermark = format->watermark;
  787. #endif
  788. handle->channel = format->channel;
  789. SAI_TxSetFormat(base, format, mclkSourceClockHz, bclkSourceClockHz);
  790. return kStatus_Success;
  791. }
  792. status_t SAI_TransferRxSetFormat(I2S_Type *base,
  793. sai_handle_t *handle,
  794. sai_transfer_format_t *format,
  795. uint32_t mclkSourceClockHz,
  796. uint32_t bclkSourceClockHz)
  797. {
  798. assert(handle);
  799. if ((mclkSourceClockHz < format->sampleRate_Hz) || (bclkSourceClockHz < format->sampleRate_Hz))
  800. {
  801. return kStatus_InvalidArgument;
  802. }
  803. /* Copy format to handle */
  804. handle->bitWidth = format->bitWidth;
  805. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  806. handle->watermark = format->watermark;
  807. #endif
  808. handle->channel = format->channel;
  809. SAI_RxSetFormat(base, format, mclkSourceClockHz, bclkSourceClockHz);
  810. return kStatus_Success;
  811. }
  812. status_t SAI_TransferSendNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
  813. {
  814. assert(handle);
  815. /* Check if the queue is full */
  816. if (handle->saiQueue[handle->queueUser].data)
  817. {
  818. return kStatus_SAI_QueueFull;
  819. }
  820. /* Add into queue */
  821. handle->transferSize[handle->queueUser] = xfer->dataSize;
  822. handle->saiQueue[handle->queueUser].data = xfer->data;
  823. handle->saiQueue[handle->queueUser].dataSize = xfer->dataSize;
  824. handle->queueUser = (handle->queueUser + 1) % SAI_XFER_QUEUE_SIZE;
  825. /* Set the state to busy */
  826. handle->state = kSAI_Busy;
  827. /* Enable interrupt */
  828. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  829. /* Use FIFO request interrupt and fifo error*/
  830. SAI_TxEnableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFORequestInterruptEnable);
  831. #else
  832. SAI_TxEnableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFOWarningInterruptEnable);
  833. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  834. /* Enable Tx transfer */
  835. SAI_TxEnable(base, true);
  836. return kStatus_Success;
  837. }
  838. status_t SAI_TransferReceiveNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
  839. {
  840. assert(handle);
  841. /* Check if the queue is full */
  842. if (handle->saiQueue[handle->queueUser].data)
  843. {
  844. return kStatus_SAI_QueueFull;
  845. }
  846. /* Add into queue */
  847. handle->transferSize[handle->queueUser] = xfer->dataSize;
  848. handle->saiQueue[handle->queueUser].data = xfer->data;
  849. handle->saiQueue[handle->queueUser].dataSize = xfer->dataSize;
  850. handle->queueUser = (handle->queueUser + 1) % SAI_XFER_QUEUE_SIZE;
  851. /* Set state to busy */
  852. handle->state = kSAI_Busy;
  853. /* Enable interrupt */
  854. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  855. /* Use FIFO request interrupt and fifo error*/
  856. SAI_RxEnableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFORequestInterruptEnable);
  857. #else
  858. SAI_RxEnableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFOWarningInterruptEnable);
  859. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  860. /* Enable Rx transfer */
  861. SAI_RxEnable(base, true);
  862. return kStatus_Success;
  863. }
  864. status_t SAI_TransferGetSendCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
  865. {
  866. assert(handle);
  867. status_t status = kStatus_Success;
  868. if (handle->state != kSAI_Busy)
  869. {
  870. status = kStatus_NoTransferInProgress;
  871. }
  872. else
  873. {
  874. *count = (handle->transferSize[handle->queueDriver] - handle->saiQueue[handle->queueDriver].dataSize);
  875. }
  876. return status;
  877. }
  878. status_t SAI_TransferGetReceiveCount(I2S_Type *base, sai_handle_t *handle, size_t *count)
  879. {
  880. assert(handle);
  881. status_t status = kStatus_Success;
  882. if (handle->state != kSAI_Busy)
  883. {
  884. status = kStatus_NoTransferInProgress;
  885. }
  886. else
  887. {
  888. *count = (handle->transferSize[handle->queueDriver] - handle->saiQueue[handle->queueDriver].dataSize);
  889. }
  890. return status;
  891. }
  892. void SAI_TransferAbortSend(I2S_Type *base, sai_handle_t *handle)
  893. {
  894. assert(handle);
  895. /* Stop Tx transfer and disable interrupt */
  896. SAI_TxEnable(base, false);
  897. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  898. /* Use FIFO request interrupt and fifo error */
  899. SAI_TxDisableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFORequestInterruptEnable);
  900. #else
  901. SAI_TxDisableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFOWarningInterruptEnable);
  902. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  903. handle->state = kSAI_Idle;
  904. /* Clear the queue */
  905. memset(handle->saiQueue, 0, sizeof(sai_transfer_t) * SAI_XFER_QUEUE_SIZE);
  906. handle->queueDriver = 0;
  907. handle->queueUser = 0;
  908. }
  909. void SAI_TransferAbortReceive(I2S_Type *base, sai_handle_t *handle)
  910. {
  911. assert(handle);
  912. /* Stop Tx transfer and disable interrupt */
  913. SAI_RxEnable(base, false);
  914. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  915. /* Use FIFO request interrupt and fifo error */
  916. SAI_RxDisableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFORequestInterruptEnable);
  917. #else
  918. SAI_RxDisableInterrupts(base, kSAI_FIFOErrorInterruptEnable | kSAI_FIFOWarningInterruptEnable);
  919. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  920. handle->state = kSAI_Idle;
  921. /* Clear the queue */
  922. memset(handle->saiQueue, 0, sizeof(sai_transfer_t) * SAI_XFER_QUEUE_SIZE);
  923. handle->queueDriver = 0;
  924. handle->queueUser = 0;
  925. }
  926. void SAI_TransferTerminateSend(I2S_Type *base, sai_handle_t *handle)
  927. {
  928. assert(handle);
  929. /* Abort the current transfer */
  930. SAI_TransferAbortSend(base, handle);
  931. /* Clear all the internal information */
  932. memset(handle->saiQueue, 0U, sizeof(handle->saiQueue));
  933. memset(handle->transferSize, 0U, sizeof(handle->transferSize));
  934. handle->queueUser = 0U;
  935. handle->queueDriver = 0U;
  936. }
  937. void SAI_TransferTerminateReceive(I2S_Type *base, sai_handle_t *handle)
  938. {
  939. assert(handle);
  940. /* Abort the current transfer */
  941. SAI_TransferAbortReceive(base, handle);
  942. /* Clear all the internal information */
  943. memset(handle->saiQueue, 0U, sizeof(handle->saiQueue));
  944. memset(handle->transferSize, 0U, sizeof(handle->transferSize));
  945. handle->queueUser = 0U;
  946. handle->queueDriver = 0U;
  947. }
  948. void SAI_TransferTxHandleIRQ(I2S_Type *base, sai_handle_t *handle)
  949. {
  950. assert(handle);
  951. uint8_t *buffer = handle->saiQueue[handle->queueDriver].data;
  952. uint8_t dataSize = handle->bitWidth / 8U;
  953. /* Handle Error */
  954. if (base->TCSR & I2S_TCSR_FEF_MASK)
  955. {
  956. /* Clear FIFO error flag to continue transfer */
  957. SAI_TxClearStatusFlags(base, kSAI_FIFOErrorFlag);
  958. /* Reset FIFO for safety */
  959. SAI_TxSoftwareReset(base, kSAI_ResetTypeFIFO);
  960. /* Call the callback */
  961. if (handle->callback)
  962. {
  963. (handle->callback)(base, handle, kStatus_SAI_TxError, handle->userData);
  964. }
  965. }
  966. /* Handle transfer */
  967. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  968. if (base->TCSR & I2S_TCSR_FRF_MASK)
  969. {
  970. /* Judge if the data need to transmit is less than space */
  971. uint8_t size = MIN((handle->saiQueue[handle->queueDriver].dataSize),
  972. (size_t)((FSL_FEATURE_SAI_FIFO_COUNT - handle->watermark) * dataSize));
  973. /* Copy the data from sai buffer to FIFO */
  974. SAI_WriteNonBlocking(base, handle->channel, handle->bitWidth, buffer, size);
  975. /* Update the internal counter */
  976. handle->saiQueue[handle->queueDriver].dataSize -= size;
  977. handle->saiQueue[handle->queueDriver].data += size;
  978. }
  979. #else
  980. if (base->TCSR & I2S_TCSR_FWF_MASK)
  981. {
  982. uint8_t size = MIN((handle->saiQueue[handle->queueDriver].dataSize), dataSize);
  983. SAI_WriteNonBlocking(base, handle->channel, handle->bitWidth, buffer, size);
  984. /* Update internal counter */
  985. handle->saiQueue[handle->queueDriver].dataSize -= size;
  986. handle->saiQueue[handle->queueDriver].data += size;
  987. }
  988. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  989. /* If finished a blcok, call the callback function */
  990. if (handle->saiQueue[handle->queueDriver].dataSize == 0U)
  991. {
  992. memset(&handle->saiQueue[handle->queueDriver], 0, sizeof(sai_transfer_t));
  993. handle->queueDriver = (handle->queueDriver + 1) % SAI_XFER_QUEUE_SIZE;
  994. if (handle->callback)
  995. {
  996. (handle->callback)(base, handle, kStatus_SAI_TxIdle, handle->userData);
  997. }
  998. }
  999. /* If all data finished, just stop the transfer */
  1000. if (handle->saiQueue[handle->queueDriver].data == NULL)
  1001. {
  1002. SAI_TransferAbortSend(base, handle);
  1003. }
  1004. }
  1005. void SAI_TransferRxHandleIRQ(I2S_Type *base, sai_handle_t *handle)
  1006. {
  1007. assert(handle);
  1008. uint8_t *buffer = handle->saiQueue[handle->queueDriver].data;
  1009. uint8_t dataSize = handle->bitWidth / 8U;
  1010. /* Handle Error */
  1011. if (base->RCSR & I2S_RCSR_FEF_MASK)
  1012. {
  1013. /* Clear FIFO error flag to continue transfer */
  1014. SAI_RxClearStatusFlags(base, kSAI_FIFOErrorFlag);
  1015. /* Reset FIFO for safety */
  1016. SAI_RxSoftwareReset(base, kSAI_ResetTypeFIFO);
  1017. /* Call the callback */
  1018. if (handle->callback)
  1019. {
  1020. (handle->callback)(base, handle, kStatus_SAI_RxError, handle->userData);
  1021. }
  1022. }
  1023. /* Handle transfer */
  1024. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1025. if (base->RCSR & I2S_RCSR_FRF_MASK)
  1026. {
  1027. /* Judge if the data need to transmit is less than space */
  1028. uint8_t size = MIN((handle->saiQueue[handle->queueDriver].dataSize), (handle->watermark * dataSize));
  1029. /* Copy the data from sai buffer to FIFO */
  1030. SAI_ReadNonBlocking(base, handle->channel, handle->bitWidth, buffer, size);
  1031. /* Update the internal counter */
  1032. handle->saiQueue[handle->queueDriver].dataSize -= size;
  1033. handle->saiQueue[handle->queueDriver].data += size;
  1034. }
  1035. #else
  1036. if (base->RCSR & I2S_RCSR_FWF_MASK)
  1037. {
  1038. uint8_t size = MIN((handle->saiQueue[handle->queueDriver].dataSize), dataSize);
  1039. SAI_ReadNonBlocking(base, handle->channel, handle->bitWidth, buffer, size);
  1040. /* Update internal state */
  1041. handle->saiQueue[handle->queueDriver].dataSize -= size;
  1042. handle->saiQueue[handle->queueDriver].data += size;
  1043. }
  1044. #endif /* FSL_FEATURE_SAI_FIFO_COUNT */
  1045. /* If finished a blcok, call the callback function */
  1046. if (handle->saiQueue[handle->queueDriver].dataSize == 0U)
  1047. {
  1048. memset(&handle->saiQueue[handle->queueDriver], 0, sizeof(sai_transfer_t));
  1049. handle->queueDriver = (handle->queueDriver + 1) % SAI_XFER_QUEUE_SIZE;
  1050. if (handle->callback)
  1051. {
  1052. (handle->callback)(base, handle, kStatus_SAI_RxIdle, handle->userData);
  1053. }
  1054. }
  1055. /* If all data finished, just stop the transfer */
  1056. if (handle->saiQueue[handle->queueDriver].data == NULL)
  1057. {
  1058. SAI_TransferAbortReceive(base, handle);
  1059. }
  1060. }
  1061. #if defined(I2S0)
  1062. void I2S0_DriverIRQHandler(void)
  1063. {
  1064. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1065. if ((s_saiHandle[0][1]) && ((I2S0->RCSR & kSAI_FIFORequestFlag) || (I2S0->RCSR & kSAI_FIFOErrorFlag)) &&
  1066. ((I2S0->RCSR & kSAI_FIFORequestInterruptEnable) || (I2S0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1067. #else
  1068. if ((s_saiHandle[0][1]) && ((I2S0->RCSR & kSAI_FIFOWarningFlag) || (I2S0->RCSR & kSAI_FIFOErrorFlag)) &&
  1069. ((I2S0->RCSR & kSAI_FIFOWarningInterruptEnable) || (I2S0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1070. #endif
  1071. {
  1072. s_saiRxIsr(I2S0, s_saiHandle[0][1]);
  1073. }
  1074. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1075. if ((s_saiHandle[0][0]) && ((I2S0->TCSR & kSAI_FIFORequestFlag) || (I2S0->TCSR & kSAI_FIFOErrorFlag)) &&
  1076. ((I2S0->TCSR & kSAI_FIFORequestInterruptEnable) || (I2S0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1077. #else
  1078. if ((s_saiHandle[0][0]) && ((I2S0->TCSR & kSAI_FIFOWarningFlag) || (I2S0->TCSR & kSAI_FIFOErrorFlag)) &&
  1079. ((I2S0->TCSR & kSAI_FIFOWarningInterruptEnable) || (I2S0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1080. #endif
  1081. {
  1082. s_saiTxIsr(I2S0, s_saiHandle[0][0]);
  1083. }
  1084. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1085. exception return operation might vector to incorrect interrupt */
  1086. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1087. __DSB();
  1088. #endif
  1089. }
  1090. void I2S0_Tx_DriverIRQHandler(void)
  1091. {
  1092. assert(s_saiHandle[0][0]);
  1093. s_saiTxIsr(I2S0, s_saiHandle[0][0]);
  1094. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1095. exception return operation might vector to incorrect interrupt */
  1096. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1097. __DSB();
  1098. #endif
  1099. }
  1100. void I2S0_Rx_DriverIRQHandler(void)
  1101. {
  1102. assert(s_saiHandle[0][1]);
  1103. s_saiRxIsr(I2S0, s_saiHandle[0][1]);
  1104. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1105. exception return operation might vector to incorrect interrupt */
  1106. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1107. __DSB();
  1108. #endif
  1109. }
  1110. #endif /* I2S0*/
  1111. #if defined(I2S1)
  1112. void I2S1_DriverIRQHandler(void)
  1113. {
  1114. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1115. if ((s_saiHandle[1][1]) && ((I2S1->RCSR & kSAI_FIFORequestFlag) || (I2S1->RCSR & kSAI_FIFOErrorFlag)) &&
  1116. ((I2S1->RCSR & kSAI_FIFORequestInterruptEnable) || (I2S1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1117. #else
  1118. if ((s_saiHandle[1][1]) && ((I2S1->RCSR & kSAI_FIFOWarningFlag) || (I2S1->RCSR & kSAI_FIFOErrorFlag)) &&
  1119. ((I2S1->RCSR & kSAI_FIFOWarningInterruptEnable) || (I2S1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1120. #endif
  1121. {
  1122. s_saiRxIsr(I2S1, s_saiHandle[1][1]);
  1123. }
  1124. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1125. if ((s_saiHandle[1][0]) && ((I2S1->TCSR & kSAI_FIFORequestFlag) || (I2S1->TCSR & kSAI_FIFOErrorFlag)) &&
  1126. ((I2S1->TCSR & kSAI_FIFORequestInterruptEnable) || (I2S1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1127. #else
  1128. if ((s_saiHandle[1][0]) && ((I2S1->TCSR & kSAI_FIFOWarningFlag) || (I2S1->TCSR & kSAI_FIFOErrorFlag)) &&
  1129. ((I2S1->TCSR & kSAI_FIFOWarningInterruptEnable) || (I2S1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1130. #endif
  1131. {
  1132. s_saiTxIsr(I2S1, s_saiHandle[1][0]);
  1133. }
  1134. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1135. exception return operation might vector to incorrect interrupt */
  1136. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1137. __DSB();
  1138. #endif
  1139. }
  1140. void I2S1_Tx_DriverIRQHandler(void)
  1141. {
  1142. assert(s_saiHandle[1][0]);
  1143. s_saiTxIsr(I2S1, s_saiHandle[1][0]);
  1144. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1145. exception return operation might vector to incorrect interrupt */
  1146. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1147. __DSB();
  1148. #endif
  1149. }
  1150. void I2S1_Rx_DriverIRQHandler(void)
  1151. {
  1152. assert(s_saiHandle[1][1]);
  1153. s_saiRxIsr(I2S1, s_saiHandle[1][1]);
  1154. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1155. exception return operation might vector to incorrect interrupt */
  1156. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1157. __DSB();
  1158. #endif
  1159. }
  1160. #endif /* I2S1*/
  1161. #if defined(I2S2)
  1162. void I2S2_DriverIRQHandler(void)
  1163. {
  1164. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1165. if ((s_saiHandle[2][1]) && ((I2S2->RCSR & kSAI_FIFORequestFlag) || (I2S2->RCSR & kSAI_FIFOErrorFlag)) &&
  1166. ((I2S2->RCSR & kSAI_FIFORequestInterruptEnable) || (I2S2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1167. #else
  1168. if ((s_saiHandle[2][1]) && ((I2S2->RCSR & kSAI_FIFOWarningFlag) || (I2S2->RCSR & kSAI_FIFOErrorFlag)) &&
  1169. ((I2S2->RCSR & kSAI_FIFOWarningInterruptEnable) || (I2S2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1170. #endif
  1171. {
  1172. s_saiRxIsr(I2S2, s_saiHandle[2][1]);
  1173. }
  1174. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1175. if ((s_saiHandle[2][0]) && ((I2S2->TCSR & kSAI_FIFORequestFlag) || (I2S2->TCSR & kSAI_FIFOErrorFlag)) &&
  1176. ((I2S2->TCSR & kSAI_FIFORequestInterruptEnable) || (I2S2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1177. #else
  1178. if ((s_saiHandle[2][0]) && ((I2S2->TCSR & kSAI_FIFOWarningFlag) || (I2S2->TCSR & kSAI_FIFOErrorFlag)) &&
  1179. ((I2S2->TCSR & kSAI_FIFOWarningInterruptEnable) || (I2S2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1180. #endif
  1181. {
  1182. s_saiTxIsr(I2S2, s_saiHandle[2][0]);
  1183. }
  1184. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1185. exception return operation might vector to incorrect interrupt */
  1186. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1187. __DSB();
  1188. #endif
  1189. }
  1190. void I2S2_Tx_DriverIRQHandler(void)
  1191. {
  1192. assert(s_saiHandle[2][0]);
  1193. s_saiTxIsr(I2S2, s_saiHandle[2][0]);
  1194. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1195. exception return operation might vector to incorrect interrupt */
  1196. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1197. __DSB();
  1198. #endif
  1199. }
  1200. void I2S2_Rx_DriverIRQHandler(void)
  1201. {
  1202. assert(s_saiHandle[2][1]);
  1203. s_saiRxIsr(I2S2, s_saiHandle[2][1]);
  1204. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1205. exception return operation might vector to incorrect interrupt */
  1206. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1207. __DSB();
  1208. #endif
  1209. }
  1210. #endif /* I2S2*/
  1211. #if defined(I2S3)
  1212. void I2S3_DriverIRQHandler(void)
  1213. {
  1214. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1215. if ((s_saiHandle[3][1]) && ((I2S3->RCSR & kSAI_FIFORequestFlag) || (I2S3->RCSR & kSAI_FIFOErrorFlag)) &&
  1216. ((I2S3->RCSR & kSAI_FIFORequestInterruptEnable) || (I2S3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1217. #else
  1218. if ((s_saiHandle[3][1]) && ((I2S3->RCSR & kSAI_FIFOWarningFlag) || (I2S3->RCSR & kSAI_FIFOErrorFlag)) &&
  1219. ((I2S3->RCSR & kSAI_FIFOWarningInterruptEnable) || (I2S3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1220. #endif
  1221. {
  1222. s_saiRxIsr(I2S3, s_saiHandle[3][1]);
  1223. }
  1224. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1225. if ((s_saiHandle[3][0]) && ((I2S3->TCSR & kSAI_FIFORequestFlag) || (I2S3->TCSR & kSAI_FIFOErrorFlag)) &&
  1226. ((I2S3->TCSR & kSAI_FIFORequestInterruptEnable) || (I2S3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1227. #else
  1228. if ((s_saiHandle[3][0]) && ((I2S3->TCSR & kSAI_FIFOWarningFlag) || (I2S3->TCSR & kSAI_FIFOErrorFlag)) &&
  1229. ((I2S3->TCSR & kSAI_FIFOWarningInterruptEnable) || (I2S3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1230. #endif
  1231. {
  1232. s_saiTxIsr(I2S3, s_saiHandle[3][0]);
  1233. }
  1234. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1235. exception return operation might vector to incorrect interrupt */
  1236. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1237. __DSB();
  1238. #endif
  1239. }
  1240. void I2S3_Tx_DriverIRQHandler(void)
  1241. {
  1242. assert(s_saiHandle[3][0]);
  1243. s_saiTxIsr(I2S3, s_saiHandle[3][0]);
  1244. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1245. exception return operation might vector to incorrect interrupt */
  1246. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1247. __DSB();
  1248. #endif
  1249. }
  1250. void I2S3_Rx_DriverIRQHandler(void)
  1251. {
  1252. assert(s_saiHandle[3][1]);
  1253. s_saiRxIsr(I2S3, s_saiHandle[3][1]);
  1254. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1255. exception return operation might vector to incorrect interrupt */
  1256. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1257. __DSB();
  1258. #endif
  1259. }
  1260. #endif /* I2S3*/
  1261. #if defined(AUDIO__SAI0)
  1262. void AUDIO_SAI0_INT_DriverIRQHandler(void)
  1263. {
  1264. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1265. if ((s_saiHandle[0][1]) &&
  1266. ((AUDIO__SAI0->RCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI0->RCSR & kSAI_FIFOErrorFlag)) &&
  1267. ((AUDIO__SAI0->RCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1268. #else
  1269. if ((s_saiHandle[0][1]) &&
  1270. ((AUDIO__SAI0->RCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI0->RCSR & kSAI_FIFOErrorFlag)) &&
  1271. ((AUDIO__SAI0->RCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1272. #endif
  1273. {
  1274. s_saiRxIsr(AUDIO__SAI0, s_saiHandle[0][1]);
  1275. }
  1276. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1277. if ((s_saiHandle[0][0]) &&
  1278. ((AUDIO__SAI0->TCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI0->TCSR & kSAI_FIFOErrorFlag)) &&
  1279. ((AUDIO__SAI0->TCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1280. #else
  1281. if ((s_saiHandle[0][0]) &&
  1282. ((AUDIO__SAI0->TCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI0->TCSR & kSAI_FIFOErrorFlag)) &&
  1283. ((AUDIO__SAI0->TCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1284. #endif
  1285. {
  1286. s_saiTxIsr(AUDIO__SAI0, s_saiHandle[0][0]);
  1287. }
  1288. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1289. exception return operation might vector to incorrect interrupt */
  1290. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1291. __DSB();
  1292. #endif
  1293. }
  1294. #endif /* AUDIO__SAI0 */
  1295. #if defined(AUDIO__SAI1)
  1296. void AUDIO_SAI1_INT_DriverIRQHandler(void)
  1297. {
  1298. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1299. if ((s_saiHandle[1][1]) &&
  1300. ((AUDIO__SAI1->RCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI1->RCSR & kSAI_FIFOErrorFlag)) &&
  1301. ((AUDIO__SAI1->RCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1302. #else
  1303. if ((s_saiHandle[1][1]) &&
  1304. ((AUDIO__SAI1->RCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI1->RCSR & kSAI_FIFOErrorFlag)) &&
  1305. ((AUDIO__SAI1->RCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1306. #endif
  1307. {
  1308. s_saiRxIsr(AUDIO__SAI1, s_saiHandle[1][1]);
  1309. }
  1310. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1311. if ((s_saiHandle[1][0]) &&
  1312. ((AUDIO__SAI1->TCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI1->TCSR & kSAI_FIFOErrorFlag)) &&
  1313. ((AUDIO__SAI1->TCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1314. #else
  1315. if ((s_saiHandle[1][0]) &&
  1316. ((AUDIO__SAI1->TCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI1->TCSR & kSAI_FIFOErrorFlag)) &&
  1317. ((AUDIO__SAI1->TCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1318. #endif
  1319. {
  1320. s_saiTxIsr(AUDIO__SAI1, s_saiHandle[1][0]);
  1321. }
  1322. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1323. exception return operation might vector to incorrect interrupt */
  1324. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1325. __DSB();
  1326. #endif
  1327. }
  1328. #endif /* AUDIO__SAI1 */
  1329. #if defined(AUDIO__SAI2)
  1330. void AUDIO_SAI2_INT_DriverIRQHandler(void)
  1331. {
  1332. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1333. if ((s_saiHandle[2][1]) &&
  1334. ((AUDIO__SAI2->RCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI2->RCSR & kSAI_FIFOErrorFlag)) &&
  1335. ((AUDIO__SAI2->RCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1336. #else
  1337. if ((s_saiHandle[2][1]) &&
  1338. ((AUDIO__SAI2->RCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI2->RCSR & kSAI_FIFOErrorFlag)) &&
  1339. ((AUDIO__SAI2->RCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1340. #endif
  1341. {
  1342. s_saiRxIsr(AUDIO__SAI2, s_saiHandle[2][1]);
  1343. }
  1344. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1345. if ((s_saiHandle[2][0]) &&
  1346. ((AUDIO__SAI2->TCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI2->TCSR & kSAI_FIFOErrorFlag)) &&
  1347. ((AUDIO__SAI2->TCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1348. #else
  1349. if ((s_saiHandle[2][0]) &&
  1350. ((AUDIO__SAI2->TCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI2->TCSR & kSAI_FIFOErrorFlag)) &&
  1351. ((AUDIO__SAI2->TCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1352. #endif
  1353. {
  1354. s_saiTxIsr(AUDIO__SAI2, s_saiHandle[2][0]);
  1355. }
  1356. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1357. exception return operation might vector to incorrect interrupt */
  1358. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1359. __DSB();
  1360. #endif
  1361. }
  1362. #endif /* AUDIO__SAI2 */
  1363. #if defined(AUDIO__SAI3)
  1364. void AUDIO_SAI3_INT_DriverIRQHandler(void)
  1365. {
  1366. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1367. if ((s_saiHandle[3][1]) &&
  1368. ((AUDIO__SAI3->RCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI3->RCSR & kSAI_FIFOErrorFlag)) &&
  1369. ((AUDIO__SAI3->RCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1370. #else
  1371. if ((s_saiHandle[3][1]) &&
  1372. ((AUDIO__SAI3->RCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI3->RCSR & kSAI_FIFOErrorFlag)) &&
  1373. ((AUDIO__SAI3->RCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1374. #endif
  1375. {
  1376. s_saiRxIsr(AUDIO__SAI3, s_saiHandle[3][1]);
  1377. }
  1378. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1379. if ((s_saiHandle[3][0]) &&
  1380. ((AUDIO__SAI3->TCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI3->TCSR & kSAI_FIFOErrorFlag)) &&
  1381. ((AUDIO__SAI3->TCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1382. #else
  1383. if ((s_saiHandle[3][0]) &&
  1384. ((AUDIO__SAI3->TCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI3->TCSR & kSAI_FIFOErrorFlag)) &&
  1385. ((AUDIO__SAI3->TCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1386. #endif
  1387. {
  1388. s_saiTxIsr(AUDIO__SAI3, s_saiHandle[3][0]);
  1389. }
  1390. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1391. exception return operation might vector to incorrect interrupt */
  1392. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1393. __DSB();
  1394. #endif
  1395. }
  1396. #endif
  1397. #if defined(AUDIO__SAI6)
  1398. void AUDIO_SAI6_INT_DriverIRQHandler(void)
  1399. {
  1400. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1401. if ((s_saiHandle[6][1]) &&
  1402. ((AUDIO__SAI6->RCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI6->RCSR & kSAI_FIFOErrorFlag)) &&
  1403. ((AUDIO__SAI6->RCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI6->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1404. #else
  1405. if ((s_saiHandle[6][1]) &&
  1406. ((AUDIO__SAI6->RCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI6->RCSR & kSAI_FIFOErrorFlag)) &&
  1407. ((AUDIO__SAI6->RCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI6->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1408. #endif
  1409. {
  1410. s_saiRxIsr(AUDIO__SAI6, s_saiHandle[6][1]);
  1411. }
  1412. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1413. if ((s_saiHandle[6][0]) &&
  1414. ((AUDIO__SAI6->TCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI6->TCSR & kSAI_FIFOErrorFlag)) &&
  1415. ((AUDIO__SAI6->TCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI6->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1416. #else
  1417. if ((s_saiHandle[6][0]) &&
  1418. ((AUDIO__SAI6->TCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI6->TCSR & kSAI_FIFOErrorFlag)) &&
  1419. ((AUDIO__SAI6->TCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI6->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1420. #endif
  1421. {
  1422. s_saiTxIsr(AUDIO__SAI6, s_saiHandle[6][0]);
  1423. }
  1424. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1425. exception return operation might vector to incorrect interrupt */
  1426. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1427. __DSB();
  1428. #endif
  1429. }
  1430. #endif /* AUDIO__SAI6 */
  1431. #if defined(AUDIO__SAI7)
  1432. void AUDIO_SAI7_INT_DriverIRQHandler(void)
  1433. {
  1434. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1435. if ((s_saiHandle[7][1]) &&
  1436. ((AUDIO__SAI7->RCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI7->RCSR & kSAI_FIFOErrorFlag)) &&
  1437. ((AUDIO__SAI7->RCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI7->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1438. #else
  1439. if ((s_saiHandle[7][1]) &&
  1440. ((AUDIO__SAI7->RCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI7->RCSR & kSAI_FIFOErrorFlag)) &&
  1441. ((AUDIO__SAI7->RCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI7->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1442. #endif
  1443. {
  1444. s_saiRxIsr(AUDIO__SAI7, s_saiHandle[7][1]);
  1445. }
  1446. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1447. if ((s_saiHandle[7][0]) &&
  1448. ((AUDIO__SAI7->TCSR & kSAI_FIFORequestFlag) || (AUDIO__SAI7->TCSR & kSAI_FIFOErrorFlag)) &&
  1449. ((AUDIO__SAI7->TCSR & kSAI_FIFORequestInterruptEnable) || (AUDIO__SAI7->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1450. #else
  1451. if ((s_saiHandle[7][0]) &&
  1452. ((AUDIO__SAI7->TCSR & kSAI_FIFOWarningFlag) || (AUDIO__SAI7->TCSR & kSAI_FIFOErrorFlag)) &&
  1453. ((AUDIO__SAI7->TCSR & kSAI_FIFOWarningInterruptEnable) || (AUDIO__SAI7->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1454. #endif
  1455. {
  1456. s_saiTxIsr(AUDIO__SAI7, s_saiHandle[7][0]);
  1457. }
  1458. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1459. exception return operation might vector to incorrect interrupt */
  1460. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1461. __DSB();
  1462. #endif
  1463. }
  1464. #endif /* AUDIO__SAI7 */
  1465. #if defined(ADMA__SAI0)
  1466. void ADMA_SAI0_INT_DriverIRQHandler(void)
  1467. {
  1468. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1469. if ((s_saiHandle[1][1]) && ((ADMA__SAI0->RCSR & kSAI_FIFORequestFlag) || (ADMA__SAI0->RCSR & kSAI_FIFOErrorFlag)) &&
  1470. ((ADMA__SAI0->RCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1471. #else
  1472. if ((s_saiHandle[1][1]) && ((ADMA__SAI0->RCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI0->RCSR & kSAI_FIFOErrorFlag)) &&
  1473. ((ADMA__SAI0->RCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1474. #endif
  1475. {
  1476. s_saiRxIsr(ADMA__SAI0, s_saiHandle[1][1]);
  1477. }
  1478. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1479. if ((s_saiHandle[1][0]) && ((ADMA__SAI0->TCSR & kSAI_FIFORequestFlag) || (ADMA__SAI0->TCSR & kSAI_FIFOErrorFlag)) &&
  1480. ((ADMA__SAI0->TCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1481. #else
  1482. if ((s_saiHandle[1][0]) && ((ADMA__SAI0->TCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI0->TCSR & kSAI_FIFOErrorFlag)) &&
  1483. ((ADMA__SAI0->TCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1484. #endif
  1485. {
  1486. s_saiTxIsr(ADMA__SAI0, s_saiHandle[1][0]);
  1487. }
  1488. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1489. exception return operation might vector to incorrect interrupt */
  1490. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1491. __DSB();
  1492. #endif
  1493. }
  1494. #endif /* ADMA__SAI0 */
  1495. #if defined(ADMA__SAI1)
  1496. void ADMA_SAI1_INT_DriverIRQHandler(void)
  1497. {
  1498. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1499. if ((s_saiHandle[1][1]) && ((ADMA__SAI1->RCSR & kSAI_FIFORequestFlag) || (ADMA__SAI1->RCSR & kSAI_FIFOErrorFlag)) &&
  1500. ((ADMA__SAI1->RCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1501. #else
  1502. if ((s_saiHandle[1][1]) && ((ADMA__SAI1->RCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI1->RCSR & kSAI_FIFOErrorFlag)) &&
  1503. ((ADMA__SAI1->RCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1504. #endif
  1505. {
  1506. s_saiRxIsr(ADMA__SAI1, s_saiHandle[1][1]);
  1507. }
  1508. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1509. if ((s_saiHandle[1][0]) && ((ADMA__SAI1->TCSR & kSAI_FIFORequestFlag) || (ADMA__SAI1->TCSR & kSAI_FIFOErrorFlag)) &&
  1510. ((ADMA__SAI1->TCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1511. #else
  1512. if ((s_saiHandle[1][0]) && ((ADMA__SAI1->TCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI1->TCSR & kSAI_FIFOErrorFlag)) &&
  1513. ((ADMA__SAI1->TCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1514. #endif
  1515. {
  1516. s_saiTxIsr(ADMA__SAI1, s_saiHandle[1][0]);
  1517. }
  1518. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1519. exception return operation might vector to incorrect interrupt */
  1520. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1521. __DSB();
  1522. #endif
  1523. }
  1524. #endif /* ADMA__SAI1 */
  1525. #if defined(ADMA__SAI2)
  1526. void ADMA_SAI2_INT_DriverIRQHandler(void)
  1527. {
  1528. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1529. if ((s_saiHandle[1][1]) && ((ADMA__SAI2->RCSR & kSAI_FIFORequestFlag) || (ADMA__SAI2->RCSR & kSAI_FIFOErrorFlag)) &&
  1530. ((ADMA__SAI2->RCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1531. #else
  1532. if ((s_saiHandle[1][1]) && ((ADMA__SAI2->RCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI2->RCSR & kSAI_FIFOErrorFlag)) &&
  1533. ((ADMA__SAI2->RCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1534. #endif
  1535. {
  1536. s_saiRxIsr(ADMA__SAI2, s_saiHandle[1][1]);
  1537. }
  1538. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1539. if ((s_saiHandle[1][0]) && ((ADMA__SAI2->TCSR & kSAI_FIFORequestFlag) || (ADMA__SAI2->TCSR & kSAI_FIFOErrorFlag)) &&
  1540. ((ADMA__SAI2->TCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1541. #else
  1542. if ((s_saiHandle[1][0]) && ((ADMA__SAI2->TCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI2->TCSR & kSAI_FIFOErrorFlag)) &&
  1543. ((ADMA__SAI2->TCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1544. #endif
  1545. {
  1546. s_saiTxIsr(ADMA__SAI2, s_saiHandle[1][0]);
  1547. }
  1548. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1549. exception return operation might vector to incorrect interrupt */
  1550. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1551. __DSB();
  1552. #endif
  1553. }
  1554. #endif /* ADMA__SAI2 */
  1555. #if defined(ADMA__SAI3)
  1556. void ADMA_SAI3_INT_DriverIRQHandler(void)
  1557. {
  1558. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1559. if ((s_saiHandle[1][1]) && ((ADMA__SAI3->RCSR & kSAI_FIFORequestFlag) || (ADMA__SAI3->RCSR & kSAI_FIFOErrorFlag)) &&
  1560. ((ADMA__SAI3->RCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1561. #else
  1562. if ((s_saiHandle[1][1]) && ((ADMA__SAI3->RCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI3->RCSR & kSAI_FIFOErrorFlag)) &&
  1563. ((ADMA__SAI3->RCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1564. #endif
  1565. {
  1566. s_saiRxIsr(ADMA__SAI3, s_saiHandle[1][1]);
  1567. }
  1568. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1569. if ((s_saiHandle[1][0]) && ((ADMA__SAI3->TCSR & kSAI_FIFORequestFlag) || (ADMA__SAI3->TCSR & kSAI_FIFOErrorFlag)) &&
  1570. ((ADMA__SAI3->TCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1571. #else
  1572. if ((s_saiHandle[1][0]) && ((ADMA__SAI3->TCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI3->TCSR & kSAI_FIFOErrorFlag)) &&
  1573. ((ADMA__SAI3->TCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1574. #endif
  1575. {
  1576. s_saiTxIsr(ADMA__SAI3, s_saiHandle[1][0]);
  1577. }
  1578. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1579. exception return operation might vector to incorrect interrupt */
  1580. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1581. __DSB();
  1582. #endif
  1583. }
  1584. #endif /* ADMA__SAI3 */
  1585. #if defined(ADMA__SAI4)
  1586. void ADMA_SAI4_INT_DriverIRQHandler(void)
  1587. {
  1588. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1589. if ((s_saiHandle[1][1]) && ((ADMA__SAI4->RCSR & kSAI_FIFORequestFlag) || (ADMA__SAI4->RCSR & kSAI_FIFOErrorFlag)) &&
  1590. ((ADMA__SAI4->RCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI4->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1591. #else
  1592. if ((s_saiHandle[1][1]) && ((ADMA__SAI4->RCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI4->RCSR & kSAI_FIFOErrorFlag)) &&
  1593. ((ADMA__SAI4->RCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI4->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1594. #endif
  1595. {
  1596. s_saiRxIsr(ADMA__SAI4, s_saiHandle[1][1]);
  1597. }
  1598. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1599. if ((s_saiHandle[1][0]) && ((ADMA__SAI4->TCSR & kSAI_FIFORequestFlag) || (ADMA__SAI4->TCSR & kSAI_FIFOErrorFlag)) &&
  1600. ((ADMA__SAI4->TCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI4->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1601. #else
  1602. if ((s_saiHandle[1][0]) && ((ADMA__SAI4->TCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI4->TCSR & kSAI_FIFOErrorFlag)) &&
  1603. ((ADMA__SAI4->TCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI4->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1604. #endif
  1605. {
  1606. s_saiTxIsr(ADMA__SAI4, s_saiHandle[1][0]);
  1607. }
  1608. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1609. exception return operation might vector to incorrect interrupt */
  1610. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1611. __DSB();
  1612. #endif
  1613. }
  1614. #endif /* ADMA__SAI4 */
  1615. #if defined(ADMA__SAI5)
  1616. void ADMA_SAI5_INT_DriverIRQHandler(void)
  1617. {
  1618. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1619. if ((s_saiHandle[1][1]) && ((ADMA__SAI5->RCSR & kSAI_FIFORequestFlag) || (ADMA__SAI5->RCSR & kSAI_FIFOErrorFlag)) &&
  1620. ((ADMA__SAI5->RCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI5->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1621. #else
  1622. if ((s_saiHandle[1][1]) && ((ADMA__SAI5->RCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI5->RCSR & kSAI_FIFOErrorFlag)) &&
  1623. ((ADMA__SAI5->RCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI5->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1624. #endif
  1625. {
  1626. s_saiRxIsr(ADMA__SAI5, s_saiHandle[1][1]);
  1627. }
  1628. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1629. if ((s_saiHandle[1][0]) && ((ADMA__SAI5->TCSR & kSAI_FIFORequestFlag) || (ADMA__SAI5->TCSR & kSAI_FIFOErrorFlag)) &&
  1630. ((ADMA__SAI5->TCSR & kSAI_FIFORequestInterruptEnable) || (ADMA__SAI5->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1631. #else
  1632. if ((s_saiHandle[1][0]) && ((ADMA__SAI5->TCSR & kSAI_FIFOWarningFlag) || (ADMA__SAI5->TCSR & kSAI_FIFOErrorFlag)) &&
  1633. ((ADMA__SAI5->TCSR & kSAI_FIFOWarningInterruptEnable) || (ADMA__SAI5->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1634. #endif
  1635. {
  1636. s_saiTxIsr(ADMA__SAI5, s_saiHandle[1][0]);
  1637. }
  1638. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1639. exception return operation might vector to incorrect interrupt */
  1640. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1641. __DSB();
  1642. #endif
  1643. }
  1644. #endif /* ADMA__SAI5 */
  1645. #if defined(SAI0)
  1646. void SAI0_DriverIRQHandler(void)
  1647. {
  1648. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1649. if ((s_saiHandle[0][1]) && ((SAI0->RCSR & kSAI_FIFORequestFlag) || (SAI0->RCSR & kSAI_FIFOErrorFlag)) &&
  1650. ((SAI0->RCSR & kSAI_FIFORequestInterruptEnable) || (SAI0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1651. #else
  1652. if ((s_saiHandle[0][1]) && ((SAI0->RCSR & kSAI_FIFOWarningFlag) || (SAI0->RCSR & kSAI_FIFOErrorFlag)) &&
  1653. ((SAI0->RCSR & kSAI_FIFOWarningInterruptEnable) || (SAI0->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1654. #endif
  1655. {
  1656. s_saiRxIsr(SAI0, s_saiHandle[0][1]);
  1657. }
  1658. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1659. if ((s_saiHandle[0][0]) && ((SAI0->TCSR & kSAI_FIFORequestFlag) || (SAI0->TCSR & kSAI_FIFOErrorFlag)) &&
  1660. ((SAI0->TCSR & kSAI_FIFORequestInterruptEnable) || (SAI0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1661. #else
  1662. if ((s_saiHandle[0][0]) && ((SAI0->TCSR & kSAI_FIFOWarningFlag) || (SAI0->TCSR & kSAI_FIFOErrorFlag)) &&
  1663. ((SAI0->TCSR & kSAI_FIFOWarningInterruptEnable) || (SAI0->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1664. #endif
  1665. {
  1666. s_saiTxIsr(AUDIO__SAI0, s_saiHandle[0][0]);
  1667. }
  1668. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1669. exception return operation might vector to incorrect interrupt */
  1670. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1671. __DSB();
  1672. #endif
  1673. }
  1674. #endif /* SAI0 */
  1675. #if defined(SAI1)
  1676. void SAI1_DriverIRQHandler(void)
  1677. {
  1678. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1679. if ((s_saiHandle[1][1]) && ((SAI1->RCSR & kSAI_FIFORequestFlag) || (SAI1->RCSR & kSAI_FIFOErrorFlag)) &&
  1680. ((SAI1->RCSR & kSAI_FIFORequestInterruptEnable) || (SAI1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1681. #else
  1682. if ((s_saiHandle[1][1]) && ((SAI1->RCSR & kSAI_FIFOWarningFlag) || (SAI1->RCSR & kSAI_FIFOErrorFlag)) &&
  1683. ((SAI1->RCSR & kSAI_FIFOWarningInterruptEnable) || (SAI1->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1684. #endif
  1685. {
  1686. s_saiRxIsr(SAI1, s_saiHandle[1][1]);
  1687. }
  1688. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1689. if ((s_saiHandle[1][0]) && ((SAI1->TCSR & kSAI_FIFORequestFlag) || (SAI1->TCSR & kSAI_FIFOErrorFlag)) &&
  1690. ((SAI1->TCSR & kSAI_FIFORequestInterruptEnable) || (SAI1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1691. #else
  1692. if ((s_saiHandle[1][0]) && ((SAI1->TCSR & kSAI_FIFOWarningFlag) || (SAI1->TCSR & kSAI_FIFOErrorFlag)) &&
  1693. ((SAI1->TCSR & kSAI_FIFOWarningInterruptEnable) || (SAI1->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1694. #endif
  1695. {
  1696. s_saiTxIsr(SAI1, s_saiHandle[1][0]);
  1697. }
  1698. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1699. exception return operation might vector to incorrect interrupt */
  1700. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1701. __DSB();
  1702. #endif
  1703. }
  1704. #endif /* SAI1 */
  1705. #if defined(SAI2)
  1706. void SAI2_DriverIRQHandler(void)
  1707. {
  1708. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1709. if ((s_saiHandle[2][1]) && ((SAI2->RCSR & kSAI_FIFORequestFlag) || (SAI2->RCSR & kSAI_FIFOErrorFlag)) &&
  1710. ((SAI2->RCSR & kSAI_FIFORequestInterruptEnable) || (SAI2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1711. #else
  1712. if ((s_saiHandle[2][1]) && ((SAI2->RCSR & kSAI_FIFOWarningFlag) || (SAI2->RCSR & kSAI_FIFOErrorFlag)) &&
  1713. ((SAI2->RCSR & kSAI_FIFOWarningInterruptEnable) || (SAI2->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1714. #endif
  1715. {
  1716. s_saiRxIsr(SAI2, s_saiHandle[2][1]);
  1717. }
  1718. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1719. if ((s_saiHandle[2][0]) && ((SAI2->TCSR & kSAI_FIFORequestFlag) || (SAI2->TCSR & kSAI_FIFOErrorFlag)) &&
  1720. ((SAI2->TCSR & kSAI_FIFORequestInterruptEnable) || (SAI2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1721. #else
  1722. if ((s_saiHandle[2][0]) && ((SAI2->TCSR & kSAI_FIFOWarningFlag) || (SAI2->TCSR & kSAI_FIFOErrorFlag)) &&
  1723. ((SAI2->TCSR & kSAI_FIFOWarningInterruptEnable) || (SAI2->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1724. #endif
  1725. {
  1726. s_saiTxIsr(SAI2, s_saiHandle[2][0]);
  1727. }
  1728. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1729. exception return operation might vector to incorrect interrupt */
  1730. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1731. __DSB();
  1732. #endif
  1733. }
  1734. #endif /* SAI2 */
  1735. #if defined(SAI3)
  1736. void SAI3_DriverIRQHandler(void)
  1737. {
  1738. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1739. if ((s_saiHandle[3][1]) && ((SAI3->RCSR & kSAI_FIFORequestFlag) || (SAI3->RCSR & kSAI_FIFOErrorFlag)) &&
  1740. ((SAI3->RCSR & kSAI_FIFORequestInterruptEnable) || (SAI3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1741. #else
  1742. if ((s_saiHandle[3][1]) && ((SAI3->RCSR & kSAI_FIFOWarningFlag) || (SAI3->RCSR & kSAI_FIFOErrorFlag)) &&
  1743. ((SAI3->RCSR & kSAI_FIFOWarningInterruptEnable) || (SAI3->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1744. #endif
  1745. {
  1746. s_saiRxIsr(SAI3, s_saiHandle[3][1]);
  1747. }
  1748. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1749. if ((s_saiHandle[3][0]) && ((SAI3->TCSR & kSAI_FIFORequestFlag) || (SAI3->TCSR & kSAI_FIFOErrorFlag)) &&
  1750. ((SAI3->TCSR & kSAI_FIFORequestInterruptEnable) || (SAI3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1751. #else
  1752. if ((s_saiHandle[3][0]) && ((SAI3->TCSR & kSAI_FIFOWarningFlag) || (SAI3->TCSR & kSAI_FIFOErrorFlag)) &&
  1753. ((SAI3->TCSR & kSAI_FIFOWarningInterruptEnable) || (SAI3->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1754. #endif
  1755. {
  1756. s_saiTxIsr(SAI3, s_saiHandle[3][0]);
  1757. }
  1758. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1759. exception return operation might vector to incorrect interrupt */
  1760. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1761. __DSB();
  1762. #endif
  1763. }
  1764. void SAI3_Tx_DriverIRQHandler(void)
  1765. {
  1766. assert(s_saiHandle[3][0]);
  1767. s_saiTxIsr(SAI3, s_saiHandle[3][0]);
  1768. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1769. exception return operation might vector to incorrect interrupt */
  1770. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1771. __DSB();
  1772. #endif
  1773. }
  1774. void SAI3_Rx_DriverIRQHandler(void)
  1775. {
  1776. assert(s_saiHandle[3][1]);
  1777. s_saiRxIsr(SAI3, s_saiHandle[3][1]);
  1778. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1779. exception return operation might vector to incorrect interrupt */
  1780. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1781. __DSB();
  1782. #endif
  1783. }
  1784. #endif /* SAI3 */
  1785. #if defined(SAI4)
  1786. void SAI4_DriverIRQHandler(void)
  1787. {
  1788. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1789. if ((s_saiHandle[4][1]) && ((SAI4->RCSR & kSAI_FIFORequestFlag) || (SAI4->RCSR & kSAI_FIFOErrorFlag)) &&
  1790. ((SAI4->RCSR & kSAI_FIFORequestInterruptEnable) || (SAI4->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1791. #else
  1792. if ((s_saiHandle[4][1]) && ((SAI4->RCSR & kSAI_FIFOWarningFlag) || (SAI4->RCSR & kSAI_FIFOErrorFlag)) &&
  1793. ((SAI4->RCSR & kSAI_FIFOWarningInterruptEnable) || (SAI4->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1794. #endif
  1795. {
  1796. s_saiRxIsr(SAI4, s_saiHandle[4][1]);
  1797. }
  1798. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1799. if ((s_saiHandle[4][0]) && ((SAI4->TCSR & kSAI_FIFORequestFlag) || (SAI4->TCSR & kSAI_FIFOErrorFlag)) &&
  1800. ((SAI4->TCSR & kSAI_FIFORequestInterruptEnable) || (SAI4->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1801. #else
  1802. if ((s_saiHandle[4][0]) && ((SAI4->TCSR & kSAI_FIFOWarningFlag) || (SAI4->TCSR & kSAI_FIFOErrorFlag)) &&
  1803. ((SAI4->TCSR & kSAI_FIFOWarningInterruptEnable) || (SAI4->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1804. #endif
  1805. {
  1806. s_saiTxIsr(SAI4, s_saiHandle[4][0]);
  1807. }
  1808. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1809. exception return operation might vector to incorrect interrupt */
  1810. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1811. __DSB();
  1812. #endif
  1813. }
  1814. #endif /* SAI4 */
  1815. #if defined(SAI5)
  1816. void SAI5_DriverIRQHandler(void)
  1817. {
  1818. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1819. if ((s_saiHandle[5][1]) && ((SAI5->RCSR & kSAI_FIFORequestFlag) || (SAI5->RCSR & kSAI_FIFOErrorFlag)) &&
  1820. ((SAI5->RCSR & kSAI_FIFORequestInterruptEnable) || (SAI5->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1821. #else
  1822. if ((s_saiHandle[5][1]) && ((SAI5->RCSR & kSAI_FIFOWarningFlag) || (SAI5->RCSR & kSAI_FIFOErrorFlag)) &&
  1823. ((SAI5->RCSR & kSAI_FIFOWarningInterruptEnable) || (SAI5->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1824. #endif
  1825. {
  1826. s_saiRxIsr(SAI5, s_saiHandle[5][1]);
  1827. }
  1828. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1829. if ((s_saiHandle[5][0]) && ((SAI5->TCSR & kSAI_FIFORequestFlag) || (SAI5->TCSR & kSAI_FIFOErrorFlag)) &&
  1830. ((SAI5->TCSR & kSAI_FIFORequestInterruptEnable) || (SAI5->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1831. #else
  1832. if ((s_saiHandle[5][0]) && ((SAI5->TCSR & kSAI_FIFOWarningFlag) || (SAI5->TCSR & kSAI_FIFOErrorFlag)) &&
  1833. ((SAI5->TCSR & kSAI_FIFOWarningInterruptEnable) || (SAI5->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1834. #endif
  1835. {
  1836. s_saiTxIsr(SAI5, s_saiHandle[5][0]);
  1837. }
  1838. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1839. exception return operation might vector to incorrect interrupt */
  1840. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1841. __DSB();
  1842. #endif
  1843. }
  1844. #endif /* SAI5 */
  1845. #if defined(SAI6)
  1846. void SAI6_DriverIRQHandler(void)
  1847. {
  1848. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1849. if ((s_saiHandle[6][1]) && ((SAI6->RCSR & kSAI_FIFORequestFlag) || (SAI6->RCSR & kSAI_FIFOErrorFlag)) &&
  1850. ((SAI6->RCSR & kSAI_FIFORequestInterruptEnable) || (SAI6->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1851. #else
  1852. if ((s_saiHandle[6][1]) && ((SAI6->RCSR & kSAI_FIFOWarningFlag) || (SAI6->RCSR & kSAI_FIFOErrorFlag)) &&
  1853. ((SAI6->RCSR & kSAI_FIFOWarningInterruptEnable) || (SAI6->RCSR & kSAI_FIFOErrorInterruptEnable)))
  1854. #endif
  1855. {
  1856. s_saiRxIsr(SAI6, s_saiHandle[6][1]);
  1857. }
  1858. #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1)
  1859. if ((s_saiHandle[6][0]) && ((SAI6->TCSR & kSAI_FIFORequestFlag) || (SAI6->TCSR & kSAI_FIFOErrorFlag)) &&
  1860. ((SAI6->TCSR & kSAI_FIFORequestInterruptEnable) || (SAI6->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1861. #else
  1862. if ((s_saiHandle[6][0]) && ((SAI6->TCSR & kSAI_FIFOWarningFlag) || (SAI6->TCSR & kSAI_FIFOErrorFlag)) &&
  1863. ((SAI6->TCSR & kSAI_FIFOWarningInterruptEnable) || (SAI6->TCSR & kSAI_FIFOErrorInterruptEnable)))
  1864. #endif
  1865. {
  1866. s_saiTxIsr(SAI6, s_saiHandle[6][0]);
  1867. }
  1868. /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  1869. exception return operation might vector to incorrect interrupt */
  1870. #if defined __CORTEX_M && (__CORTEX_M == 4U)
  1871. __DSB();
  1872. #endif
  1873. }
  1874. #endif /* SAI6 */