I have read the data sent with a logic analyzer and the information is complete (a little ugly due to noise issues, but complete)
This is the information read with the logic analyzer.
The code I am using is the following
Code: Select all
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <math.h>
#include "i2s_driver.h"
#define BUFF_SIZE_I2S 1024
static i2s_chan_handle_t rx_chan; // I2S rx channel handler
uint16_t *r_buf;
size_t r_bytes=0;
int16_t *chan_1=NULL;
int16_t *chan_2=NULL;
void i2s_configure_channel(){
r_buf=(uint16_t *)calloc(2,BUFF_SIZE_I2S);
i2s_chan_config_t chan_cfg ={
.id=I2S_NUM_AUTO,
.role = I2S_ROLE_MASTER,
.dma_desc_num=16*2,
.dma_frame_num = 2048*2,
.auto_clear = false
};
ESP_ERROR_CHECK(i2s_new_channel(&chan_cfg,NULL, &rx_chan));
i2s_std_config_t std_cfg = {
.clk_cfg = {
.sample_rate_hz = 44100,
.clk_src = I2S_CLK_SRC_DEFAULT,//I2S_CLK_SRC_DEFAULT,I2S_CLK_SRC_PLL_160M,I2S_CLK_SRC_APLL
.mclk_multiple = I2S_MCLK_MULTIPLE_256,
},
.slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO),
.gpio_cfg = {
.mclk = GPIO_NUM_0,
.bclk = GPIO_NUM_19,
.ws = GPIO_NUM_22,
.dout = GPIO_NUM_21,
.din = GPIO_NUM_17, // In duplex mode, bind output and input to a same gpio can loopback internally
.invert_flags = {
.mclk_inv = false,
.bclk_inv = false,
.ws_inv = false,
},
},
};
ESP_ERROR_CHECK(i2s_channel_init_std_mode(rx_chan, &std_cfg));
}
uint16_t* i2s_raw(){
i2s_channel_enable(rx_chan);
if (i2s_channel_read(rx_chan, r_buf, BUFF_SIZE_I2S, &r_bytes, 2000)!= ESP_OK){
printf("Read Task: i2s read failed\n");
}
i2s_channel_disable(rx_chan);
return r_buf;
}
I don't know what to do anymore, it's for my thesis!