ES9018AudioSink.cpp 972 B

1234567891011121314151617181920212223242526272829303132
  1. #include "ES9018AudioSink.h"
  2. #include "driver/i2s.h"
  3. ES9018AudioSink::ES9018AudioSink() {
  4. i2s_config_t i2s_config = {
  5. .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX), // Only TX
  6. .sample_rate = 44100,
  7. .bits_per_sample = (i2s_bits_per_sample_t)16,
  8. .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //2-channels
  9. .communication_format = (i2s_comm_format_t)I2S_COMM_FORMAT_STAND_MSB,
  10. .intr_alloc_flags = 0, //Default interrupt priority
  11. .dma_buf_count = 8,
  12. .dma_buf_len = 512,
  13. .use_apll = true,
  14. .tx_desc_auto_clear = true, //Auto clear tx descriptor on underflow
  15. .fixed_mclk = 384 * 44100};
  16. i2s_pin_config_t pin_config = {
  17. .bck_io_num = 27,
  18. .ws_io_num = 32,
  19. .data_out_num = 25,
  20. .data_in_num = -1 //Not used
  21. };
  22. i2s_driver_install((i2s_port_t)0, &i2s_config, 0, NULL);
  23. i2s_set_pin((i2s_port_t)0, &pin_config);
  24. startI2sFeed();
  25. }
  26. ES9018AudioSink::~ES9018AudioSink() {}