Skip to content

Commit

Permalink
Extend TDM support
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Oct 28, 2024
1 parent b3dec88 commit 2277f92
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/AudioTools/CoreAudio/AudioI2S/I2SESP32V1.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,36 @@ class I2SDriverESP32V1 {
for (int j = 0; j < cfg.channels; j++) {
slots |= 1 << j;
}
return I2S_TDM_MSB_SLOT_DEFAULT_CONFIG(
(i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
(i2s_tdm_slot_mask_t)slots);
// setup default format
i2s_tdm_slot_config_t cfg = I2S_TDM_PHILIPS_SLOT_DEFAULT_CONFIG(
(i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
(i2s_tdm_slot_mask_t)slots);

switch(cfg.i2s_format){
case I2S_RIGHT_JUSTIFIED_FORMAT:
case I2S_LSB_FORMAT:
case I2S_PHILIPS_FORMAT:
case I2S_STD_FORMAT:
cfg = I2S_TDM_PHILIPS_SLOT_DEFAULT_CONFIG(
(i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
(i2s_tdm_slot_mask_t)slots);
break;
case I2S_LEFT_JUSTIFIED_FORMAT:
case I2S_MSB_FORMAT:
cfg = I2S_TDM_MSB_SLOT_DEFAULT_CONFIG(
(i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
(i2s_tdm_slot_mask_t)slots);
break;
case I2S_PCM:
cfg = I2S_TDM_PCM_LONG_SLOT_DEFAULT_CONFIG(
(i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
(i2s_tdm_slot_mask_t)slots);
break;
default:
LOGE("TDM: Unsupported format");
}

return cfg;
}

i2s_chan_config_t getChannelConfig(I2SConfigESP32V1 &cfg) {
Expand Down

0 comments on commit 2277f92

Please sign in to comment.