@@ -64,6 +64,7 @@ class I2SCodecStream : public AudioStream, public VolumeSupport {
64
64
cfg.input_device = ADC_INPUT_LINE1;
65
65
cfg.output_device = DAC_OUTPUT_ALL;
66
66
cfg.sd_active = true ;
67
+ cfg.rx_tx_mode = mode;
67
68
return cfg;
68
69
}
69
70
@@ -205,6 +206,7 @@ class I2SCodecStream : public AudioStream, public VolumeSupport {
205
206
bool is_active = false ;
206
207
207
208
bool begin1 () {
209
+ TRACED ();
208
210
setupI2SPins ();
209
211
if (!beginCodec (cfg)) {
210
212
TRACEE ();
@@ -224,8 +226,9 @@ class I2SCodecStream : public AudioStream, public VolumeSupport {
224
226
225
227
// / We use the board pins if they are available
226
228
void setupI2SPins () {
227
- // setup pins in i2s config
228
- auto i2s = p_board->getPins ().getI2SPins ();
229
+ TRACED ();
230
+ // determine relevant I2S pins from driver configuration
231
+ auto i2s = getI2SPins ();
229
232
if (i2s) {
230
233
// determine i2s pins from board definition
231
234
PinsI2S i2s_pins = i2s.value ();
@@ -247,7 +250,30 @@ class I2SCodecStream : public AudioStream, public VolumeSupport {
247
250
}
248
251
}
249
252
253
+ audio_driver_local::Optional<PinsI2S> getI2SPins (){
254
+ TRACED ();
255
+ audio_driver_local::Optional<PinsI2S> i2s;
256
+ // special logic if we have a board which has a dedicated microphone I2S port
257
+ if (cfg.rx_tx_mode == RX_MODE){
258
+ i2s = p_board->getPins ().getI2SPins (PinFunction::CODEC_ADC);
259
+ #ifdef ESP32
260
+ if (i2s){
261
+ cfg.port_no = i2s.value ().port ;
262
+ LOGI (" Using port %d for input" , cfg.port_no );
263
+ }
264
+ #endif
265
+ }
266
+
267
+ // Deterine regular I2S pins
268
+ if (!i2s){
269
+ // setup pins in i2s config
270
+ i2s = p_board->getPins ().getI2SPins ();
271
+ }
272
+ return i2s;
273
+ }
274
+
250
275
bool beginCodec (I2SCodecConfig info) {
276
+ TRACED ();
251
277
switch (cfg.rx_tx_mode ) {
252
278
case RX_MODE:
253
279
codec_cfg.input_device = info.input_device ;
0 commit comments