@@ -34,7 +34,7 @@ class I2SDriverESP32V1 {
34
34
if (info.equals (cfg)) return true ;
35
35
if (info.equalsExSampleRate (cfg)) {
36
36
cfg.sample_rate = info.sample_rate ;
37
- LOGI (" i2s_set_sample_rates: %d" , (int ) info.sample_rate );
37
+ LOGI (" i2s_set_sample_rates: %d" , (int )info.sample_rate );
38
38
return getDriver (cfg).changeSampleRate (cfg, rx_chan, tx_chan);
39
39
}
40
40
} else {
@@ -152,29 +152,39 @@ class I2SDriverESP32V1 {
152
152
struct DriverI2S : public DriverCommon {
153
153
i2s_std_slot_config_t getSlotConfig (I2SConfigESP32V1 &cfg) {
154
154
TRACED ();
155
+ i2s_std_slot_config_t result;
155
156
switch (cfg.i2s_format ) {
156
- case I2S_RIGHT_JUSTIFIED_FORMAT:
157
- case I2S_LSB_FORMAT:
158
- case I2S_PHILIPS_FORMAT:
159
- case I2S_STD_FORMAT:
160
- return I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG (
161
- (i2s_data_bit_width_t )cfg.bits_per_sample ,
162
- (i2s_slot_mode_t )cfg.channels );
163
157
case I2S_LEFT_JUSTIFIED_FORMAT:
164
158
case I2S_MSB_FORMAT:
165
- return I2S_STD_MSB_SLOT_DEFAULT_CONFIG (
159
+ result = I2S_STD_MSB_SLOT_DEFAULT_CONFIG (
166
160
(i2s_data_bit_width_t )cfg.bits_per_sample ,
167
161
(i2s_slot_mode_t )cfg.channels );
168
162
case I2S_PCM:
169
- return I2S_STD_PCM_SLOT_DEFAULT_CONFIG (
163
+ result = I2S_STD_PCM_SLOT_DEFAULT_CONFIG (
164
+ (i2s_data_bit_width_t )cfg.bits_per_sample ,
165
+ (i2s_slot_mode_t )cfg.channels );
166
+ default :
167
+ result = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG (
170
168
(i2s_data_bit_width_t )cfg.bits_per_sample ,
171
169
(i2s_slot_mode_t )cfg.channels );
172
170
}
173
- // use default config
174
- TRACEE ();
175
- return I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG (
176
- (i2s_data_bit_width_t )cfg.bits_per_sample ,
177
- (i2s_slot_mode_t )cfg.channels );
171
+
172
+ // Update slot_mask if only one channel
173
+ if (cfg.channels == 1 ) {
174
+ switch (cfg.channel_format ) {
175
+ case I2SChannelSelect::Left:
176
+ result.slot_mask = I2S_STD_SLOT_LEFT;
177
+ break ;
178
+ case I2SChannelSelect::Right:
179
+ result.slot_mask = I2S_STD_SLOT_RIGHT;
180
+ break ;
181
+ case I2SChannelSelect::Stereo:
182
+ LOGW (" Invalid channel_format: %d" , cfg.channel_format );
183
+ break ;
184
+ }
185
+ }
186
+
187
+ return result;
178
188
}
179
189
180
190
i2s_chan_config_t getChannelConfig (I2SConfigESP32V1 &cfg) {
@@ -445,7 +455,7 @@ class I2SDriverESP32V1 {
445
455
return tdm;
446
456
#endif
447
457
default :
448
- break ;
458
+ break ;
449
459
}
450
460
LOGE (" Unsupported singal_type" );
451
461
return i2s;
0 commit comments