@@ -355,9 +355,36 @@ class I2SDriverESP32V1 {
355
355
for (int j = 0 ; j < cfg.channels ; j++) {
356
356
slots |= 1 << j;
357
357
}
358
- return I2S_TDM_MSB_SLOT_DEFAULT_CONFIG (
359
- (i2s_data_bit_width_t )cfg.bits_per_sample , I2S_SLOT_MODE_STEREO,
360
- (i2s_tdm_slot_mask_t )slots);
358
+ // setup default format
359
+ i2s_tdm_slot_config_t cfg = I2S_TDM_PHILIPS_SLOT_DEFAULT_CONFIG (
360
+ (i2s_data_bit_width_t )cfg.bits_per_sample , I2S_SLOT_MODE_STEREO,
361
+ (i2s_tdm_slot_mask_t )slots);
362
+
363
+ switch (cfg.i2s_format ){
364
+ case I2S_RIGHT_JUSTIFIED_FORMAT:
365
+ case I2S_LSB_FORMAT:
366
+ case I2S_PHILIPS_FORMAT:
367
+ case I2S_STD_FORMAT:
368
+ cfg = I2S_TDM_PHILIPS_SLOT_DEFAULT_CONFIG (
369
+ (i2s_data_bit_width_t )cfg.bits_per_sample , I2S_SLOT_MODE_STEREO,
370
+ (i2s_tdm_slot_mask_t )slots);
371
+ break ;
372
+ case I2S_LEFT_JUSTIFIED_FORMAT:
373
+ case I2S_MSB_FORMAT:
374
+ cfg = I2S_TDM_MSB_SLOT_DEFAULT_CONFIG (
375
+ (i2s_data_bit_width_t )cfg.bits_per_sample , I2S_SLOT_MODE_STEREO,
376
+ (i2s_tdm_slot_mask_t )slots);
377
+ break ;
378
+ case I2S_PCM:
379
+ cfg = I2S_TDM_PCM_LONG_SLOT_DEFAULT_CONFIG (
380
+ (i2s_data_bit_width_t )cfg.bits_per_sample , I2S_SLOT_MODE_STEREO,
381
+ (i2s_tdm_slot_mask_t )slots);
382
+ break ;
383
+ default :
384
+ LOGE (" TDM: Unsupported format" );
385
+ }
386
+
387
+ return cfg;
361
388
}
362
389
363
390
i2s_chan_config_t getChannelConfig (I2SConfigESP32V1 &cfg) {
0 commit comments