fsl_flexio_i2s.h 22 KB

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