The problem I have is that the stream initialization fails: see LOG output:
W (1277) i2s_platform: i2s controller 0 has been occupied by i2s_driver
E (1287) i2s_common: i2s_new_channel(813): no available channel found
E (1297) i2s_std: i2s_channel_init_std_mode(202): input parameter 'handle' is NU
E (1297) I2S_STREAM_IDF5.x: I2S stream init failed
See my code below:
Code: Select all
// Create custom i2s config
i2s_std_config_t s1_std_cfg;
s1_std_cfg = (i2s_std_config_t) {
.clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(44100),
.slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO),
.gpio_cfg = {
.mclk = I2S_GPIO_UNUSED, // Custom gpio pin
.bclk = S1_I2S_BCK_IO, // Custom gpio pin
.ws = S1_I2S_WS_IO, // Custom gpio pin
.dout = S1_I2S_DO_IO, // Custom gpio pin
.din = I2S_GPIO_UNUSED,
.invert_flags = {
.mclk_inv = false,
.bclk_inv = false,
.ws_inv = false,
}
},
};
// Create i2s stream to write data to DAC
audio_element_handle_t i2s_stream_writer;
i2s_stream_cfg_t i2s_stream_cfg = I2S_STREAM_CFG_DEFAULT();
i2s_stream_cfg.std_cfg = s1_std_cfg; //Here i pass in my custom i2s config before initializing the stream
i2s_stream_cfg.type = AUDIO_STREAM_WRITER;
i2s_stream_writer = i2s_stream_init(&i2s_stream_cfg);
it seems that this approach is not going to work as the adf explicitly gets the gpio from the "board_pins_config.h" from inside the i2s_steam code files.
In the i2s_streamidf5.c file, the function i2s_driver_startup(..) calls the function get_i2s_pins(..) which overrides what I am trying to insert. I have commented it out but still have issues with the i2s stream initialization. not sure if it is because the adf use different i2s headers?
Is there a way I can make this work without making changes to the adf code files?