Code: Select all
int mclk_rate = fs * 384; // FIXME: factor depends on fs and CKS pins settings
static const i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_TX),
.sample_rate = fs,
.bits_per_sample = I2S_BITS_PER_SAMPLE_24BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // switch to left only?
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // high interrupt priority
.dma_buf_count = 2,
.dma_buf_len = AudioDriver::BufferSize,
.use_apll = true,
.tx_desc_auto_clear = false,
.fixed_mclk = mclk_rate
};