I feel that I must be missing something. I'm building for the devkit-v1 using espidf 4.0.1 under platformio.
There are no examples of I2S Rx, only I2S Tx Master mode.
I'm setting the config as follows :
Code: Untitled.c Select all
i2s_config_t i2s_config = {
.mode = I2S_MODE_SLAVE | I2S_MODE_RX,
.sample_rate = 31250,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 6,
.dma_buf_len = 256,
.use_apll = false,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 //Interrupt level 1
};
i2s_pin_config_t pin_config = {
.bck_io_num = GPIO_NUM_21,
.ws_io_num = GPIO_NUM_19,
.data_out_num = -1, // Not used
.data_in_num = GPIO_NUM_22
};
I then call i2s_driver_install(). Looking at the source this allocates some config memory for the device. It adds an interrupt handler. It then calls i2s_set_clk() which sets up a DMA Queue in turn calls i2s_start().
How can it is2_start() work when I haven't yet assigned the IO pins?
Code: Untitled.c Select all
err = i2s_driver_install(I2S_NUM_0, & i2s_config, 0, 0);
if (err != ESP_OK)
{
ESP_LOGI(TAG, "i2s_driver_install %d", err);
}
err= i2s_set_pin(I2S_NUM_0, & pin_config);
if (err != ESP_OK)
{
ESP_LOGI(TAG, "i2s_set_pin %d", err);
}
If I then try to read data, I get a timeout and zero data.
Code: Untitled.c Select all
esp_err_t err = i2s_read(I2S_NUM_0, buff, sizeof(buff), & read, 10);
