Is there a way to get I2S to work in full duplex mode using DMA and 2 separate buffers, one for read and one for write?
I can get it to send data using i2s_write, but I can't get it to simultaneously read with i2s_read the data I send out, like I would expect form a full duplex operation.
My config info looks like this:
Code: Select all
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX, // Full duplex
.sample_rate = SAMPLE_RATE,
.bits_per_sample = 16,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //2-channels
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 16,
.dma_buf_len = 128,
.use_apll = false,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 //Interrupt level 1
};
i2s_pin_config_t pin_config = {
.bck_io_num = 26,
.ws_io_num = 25,
.data_out_num = 22,
.data_in_num = 23
};
i2s_driver_install(I2S_NUM, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM, &pin_config);
And somewhere in main I'm trying to send data with 0 timeout to get the function to return right away followed by the receive function:
Code: Select all
err = i2s_write(I2S_NUM, samples_tx, samples, &i2s_bytes_write, 0);
err = i2s_read(I2S_NUM, samples_rx, samples, &i2s_bytes_read, 100);
What's even more interesting is that i2s_bytes_read is always equal to i2s_bytes_write, even if I remove the connection between DOUT and DIN.
I'm using an ESP32_Core_board_V2.
Many thanks!