fsl_flexio_i2s.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _FSL_FLEXIO_I2S_H_
  31. #define _FSL_FLEXIO_I2S_H_
  32. #include "fsl_common.h"
  33. #include "fsl_flexio.h"
  34. /*!
  35. * @addtogroup flexio_i2s
  36. * @{
  37. */
  38. /*******************************************************************************
  39. * Definitions
  40. ******************************************************************************/
  41. /*! @name Driver version */
  42. /*@{*/
  43. /*! @brief FlexIO I2S driver version 2.1.1. */
  44. #define FSL_FLEXIO_I2S_DRIVER_VERSION (MAKE_VERSION(2, 1, 2))
  45. /*@}*/
  46. /*! @brief FlexIO I2S transfer status */
  47. enum _flexio_i2s_status
  48. {
  49. kStatus_FLEXIO_I2S_Idle = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 0), /*!< FlexIO I2S is in idle state */
  50. kStatus_FLEXIO_I2S_TxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 1), /*!< FlexIO I2S Tx is busy */
  51. kStatus_FLEXIO_I2S_RxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 2), /*!< FlexIO I2S Tx is busy */
  52. kStatus_FLEXIO_I2S_Error = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 3), /*!< FlexIO I2S error occurred */
  53. kStatus_FLEXIO_I2S_QueueFull = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 4), /*!< FlexIO I2S transfer queue is full. */
  54. };
  55. /*! @brief Define FlexIO I2S access structure typedef */
  56. typedef struct _flexio_i2s_type
  57. {
  58. FLEXIO_Type *flexioBase; /*!< FlexIO base pointer */
  59. uint8_t txPinIndex; /*!< Tx data pin index in FlexIO pins */
  60. uint8_t rxPinIndex; /*!< Rx data pin index */
  61. uint8_t bclkPinIndex; /*!< Bit clock pin index */
  62. uint8_t fsPinIndex; /*!< Frame sync pin index */
  63. uint8_t txShifterIndex; /*!< Tx data shifter index */
  64. uint8_t rxShifterIndex; /*!< Rx data shifter index */
  65. uint8_t bclkTimerIndex; /*!< Bit clock timer index */
  66. uint8_t fsTimerIndex; /*!< Frame sync timer index */
  67. } FLEXIO_I2S_Type;
  68. /*! @brief Master or slave mode */
  69. typedef enum _flexio_i2s_master_slave
  70. {
  71. kFLEXIO_I2S_Master = 0x0U, /*!< Master mode */
  72. kFLEXIO_I2S_Slave = 0x1U /*!< Slave mode */
  73. } flexio_i2s_master_slave_t;
  74. /*! @brief Define FlexIO FlexIO I2S interrupt mask. */
  75. enum _flexio_i2s_interrupt_enable
  76. {
  77. kFLEXIO_I2S_TxDataRegEmptyInterruptEnable = 0x1U, /*!< Transmit buffer empty interrupt enable. */
  78. kFLEXIO_I2S_RxDataRegFullInterruptEnable = 0x2U, /*!< Receive buffer full interrupt enable. */
  79. };
  80. /*! @brief Define FlexIO FlexIO I2S status mask. */
  81. enum _flexio_i2s_status_flags
  82. {
  83. kFLEXIO_I2S_TxDataRegEmptyFlag = 0x1U, /*!< Transmit buffer empty flag. */
  84. kFLEXIO_I2S_RxDataRegFullFlag = 0x2U, /*!< Receive buffer full flag. */
  85. };
  86. /*! @brief FlexIO I2S configure structure */
  87. typedef struct _flexio_i2s_config
  88. {
  89. bool enableI2S; /*!< Enable FlexIO I2S */
  90. flexio_i2s_master_slave_t masterSlave; /*!< Master or slave */
  91. flexio_pin_polarity_t txPinPolarity; /*!< Tx data pin polarity, active high or low */
  92. flexio_pin_polarity_t rxPinPolarity; /*!< Rx data pin polarity */
  93. flexio_pin_polarity_t bclkPinPolarity; /*!< Bit clock pin polarity */
  94. flexio_pin_polarity_t fsPinPolarity; /*!< Frame sync pin polarity */
  95. flexio_shifter_timer_polarity_t txTimerPolarity; /*!< Tx data valid on bclk rising or falling edge */
  96. flexio_shifter_timer_polarity_t rxTimerPolarity; /*!< Rx data valid on bclk rising or falling edge */
  97. } flexio_i2s_config_t;
  98. /*! @brief FlexIO I2S audio format, FlexIO I2S only support the same format in Tx and Rx */
  99. typedef struct _flexio_i2s_format
  100. {
  101. uint8_t bitWidth; /*!< Bit width of audio data, always 8/16/24/32 bits */
  102. uint32_t sampleRate_Hz; /*!< Sample rate of the audio data */
  103. } flexio_i2s_format_t;
  104. /*!@brief FlexIO I2S transfer queue size, user can refine it according to use case. */
  105. #define FLEXIO_I2S_XFER_QUEUE_SIZE (4)
  106. /*! @brief Audio sample rate */
  107. typedef enum _flexio_i2s_sample_rate
  108. {
  109. kFLEXIO_I2S_SampleRate8KHz = 8000U, /*!< Sample rate 8000Hz */
  110. kFLEXIO_I2S_SampleRate11025Hz = 11025U, /*!< Sample rate 11025Hz */
  111. kFLEXIO_I2S_SampleRate12KHz = 12000U, /*!< Sample rate 12000Hz */
  112. kFLEXIO_I2S_SampleRate16KHz = 16000U, /*!< Sample rate 16000Hz */
  113. kFLEXIO_I2S_SampleRate22050Hz = 22050U, /*!< Sample rate 22050Hz */
  114. kFLEXIO_I2S_SampleRate24KHz = 24000U, /*!< Sample rate 24000Hz */
  115. kFLEXIO_I2S_SampleRate32KHz = 32000U, /*!< Sample rate 32000Hz */
  116. kFLEXIO_I2S_SampleRate44100Hz = 44100U, /*!< Sample rate 44100Hz */
  117. kFLEXIO_I2S_SampleRate48KHz = 48000U, /*!< Sample rate 48000Hz */
  118. kFLEXIO_I2S_SampleRate96KHz = 96000U /*!< Sample rate 96000Hz */
  119. } flexio_i2s_sample_rate_t;
  120. /*! @brief Audio word width */
  121. typedef enum _flexio_i2s_word_width
  122. {
  123. kFLEXIO_I2S_WordWidth8bits = 8U, /*!< Audio data width 8 bits */
  124. kFLEXIO_I2S_WordWidth16bits = 16U, /*!< Audio data width 16 bits */
  125. kFLEXIO_I2S_WordWidth24bits = 24U, /*!< Audio data width 24 bits */
  126. kFLEXIO_I2S_WordWidth32bits = 32U /*!< Audio data width 32 bits */
  127. } flexio_i2s_word_width_t;
  128. /*! @brief Define FlexIO I2S transfer structure. */
  129. typedef struct _flexio_i2s_transfer
  130. {
  131. uint8_t *data; /*!< Data buffer start pointer */
  132. size_t dataSize; /*!< Bytes to be transferred. */
  133. } flexio_i2s_transfer_t;
  134. typedef struct _flexio_i2s_handle flexio_i2s_handle_t;
  135. /*! @brief FlexIO I2S xfer callback prototype */
  136. typedef void (*flexio_i2s_callback_t)(FLEXIO_I2S_Type *base,
  137. flexio_i2s_handle_t *handle,
  138. status_t status,
  139. void *userData);
  140. /*! @brief Define FlexIO I2S handle structure. */
  141. struct _flexio_i2s_handle
  142. {
  143. uint32_t state; /*!< Internal state */
  144. flexio_i2s_callback_t callback; /*!< Callback function called at transfer event*/
  145. void *userData; /*!< Callback parameter passed to callback function*/
  146. uint8_t bitWidth; /*!< Bit width for transfer, 8/16/24/32bits */
  147. flexio_i2s_transfer_t queue[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer */
  148. size_t transferSize[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */
  149. volatile uint8_t queueUser; /*!< Index for user to queue transfer */
  150. volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */
  151. };
  152. /*******************************************************************************
  153. * API
  154. ******************************************************************************/
  155. #if defined(__cplusplus)
  156. extern "C" {
  157. #endif /*_cplusplus*/
  158. /*!
  159. * @name Initialization and deinitialization
  160. * @{
  161. */
  162. /*!
  163. * @brief Initializes the FlexIO I2S.
  164. *
  165. * This API configures FlexIO pins and shifter to I2S and configures the FlexIO I2S with a configuration structure.
  166. * The configuration structure can be filled by the user, or be set with default values by
  167. * FLEXIO_I2S_GetDefaultConfig().
  168. *
  169. * @note This API should be called at the beginning of the application to use
  170. * the FlexIO I2S driver. Otherwise, any access to the FlexIO I2S module can cause hard fault
  171. * because the clock is not enabled.
  172. *
  173. * @param base FlexIO I2S base pointer
  174. * @param config FlexIO I2S configure structure.
  175. */
  176. void FLEXIO_I2S_Init(FLEXIO_I2S_Type *base, const flexio_i2s_config_t *config);
  177. /*!
  178. * @brief Sets the FlexIO I2S configuration structure to default values.
  179. *
  180. * The purpose of this API is to get the configuration structure initialized for use in FLEXIO_I2S_Init().
  181. * Users may use the initialized structure unchanged in FLEXIO_I2S_Init() or modify
  182. * some fields of the structure before calling FLEXIO_I2S_Init().
  183. *
  184. * @param config pointer to master configuration structure
  185. */
  186. void FLEXIO_I2S_GetDefaultConfig(flexio_i2s_config_t *config);
  187. /*!
  188. * @brief De-initializes the FlexIO I2S.
  189. *
  190. * Calling this API resets the FlexIO I2S shifter and timer config. After calling this API,
  191. * call the FLEXO_I2S_Init to use the FlexIO I2S module.
  192. *
  193. * @param base FlexIO I2S base pointer
  194. */
  195. void FLEXIO_I2S_Deinit(FLEXIO_I2S_Type *base);
  196. /*!
  197. * @brief Enables/disables the FlexIO I2S module operation.
  198. *
  199. * @param base Pointer to FLEXIO_I2S_Type
  200. * @param enable True to enable, false dose not have any effect.
  201. */
  202. static inline void FLEXIO_I2S_Enable(FLEXIO_I2S_Type *base, bool enable)
  203. {
  204. if (enable)
  205. {
  206. base->flexioBase->CTRL |= FLEXIO_CTRL_FLEXEN_MASK;
  207. }
  208. }
  209. /*! @} */
  210. /*!
  211. * @name Status
  212. * @{
  213. */
  214. /*!
  215. * @brief Gets the FlexIO I2S status flags.
  216. *
  217. * @param base Pointer to FLEXIO_I2S_Type structure
  218. * @return Status flag, which are ORed by the enumerators in the _flexio_i2s_status_flags.
  219. */
  220. uint32_t FLEXIO_I2S_GetStatusFlags(FLEXIO_I2S_Type *base);
  221. /*! @} */
  222. /*!
  223. * @name Interrupts
  224. * @{
  225. */
  226. /*!
  227. * @brief Enables the FlexIO I2S interrupt.
  228. *
  229. * This function enables the FlexIO UART interrupt.
  230. *
  231. * @param base Pointer to FLEXIO_I2S_Type structure
  232. * @param mask interrupt source
  233. */
  234. void FLEXIO_I2S_EnableInterrupts(FLEXIO_I2S_Type *base, uint32_t mask);
  235. /*!
  236. * @brief Disables the FlexIO I2S interrupt.
  237. *
  238. * This function enables the FlexIO UART interrupt.
  239. *
  240. * @param base pointer to FLEXIO_I2S_Type structure
  241. * @param mask interrupt source
  242. */
  243. void FLEXIO_I2S_DisableInterrupts(FLEXIO_I2S_Type *base, uint32_t mask);
  244. /*! @} */
  245. /*!
  246. * @name DMA Control
  247. * @{
  248. */
  249. /*!
  250. * @brief Enables/disables the FlexIO I2S Tx DMA requests.
  251. *
  252. * @param base FlexIO I2S base pointer
  253. * @param enable True means enable DMA, false means disable DMA.
  254. */
  255. static inline void FLEXIO_I2S_TxEnableDMA(FLEXIO_I2S_Type *base, bool enable)
  256. {
  257. FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1 << base->txShifterIndex, enable);
  258. }
  259. /*!
  260. * @brief Enables/disables the FlexIO I2S Rx DMA requests.
  261. *
  262. * @param base FlexIO I2S base pointer
  263. * @param enable True means enable DMA, false means disable DMA.
  264. */
  265. static inline void FLEXIO_I2S_RxEnableDMA(FLEXIO_I2S_Type *base, bool enable)
  266. {
  267. FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1 << base->rxShifterIndex, enable);
  268. }
  269. /*!
  270. * @brief Gets the FlexIO I2S send data register address.
  271. *
  272. * This function returns the I2S data register address, mainly used by DMA/eDMA.
  273. *
  274. * @param base Pointer to FLEXIO_I2S_Type structure
  275. * @return FlexIO i2s send data register address.
  276. */
  277. static inline uint32_t FLEXIO_I2S_TxGetDataRegisterAddress(FLEXIO_I2S_Type *base)
  278. {
  279. return FLEXIO_GetShifterBufferAddress(base->flexioBase, kFLEXIO_ShifterBufferBitSwapped, base->txShifterIndex);
  280. }
  281. /*!
  282. * @brief Gets the FlexIO I2S receive data register address.
  283. *
  284. * This function returns the I2S data register address, mainly used by DMA/eDMA.
  285. *
  286. * @param base Pointer to FLEXIO_I2S_Type structure
  287. * @return FlexIO i2s receive data register address.
  288. */
  289. static inline uint32_t FLEXIO_I2S_RxGetDataRegisterAddress(FLEXIO_I2S_Type *base)
  290. {
  291. return FLEXIO_GetShifterBufferAddress(base->flexioBase, kFLEXIO_ShifterBufferBitSwapped, base->rxShifterIndex);
  292. }
  293. /*! @} */
  294. /*!
  295. * @name Bus Operations
  296. * @{
  297. */
  298. /*!
  299. * @brief Configures the FlexIO I2S audio format in master mode.
  300. *
  301. * Audio format can be changed in run-time of FlexIO I2S. This function configures the sample rate and audio data
  302. * format to be transferred.
  303. *
  304. * @param base Pointer to FLEXIO_I2S_Type structure
  305. * @param format Pointer to FlexIO I2S audio data format structure.
  306. * @param srcClock_Hz I2S master clock source frequency in Hz.
  307. */
  308. void FLEXIO_I2S_MasterSetFormat(FLEXIO_I2S_Type *base, flexio_i2s_format_t *format, uint32_t srcClock_Hz);
  309. /*!
  310. * @brief Configures the FlexIO I2S audio format in slave mode.
  311. *
  312. * Audio format can be changed in run-time of FlexIO I2S. This function configures the sample rate and audio data
  313. * format to be transferred.
  314. *
  315. * @param base Pointer to FLEXIO_I2S_Type structure
  316. * @param format Pointer to FlexIO I2S audio data format structure.
  317. */
  318. void FLEXIO_I2S_SlaveSetFormat(FLEXIO_I2S_Type *base, flexio_i2s_format_t *format);
  319. /*!
  320. * @brief Sends data using a blocking method.
  321. *
  322. * @note This function blocks via polling until data is ready to be sent.
  323. *
  324. * @param base FlexIO I2S base pointer.
  325. * @param bitWidth How many bits in a audio word, usually 8/16/24/32 bits.
  326. * @param txData Pointer to the data to be written.
  327. * @param size Bytes to be written.
  328. */
  329. void FLEXIO_I2S_WriteBlocking(FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *txData, size_t size);
  330. /*!
  331. * @brief Writes data into a data register.
  332. *
  333. * @param base FlexIO I2S base pointer.
  334. * @param bitWidth How many bits in a audio word, usually 8/16/24/32 bits.
  335. * @param data Data to be written.
  336. */
  337. static inline void FLEXIO_I2S_WriteData(FLEXIO_I2S_Type *base, uint8_t bitWidth, uint32_t data)
  338. {
  339. base->flexioBase->SHIFTBUFBIS[base->txShifterIndex] = (data << (32U - bitWidth));
  340. }
  341. /*!
  342. * @brief Receives a piece of data using a blocking method.
  343. *
  344. * @note This function blocks via polling until data is ready to be sent.
  345. *
  346. * @param base FlexIO I2S base pointer
  347. * @param bitWidth How many bits in a audio word, usually 8/16/24/32 bits.
  348. * @param rxData Pointer to the data to be read.
  349. * @param size Bytes to be read.
  350. */
  351. void FLEXIO_I2S_ReadBlocking(FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *rxData, size_t size);
  352. /*!
  353. * @brief Reads a data from the data register.
  354. *
  355. * @param base FlexIO I2S base pointer
  356. * @return Data read from data register.
  357. */
  358. static inline uint32_t FLEXIO_I2S_ReadData(FLEXIO_I2S_Type *base)
  359. {
  360. return base->flexioBase->SHIFTBUFBIS[base->rxShifterIndex];
  361. }
  362. /*! @} */
  363. /*!
  364. * @name Transactional
  365. * @{
  366. */
  367. /*!
  368. * @brief Initializes the FlexIO I2S handle.
  369. *
  370. * This function initializes the FlexIO I2S handle which can be used for other
  371. * FlexIO I2S transactional APIs. Call this API once to get the
  372. * initialized handle.
  373. *
  374. * @param base Pointer to FLEXIO_I2S_Type structure
  375. * @param handle Pointer to flexio_i2s_handle_t structure to store the transfer state.
  376. * @param callback FlexIO I2S callback function, which is called while finished a block.
  377. * @param userData User parameter for the FlexIO I2S callback.
  378. */
  379. void FLEXIO_I2S_TransferTxCreateHandle(FLEXIO_I2S_Type *base,
  380. flexio_i2s_handle_t *handle,
  381. flexio_i2s_callback_t callback,
  382. void *userData);
  383. /*!
  384. * @brief Configures the FlexIO I2S audio format.
  385. *
  386. * Audio format can be changed at run-time of FlexIO I2S. This function configures the sample rate and audio data
  387. * format to be transferred.
  388. *
  389. * @param base Pointer to FLEXIO_I2S_Type structure.
  390. * @param handle FlexIO I2S handle pointer.
  391. * @param format Pointer to audio data format structure.
  392. * @param srcClock_Hz FlexIO I2S bit clock source frequency in Hz. This parameter should be 0 while in slave mode.
  393. */
  394. void FLEXIO_I2S_TransferSetFormat(FLEXIO_I2S_Type *base,
  395. flexio_i2s_handle_t *handle,
  396. flexio_i2s_format_t *format,
  397. uint32_t srcClock_Hz);
  398. /*!
  399. * @brief Initializes the FlexIO I2S receive handle.
  400. *
  401. * This function initializes the FlexIO I2S handle which can be used for other
  402. * FlexIO I2S transactional APIs. Call this API once to get the
  403. * initialized handle.
  404. *
  405. * @param base Pointer to FLEXIO_I2S_Type structure.
  406. * @param handle Pointer to flexio_i2s_handle_t structure to store the transfer state.
  407. * @param callback FlexIO I2S callback function, which is called while finished a block.
  408. * @param userData User parameter for the FlexIO I2S callback.
  409. */
  410. void FLEXIO_I2S_TransferRxCreateHandle(FLEXIO_I2S_Type *base,
  411. flexio_i2s_handle_t *handle,
  412. flexio_i2s_callback_t callback,
  413. void *userData);
  414. /*!
  415. * @brief Performs an interrupt non-blocking send transfer on FlexIO I2S.
  416. *
  417. * @note The API returns immediately after transfer initiates.
  418. * Call FLEXIO_I2S_GetRemainingBytes to poll the transfer status and check whether
  419. * the transfer is finished. If the return status is 0, the transfer is finished.
  420. *
  421. * @param base Pointer to FLEXIO_I2S_Type structure.
  422. * @param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state
  423. * @param xfer Pointer to flexio_i2s_transfer_t structure
  424. * @retval kStatus_Success Successfully start the data transmission.
  425. * @retval kStatus_FLEXIO_I2S_TxBusy Previous transmission still not finished, data not all written to TX register yet.
  426. * @retval kStatus_InvalidArgument The input parameter is invalid.
  427. */
  428. status_t FLEXIO_I2S_TransferSendNonBlocking(FLEXIO_I2S_Type *base,
  429. flexio_i2s_handle_t *handle,
  430. flexio_i2s_transfer_t *xfer);
  431. /*!
  432. * @brief Performs an interrupt non-blocking receive transfer on FlexIO I2S.
  433. *
  434. * @note The API returns immediately after transfer initiates.
  435. * Call FLEXIO_I2S_GetRemainingBytes to poll the transfer status to check whether
  436. * the transfer is finished. If the return status is 0, the transfer is finished.
  437. *
  438. * @param base Pointer to FLEXIO_I2S_Type structure.
  439. * @param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state
  440. * @param xfer Pointer to flexio_i2s_transfer_t structure
  441. * @retval kStatus_Success Successfully start the data receive.
  442. * @retval kStatus_FLEXIO_I2S_RxBusy Previous receive still not finished.
  443. * @retval kStatus_InvalidArgument The input parameter is invalid.
  444. */
  445. status_t FLEXIO_I2S_TransferReceiveNonBlocking(FLEXIO_I2S_Type *base,
  446. flexio_i2s_handle_t *handle,
  447. flexio_i2s_transfer_t *xfer);
  448. /*!
  449. * @brief Aborts the current send.
  450. *
  451. * @note This API can be called at any time when interrupt non-blocking transfer initiates
  452. * to abort the transfer in a early time.
  453. *
  454. * @param base Pointer to FLEXIO_I2S_Type structure.
  455. * @param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state
  456. */
  457. void FLEXIO_I2S_TransferAbortSend(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle);
  458. /*!
  459. * @brief Aborts the current receive.
  460. *
  461. * @note This API can be called at any time when interrupt non-blocking transfer initiates
  462. * to abort the transfer in a early time.
  463. *
  464. * @param base Pointer to FLEXIO_I2S_Type structure.
  465. * @param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state
  466. */
  467. void FLEXIO_I2S_TransferAbortReceive(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle);
  468. /*!
  469. * @brief Gets the remaining bytes to be sent.
  470. *
  471. * @param base Pointer to FLEXIO_I2S_Type structure.
  472. * @param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state
  473. * @param count Bytes sent.
  474. * @retval kStatus_Success Succeed get the transfer count.
  475. * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.
  476. */
  477. status_t FLEXIO_I2S_TransferGetSendCount(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, size_t *count);
  478. /*!
  479. * @brief Gets the remaining bytes to be received.
  480. *
  481. * @param base Pointer to FLEXIO_I2S_Type structure.
  482. * @param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state
  483. * @return count Bytes received.
  484. * @retval kStatus_Success Succeed get the transfer count.
  485. * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.
  486. */
  487. status_t FLEXIO_I2S_TransferGetReceiveCount(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, size_t *count);
  488. /*!
  489. * @brief Tx interrupt handler.
  490. *
  491. * @param i2sBase Pointer to FLEXIO_I2S_Type structure.
  492. * @param i2sHandle Pointer to flexio_i2s_handle_t structure
  493. */
  494. void FLEXIO_I2S_TransferTxHandleIRQ(void *i2sBase, void *i2sHandle);
  495. /*!
  496. * @brief Rx interrupt handler.
  497. *
  498. * @param i2sBase Pointer to FLEXIO_I2S_Type structure.
  499. * @param i2sHandle Pointer to flexio_i2s_handle_t structure.
  500. */
  501. void FLEXIO_I2S_TransferRxHandleIRQ(void *i2sBase, void *i2sHandle);
  502. /*! @} */
  503. #if defined(__cplusplus)
  504. }
  505. #endif /*_cplusplus*/
  506. /*! @} */
  507. #endif /* _FSL_FLEXIO_I2S_H_ */