i2s_sync.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. // DO NOT USE THESE APIS IN YOUR APPLICATIONS
  7. // The following APIs are for internal use, public to other IDF components, but not for users' applications.
  8. /**
  9. * This file is used for getting the bclk and fifo sending count
  10. * for the synchronization among different I2S ports.
  11. *
  12. * The APIs in this file might be called frequently, so they are made light-weight and flexible to be called
  13. *
  14. * NOTE: These APIs are private for ESP internal usages.
  15. * Please be aware of the risk that APIs might be changed regarding the use case.
  16. */
  17. #pragma once
  18. #include <stdint.h>
  19. #include "driver/i2s_types.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #if SOC_I2S_SUPPORTS_TX_SYNC_CNT
  24. /**
  25. * @brief Get the counter number of BCLK ticks
  26. * @note The BCLK tick count reflects the real data that have sent on line
  27. *
  28. * @param[in] tx_handle The I2S tx channel handle
  29. * @return
  30. * - BCLK tick count
  31. */
  32. uint32_t i2s_sync_get_bclk_count(i2s_chan_handle_t tx_handle);
  33. /**
  34. * @brief Get the counter number of fifo
  35. * @note The FIFO count reflects how many slots have processed
  36. * Normally, fifo_cnt = slot_bit_width * bclk_cnt
  37. * If fifo_cnt < slot_bit_width * bclk_cnt, that means some data are still stuck in the I2S controller
  38. *
  39. * @param[in] tx_handle The I2S tx channel handle
  40. * @return
  41. * - FIFO slot count
  42. */
  43. uint32_t i2s_sync_get_fifo_count(i2s_chan_handle_t tx_handle);
  44. /**
  45. * @brief Reset the bclk counter
  46. *
  47. * @param[in] tx_handle The I2S tx channel handle
  48. */
  49. void i2s_sync_reset_bclk_count(i2s_chan_handle_t tx_handle);
  50. /**
  51. * @brief Reset the fifo counter
  52. *
  53. * @param[in] tx_handle The I2S tx channel handle
  54. */
  55. void i2s_sync_reset_fifo_count(i2s_chan_handle_t tx_handle);
  56. #endif // SOC_I2S_SUPPORTS_TX_SYNC_CNT
  57. #ifdef __cplusplus
  58. }
  59. #endif