Advertisement
Guest User

Untitled

a guest
May 15th, 2025
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. void setupI2S() {
  2.   i2s_config_t cfg = {
  3.     .mode                 = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_TX),
  4.     .sample_rate          = SAMPLE_RATE,
  5.     .bits_per_sample      = I2S_BITS_PER_SAMPLE_16BIT,
  6.     .channel_format       = I2S_CHANNEL_FMT_RIGHT_LEFT,
  7.     .communication_format = I2S_COMM_FORMAT_I2S,
  8.     .intr_alloc_flags     = ESP_INTR_FLAG_LEVEL1,
  9.     .dma_buf_count        = DMA_BUF_COUNT,
  10.     .dma_buf_len          = DMA_BUF_LEN,
  11.     .use_apll             = true,
  12.     .tx_desc_auto_clear   = false
  13.   };
  14.   i2s_pin_config_t pins = {
  15.     .bck_io_num   = I2S_BCLK_PIN,
  16.     .ws_io_num    = I2S_LRC_PIN,
  17.     .data_out_num = I2S_DOUT_PIN,
  18.     .data_in_num  = I2S_PIN_NO_CHANGE
  19.   };
  20.   i2s_driver_install(I2S_PORT, &cfg, 0, nullptr);
  21.   i2s_set_pin(I2S_PORT, &pins);
  22.   i2s_set_clk(I2S_PORT, SAMPLE_RATE, I2S_BITS_PER_SAMPLE_16BIT, I2S_CHANNEL_STEREO);
  23.   i2s_zero_dma_buffer(I2S_PORT);
  24.   i2s_start(I2S_PORT);
  25.   logMsg("[I2S] ready");
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement