hpm_i2s_drv.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_I2S_DRV_H
  8. #define HPM_I2S_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_soc_feature.h"
  11. #include "hpm_i2s_regs.h"
  12. #include "hpm_i2s_common.h"
  13. /**
  14. * @brief I2S driver APIs
  15. * @defgroup i2s_interface I2S driver APIs
  16. * @ingroup io_interfaces
  17. * @{
  18. */
  19. /**
  20. * @brief I2S data line
  21. */
  22. #define I2S_DATA_LINE_0 (0U)
  23. #define I2S_DATA_LINE_1 (1U)
  24. #define I2S_DATA_LINE_2 (2U)
  25. #define I2S_DATA_LINE_3 (3U)
  26. #define I2S_DATA_LINE_MAX I2S_DATA_LINE_3
  27. /**
  28. * @brief I2S config
  29. */
  30. typedef struct i2s_config {
  31. bool invert_mclk_out;
  32. bool invert_mclk_in;
  33. bool use_external_mclk;
  34. bool invert_bclk_out;
  35. bool invert_bclk_in;
  36. bool use_external_bclk;
  37. bool invert_fclk_out;
  38. bool invert_fclk_in;
  39. bool use_external_fclk;
  40. bool enable_mclk_out;
  41. bool frame_start_at_rising_edge;
  42. uint16_t tx_fifo_threshold;
  43. uint16_t rx_fifo_threshold;
  44. } i2s_config_t;
  45. /**
  46. * @brief I2S transfer config
  47. */
  48. typedef struct i2x_transfer_config {
  49. uint32_t sample_rate;
  50. bool enable_tdm_mode;
  51. uint8_t channel_num_per_frame;
  52. uint8_t channel_length; /* 16-bit or 32-bit */
  53. uint8_t audio_depth; /* 16-bit, 24-bit, 32-bit */
  54. bool master_mode;
  55. uint8_t protocol;
  56. uint8_t data_line;
  57. uint32_t channel_slot_mask;
  58. } i2s_transfer_config_t;
  59. typedef enum {
  60. i2s_tx_fifo_threshold_irq_mask = I2S_CTRL_TXDNIE_MASK,
  61. i2s_rx_fifo_threshold_irq_mask = I2S_CTRL_RXDAIE_MASK,
  62. i2s_fifo_error_irq_mask = I2S_CTRL_ERRIE_MASK, /*<! rx fifo overrun, tx fifo underrun */
  63. } i2s_irq_mask_t;
  64. typedef enum {
  65. i2s_data_line_rx_fifo_avail = 1U, /*<! data avail */
  66. i2s_data_line_tx_fifo_avail = 2U, /*<! fifo empty avail */
  67. i2s_data_line_rx_fifo_overrun = 4U,
  68. i2s_data_line_tx_fifo_underrun = 8U,
  69. } i2s_data_line_stat_t;
  70. #ifdef __cplusplus
  71. extern "C" {
  72. #endif
  73. /**
  74. * @brief enable TDM
  75. *
  76. * @param [in] ptr I2S base address
  77. */
  78. static inline void i2s_enable_tdm(I2S_Type *ptr)
  79. {
  80. ptr->CFGR |= I2S_CFGR_TDM_EN_MASK;
  81. }
  82. /**
  83. * @brief disable TDM
  84. *
  85. * @param [in] ptr I2S base address
  86. */
  87. static inline void i2s_disable_tdm(I2S_Type *ptr)
  88. {
  89. ptr->CFGR &= ~I2S_CFGR_TDM_EN_MASK;
  90. }
  91. /**
  92. * @brief update rx fifo threshold
  93. *
  94. * @param [in] ptr I2S base address
  95. * @param [in] threshold fifo threshold value
  96. */
  97. static inline void i2s_update_rx_fifo_threshold(I2S_Type *ptr, uint8_t threshold)
  98. {
  99. ptr->FIFO_THRESH = (ptr->FIFO_THRESH & ~I2S_FIFO_THRESH_RX_MASK)
  100. | I2S_FIFO_THRESH_RX_SET(threshold);
  101. }
  102. /**
  103. * @brief update tx fifo threshold
  104. *
  105. * @param [in] ptr I2S base address
  106. * @param [in] threshold fifo threshold value
  107. */
  108. static inline void i2s_update_tx_fifo_threshold(I2S_Type *ptr, uint8_t threshold)
  109. {
  110. ptr->FIFO_THRESH = (ptr->FIFO_THRESH & ~I2S_FIFO_THRESH_TX_MASK)
  111. | I2S_FIFO_THRESH_TX_SET(threshold);
  112. }
  113. /**
  114. * @brief open BCLK
  115. *
  116. * @param [in] ptr I2S base address
  117. */
  118. static inline void i2s_ungate_bclk(I2S_Type *ptr)
  119. {
  120. ptr->CFGR &= ~I2S_CFGR_BCLK_GATEOFF_MASK;
  121. }
  122. /**
  123. * @brief gete off BCLK
  124. *
  125. * @param [in] ptr I2S base address
  126. */
  127. static inline void i2s_gate_bclk(I2S_Type *ptr)
  128. {
  129. ptr->CFGR |= I2S_CFGR_BCLK_GATEOFF_MASK;
  130. }
  131. /**
  132. * @brief open MCLK
  133. *
  134. * @param [in] ptr I2S base address
  135. */
  136. static inline void i2s_ungate_mclk(I2S_Type *ptr)
  137. {
  138. ptr->MISC_CFGR &= ~I2S_MISC_CFGR_MCLK_GATEOFF_MASK;
  139. }
  140. /**
  141. * @brief gate off MCLK
  142. *
  143. * @param [in] ptr I2S base address
  144. */
  145. static inline void i2s_gate_mclk(I2S_Type *ptr)
  146. {
  147. ptr->MISC_CFGR |= I2S_MISC_CFGR_MCLK_GATEOFF_MASK;
  148. }
  149. /**
  150. * @brief enable TX dma request
  151. *
  152. * @param [in] ptr I2S base address
  153. */
  154. static inline void i2s_enable_tx_dma_request(I2S_Type *ptr)
  155. {
  156. ptr->CTRL |= I2S_CTRL_TX_DMA_EN_MASK;
  157. }
  158. /**
  159. * @brief disable TX dma request
  160. *
  161. * @param [in] ptr I2S base address
  162. */
  163. static inline void i2s_disable_tx_dma_request(I2S_Type *ptr)
  164. {
  165. ptr->CTRL &= ~I2S_CTRL_TX_DMA_EN_MASK;
  166. }
  167. /**
  168. * @brief enable RX dma request
  169. *
  170. * @param [in] ptr I2S base address
  171. */
  172. static inline void i2s_enable_rx_dma_request(I2S_Type *ptr)
  173. {
  174. ptr->CTRL |= I2S_CTRL_RX_DMA_EN_MASK;
  175. }
  176. /**
  177. * @brief disable RX dma request
  178. *
  179. * @param [in] ptr I2S base address
  180. */
  181. static inline void i2s_disable_rx_dma_request(I2S_Type *ptr)
  182. {
  183. ptr->CTRL &= ~I2S_CTRL_RX_DMA_EN_MASK;
  184. }
  185. /**
  186. * @brief enable IRQ
  187. *
  188. * @param [in] ptr I2S base address
  189. * @param [in] mask irq bit mask
  190. */
  191. static inline void i2s_enable_irq(I2S_Type *ptr, uint32_t mask)
  192. {
  193. ptr->CTRL |= mask;
  194. }
  195. /**
  196. * @brief disable IRQ
  197. *
  198. * @param [in] ptr I2S base address
  199. * @param [in] mask irq bit mask
  200. */
  201. static inline void i2s_disable_irq(I2S_Type *ptr, uint32_t mask)
  202. {
  203. ptr->CTRL &= ~mask;
  204. }
  205. /**
  206. * @brief I2S enable
  207. *
  208. * @note dropped API, please use i2s_start
  209. *
  210. * @param [in] ptr I2S base address
  211. */
  212. static inline void i2s_enable(I2S_Type *ptr)
  213. {
  214. ptr->CTRL |= I2S_CTRL_I2S_EN_MASK;
  215. }
  216. /**
  217. * @brief I2S disable
  218. *
  219. * @note dropped API, please use i2s_stop
  220. *
  221. * @param [in] ptr I2S base address
  222. */
  223. static inline void i2s_disable(I2S_Type *ptr)
  224. {
  225. ptr->CTRL &= ~I2S_CTRL_I2S_EN_MASK;
  226. }
  227. /**
  228. * @brief I2S start
  229. *
  230. * @param [in] ptr I2S base address
  231. */
  232. static inline void i2s_start(I2S_Type *ptr)
  233. {
  234. ptr->CTRL |= I2S_CTRL_I2S_EN_MASK;
  235. }
  236. /**
  237. * @brief I2S stop
  238. *
  239. * @param [in] ptr I2S base address
  240. */
  241. static inline void i2s_stop(I2S_Type *ptr)
  242. {
  243. ptr->CTRL &= ~I2S_CTRL_I2S_EN_MASK;
  244. }
  245. /**
  246. * @brief I2S enable rx function
  247. *
  248. * @param [in] ptr I2S base address
  249. * @param [in] rx_mask rx data line mask
  250. */
  251. static inline void i2s_enable_rx(I2S_Type *ptr, uint8_t rx_mask)
  252. {
  253. ptr->CTRL |= I2S_CTRL_RX_EN_SET(rx_mask);
  254. }
  255. /**
  256. * @brief I2S disable rx function
  257. *
  258. * @param [in] ptr I2S base address
  259. * @param [in] rx_mask rx data line mask
  260. */
  261. static inline void i2s_disable_rx(I2S_Type *ptr, uint8_t rx_mask)
  262. {
  263. ptr->CTRL &= ~I2S_CTRL_RX_EN_SET(rx_mask);
  264. }
  265. /**
  266. * @brief I2S enable tx function
  267. *
  268. * @param [in] ptr I2S base address
  269. * @param [in] tx_mask tx data line mask
  270. */
  271. static inline void i2s_enable_tx(I2S_Type *ptr, uint8_t tx_mask)
  272. {
  273. ptr->CTRL |= I2S_CTRL_TX_EN_SET(tx_mask);
  274. }
  275. /**
  276. * @brief I2S disbale tx function
  277. *
  278. * @param [in] ptr I2S base address
  279. * @param [in] tx_mask tx data line mask
  280. */
  281. static inline void i2s_disable_tx(I2S_Type *ptr, uint8_t tx_mask)
  282. {
  283. ptr->CTRL &= ~I2S_CTRL_TX_EN_SET(tx_mask);
  284. }
  285. /**
  286. * @brief I2S reset clock generator
  287. *
  288. * @param [in] ptr I2S base address
  289. */
  290. static inline void i2s_reset_clock_gen(I2S_Type *ptr)
  291. {
  292. ptr->CTRL |= I2S_CTRL_SFTRST_CLKGEN_MASK;
  293. ptr->CTRL &= ~I2S_CTRL_SFTRST_CLKGEN_MASK;
  294. }
  295. /**
  296. * @brief I2S reset tx function
  297. *
  298. * @note This API will disable I2S, reset tx function
  299. * Please ensure that there is a valid BCLK when calling this function
  300. *
  301. * @param [in] ptr I2S base address
  302. */
  303. static inline void i2s_reset_tx(I2S_Type *ptr)
  304. {
  305. /* disable I2S */
  306. ptr->CTRL &= ~I2S_CTRL_I2S_EN_MASK;
  307. /* reset tx and clear fifo */
  308. ptr->CTRL |= (I2S_CTRL_TXFIFOCLR_MASK | I2S_CTRL_SFTRST_TX_MASK);
  309. ptr->CTRL &= ~(I2S_CTRL_TXFIFOCLR_MASK | I2S_CTRL_SFTRST_TX_MASK);
  310. }
  311. /**
  312. * @brief I2S reset rx function
  313. *
  314. * @note This API will disable I2S, reset rx function
  315. * Please ensure that there is a valid BCLK when calling this function
  316. *
  317. * @param [in] ptr I2S base address
  318. */
  319. static inline void i2s_reset_rx(I2S_Type *ptr)
  320. {
  321. /* disable I2S */
  322. ptr->CTRL &= ~I2S_CTRL_I2S_EN_MASK;
  323. /* reset rx and clear fifo */
  324. ptr->CTRL |= (I2S_CTRL_RXFIFOCLR_MASK | I2S_CTRL_SFTRST_RX_MASK);
  325. ptr->CTRL &= ~(I2S_CTRL_RXFIFOCLR_MASK | I2S_CTRL_SFTRST_RX_MASK);
  326. }
  327. /**
  328. * @brief I2S reset tx and rx function
  329. *
  330. * @note This API will disable I2S, reset tx/rx function
  331. * Please ensure that there is a valid BCLK when calling this function
  332. *
  333. * @param [in] ptr I2S base address
  334. */
  335. static inline void i2s_reset_tx_rx(I2S_Type *ptr)
  336. {
  337. /* disable I2S */
  338. ptr->CTRL &= ~I2S_CTRL_I2S_EN_MASK;
  339. /* reset tx/rx and clear fifo */
  340. ptr->CTRL |= (I2S_CTRL_TXFIFOCLR_MASK | I2S_CTRL_RXFIFOCLR_MASK | I2S_CTRL_SFTRST_TX_MASK | I2S_CTRL_SFTRST_RX_MASK);
  341. ptr->CTRL &= ~(I2S_CTRL_TXFIFOCLR_MASK | I2S_CTRL_RXFIFOCLR_MASK | I2S_CTRL_SFTRST_TX_MASK | I2S_CTRL_SFTRST_RX_MASK);
  342. }
  343. /**
  344. * @brief I2S reset tx/rx and clock generator module
  345. *
  346. * @note This API will disable I2S, reset tx/rx and clock generator module
  347. * This function uses an internal clock to generate BCLK, then do reset operation,
  348. * and finally restores the previous clock settings
  349. *
  350. * @param [in] ptr I2S base address
  351. */
  352. void i2s_reset_all(I2S_Type *ptr);
  353. /**
  354. * @brief I2S get tx fifo level
  355. *
  356. * @param [in] ptr I2S base address
  357. *
  358. * @retval I2S tx fifo level
  359. */
  360. static inline uint32_t i2s_get_tx_fifo_level(I2S_Type *ptr)
  361. {
  362. return ptr->TFIFO_FILLINGS;
  363. }
  364. /**
  365. * @brief I2S get data line tx fifo level
  366. *
  367. * @param [in] ptr I2S base address
  368. * @param [in] line I2S data line
  369. *
  370. * @retval I2S data line tx fifo level
  371. */
  372. static inline uint32_t i2s_get_tx_line_fifo_level(I2S_Type *ptr, uint8_t line)
  373. {
  374. return (i2s_get_tx_fifo_level(ptr) & (0xFF << (line << 3))) >> (line << 3);
  375. }
  376. /**
  377. * @brief I2S get rx fifo level
  378. *
  379. * @param [in] ptr I2S base address
  380. *
  381. * @retval I2S rx fifo level
  382. */
  383. static inline uint32_t i2s_get_rx_fifo_level(I2S_Type *ptr)
  384. {
  385. return ptr->RFIFO_FILLINGS;
  386. }
  387. /**
  388. * @brief I2S get data line rx fifo level
  389. *
  390. * @param [in] ptr I2S base address
  391. * @param [in] line I2S data line
  392. *
  393. * @retval I2S data line rx fifo level
  394. */
  395. static inline uint32_t i2s_get_rx_line_fifo_level(I2S_Type *ptr, uint8_t line)
  396. {
  397. return (i2s_get_rx_fifo_level(ptr) & (0xFF << (line << 3))) >> (line << 3);
  398. }
  399. /**
  400. * @brief Check I2S data line status
  401. *
  402. * @param[in] ptr I2S base address
  403. * @param[in] line I2S data line
  404. *
  405. * @retval i2s_data_line_rx_fifo_avail data in rx fifo >= threshold
  406. * @retval i2s_data_line_tx_fifo_avail data in tx fifo <= threshold
  407. * @retval i2s_data_line_rx_fifo_overrun rx fifo overrun occured
  408. * @retval i2s_data_line_tx_fifo_underrun tx fifo underrun occured
  409. */
  410. static inline uint32_t i2s_check_data_line_status(I2S_Type *ptr, uint8_t line)
  411. {
  412. volatile uint32_t reg_val = ptr->STA;
  413. uint32_t bit_mask;
  414. uint32_t stat = 0;
  415. bit_mask = 1 << (I2S_STA_RX_DA_SHIFT + line);
  416. if ((bit_mask & reg_val) != 0) {
  417. stat |= i2s_data_line_rx_fifo_avail;
  418. }
  419. bit_mask = 1 << (I2S_STA_TX_DN_SHIFT + line);
  420. if ((bit_mask & reg_val) != 0) {
  421. stat |= i2s_data_line_tx_fifo_avail;
  422. }
  423. bit_mask = 1 << (I2S_STA_RX_OV_SHIFT + line);
  424. if ((bit_mask & reg_val) != 0) {
  425. stat |= i2s_data_line_rx_fifo_overrun;
  426. ptr->STA = bit_mask; /* clear flag: W1C*/
  427. }
  428. bit_mask = 1 << (I2S_STA_TX_UD_SHIFT + line);
  429. if ((bit_mask & reg_val) != 0) {
  430. stat |= i2s_data_line_tx_fifo_underrun;
  431. ptr->STA = bit_mask; /* clear flag: W1C*/
  432. }
  433. return stat;
  434. }
  435. /**
  436. * @brief I2S get IRQ status
  437. *
  438. * @param [in] ptr I2S base address
  439. *
  440. * @retval I2S STA register value
  441. */
  442. static inline uint32_t i2s_get_irq_status(I2S_Type *ptr)
  443. {
  444. return ptr->STA;
  445. }
  446. /**
  447. * @brief I2S stop transfer
  448. *
  449. * @param [in] ptr I2S base address
  450. */
  451. static inline void i2s_stop_transfer(I2S_Type *ptr)
  452. {
  453. i2s_disable(ptr);
  454. }
  455. /**
  456. * @brief I2S config tx
  457. *
  458. * @note This API will disable I2S and configure parameters, could call i2s_enable() to enable I2S
  459. *
  460. * @param [in] ptr I2S base address
  461. * @param [in] mclk_in_hz mclk frequency in Hz
  462. * @param [in] config i2s_transfer_config_t
  463. * @retval hpm_stat_t status_invalid_argument or status_success
  464. */
  465. hpm_stat_t i2s_config_tx(I2S_Type *ptr, uint32_t mclk_in_hz, i2s_transfer_config_t *config);
  466. /**
  467. * @brief I2S config tx for slave
  468. *
  469. * @note This API will disable I2S and configure parameters, could call i2s_enable() to enable I2S
  470. *
  471. * @param [in] ptr I2S base address
  472. * @param [in] config i2s_transfer_config_t
  473. */
  474. hpm_stat_t i2s_config_tx_slave(I2S_Type *ptr, i2s_transfer_config_t *config);
  475. /**
  476. * @brief I2S config rx
  477. *
  478. * @note This API will disable I2S and configure parameters, could call i2s_enable() to enable I2S
  479. *
  480. * @param [in] ptr I2S base address
  481. * @param [in] mclk_in_hz mclk frequency in Hz
  482. * @param [in] config i2s_transfer_config_t
  483. * @retval hpm_stat_t status_invalid_argument or status_success
  484. */
  485. hpm_stat_t i2s_config_rx(I2S_Type *ptr, uint32_t mclk_in_hz, i2s_transfer_config_t *config);
  486. /**
  487. * @brief I2S config rx for slave
  488. *
  489. * @note This API will disable I2S and configure parameters, could call i2s_enable() to enable I2S
  490. *
  491. * @param [in] ptr I2S base address
  492. * @param [in] config i2s_transfer_config_t
  493. * @retval hpm_stat_t status_invalid_argument or status_success
  494. */
  495. hpm_stat_t i2s_config_rx_slave(I2S_Type *ptr, i2s_transfer_config_t *config);
  496. /**
  497. * @brief I2S config transfer
  498. *
  499. * @note This API will disable I2S and configure parameters, could call i2s_enable() to enable I2S
  500. *
  501. * @param [in] ptr I2S base address
  502. * @param [in] mclk_in_hz mclk frequency in Hz
  503. * @param [in] config i2s_transfer_config_t
  504. * @retval hpm_stat_t status_invalid_argument or status_success
  505. */
  506. hpm_stat_t i2s_config_transfer(I2S_Type *ptr, uint32_t mclk_in_hz, i2s_transfer_config_t *config);
  507. /**
  508. * @brief I2S config transfer for slave
  509. *
  510. * @note This API will disable I2S and configure parameters, could call i2s_enable() to enable I2S
  511. *
  512. * @param [in] ptr I2S base address
  513. * @param [in] config i2s_transfer_config_t
  514. * @retval hpm_stat_t status_invalid_argument or status_success
  515. */
  516. hpm_stat_t i2s_config_transfer_slave(I2S_Type *ptr, i2s_transfer_config_t *config);
  517. /**
  518. * @brief I2S send data
  519. *
  520. * @param [in] ptr I2S base address
  521. * @param [in] tx_line_index data line
  522. * @param [in] data data to be written
  523. */
  524. static inline void i2s_send_data(I2S_Type *ptr, uint8_t tx_line_index, uint32_t data)
  525. {
  526. ptr->TXD[tx_line_index] = data;
  527. }
  528. /**
  529. * @brief I2S receive data
  530. *
  531. * @param [in] ptr I2S base address
  532. * @param [in] rx_line_index data line
  533. * @param [out] data point to store data address
  534. */
  535. static inline void i2s_receive_data(I2S_Type *ptr, uint8_t rx_line_index, uint32_t *data)
  536. {
  537. *data = ptr->RXD[rx_line_index];
  538. }
  539. /**
  540. * @brief I2S send data in buff
  541. *
  542. * @param [in] ptr I2S base address
  543. * @param [in] tx_line_index data line
  544. * @param [in] samplebits audio data width
  545. * @param [in] src source data buff
  546. * @param [in] size data size
  547. *
  548. * @retval I2S sent data size in byte
  549. */
  550. uint32_t i2s_send_buff(I2S_Type *ptr, uint8_t tx_line_index, uint8_t samplebits, uint8_t *src, uint32_t size);
  551. /**
  552. * @brief I2S receive data in buff
  553. *
  554. * @param [in] ptr I2S base address
  555. * @param [in] rx_line_index data line
  556. * @param [in] samplebits audio data width
  557. * @param [out] dst target data buff
  558. * @param [in] size data size
  559. *
  560. * @retval I2S sent data size in byte
  561. */
  562. uint32_t i2s_receive_buff(I2S_Type *ptr, uint8_t rx_line_index, uint8_t samplebits, uint8_t *dst, uint32_t size);
  563. /**
  564. * @brief I2S get default config
  565. *
  566. * @param [in] ptr I2S base address
  567. * @param [out] config i2s_config_t
  568. */
  569. void i2s_get_default_config(I2S_Type *ptr, i2s_config_t *config);
  570. /**
  571. * @brief I2S initialization
  572. *
  573. * @param [in] ptr I2S base address
  574. * @param [in] config i2s_config_t
  575. */
  576. void i2s_init(I2S_Type *ptr, i2s_config_t *config);
  577. /**
  578. * @brief I2S get default transfer config for pdm
  579. *
  580. * @param [out] transfer i2s_transfer_config_t
  581. */
  582. void i2s_get_default_transfer_config_for_pdm(i2s_transfer_config_t *transfer);
  583. /**
  584. * @brief I2S get default transfer config for dao
  585. *
  586. * @param [out] transfer i2s_transfer_config_t
  587. */
  588. void i2s_get_default_transfer_config_for_dao(i2s_transfer_config_t *transfer);
  589. /**
  590. * @brief I2S get default transfer config
  591. *
  592. * @param [out] transfer i2s_transfer_config_t
  593. */
  594. void i2s_get_default_transfer_config(i2s_transfer_config_t *transfer);
  595. /**
  596. * @brief I2S fill dummy data into TX fifo
  597. *
  598. * @note workaround: fill dummy data into TX fifo to avoid TX underflow during tx start
  599. *
  600. * @param [in] ptr I2S base address
  601. * @param [in] data_line data line
  602. * @param [in] data_count dummy data count, This value should be the same as the number of audio channels
  603. *
  604. * @retval status_success if no error occurred
  605. */
  606. hpm_stat_t i2s_fill_tx_dummy_data(I2S_Type *ptr, uint8_t data_line, uint8_t data_count);
  607. /**
  608. * @}
  609. */
  610. #ifdef __cplusplus
  611. }
  612. #endif
  613. #endif /* HPM_I2S_DRV_H */