@@ -286,6 +286,9 @@ bool I2SClass::initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mo
286
286
if (_dout >= 0 ) if (!perimanSetPinBus (_dout, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
287
287
if (_din >= 0 ) if (!perimanSetPinBus (_din, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
288
288
289
+ // Set peripheral manager detach function for I2S
290
+ perimanSetBusDeinit (ESP32_BUS_TYPE_I2S_STD, I2SClass::i2sDetachBus);
291
+
289
292
// I2S configuration
290
293
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG ();
291
294
if (_dout >= 0 && _din >= 0 ) {
@@ -335,6 +338,9 @@ bool I2SClass::initTDM(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mo
335
338
if (_dout >= 0 ) if (!perimanSetPinBus (_dout, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
336
339
if (_din >= 0 ) if (!perimanSetPinBus (_din, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
337
340
341
+ // Set peripheral manager detach function for I2S
342
+ perimanSetBusDeinit (ESP32_BUS_TYPE_I2S_TDM, I2SClass::i2sDetachBus);
343
+
338
344
// I2S configuration
339
345
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG ();
340
346
if (_dout >= 0 && _din >= 0 ) {
@@ -383,6 +389,9 @@ bool I2SClass::initPDMtx(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_
383
389
if (_tx_dout0 >= 0 ) if (!perimanSetPinBus (_tx_dout0, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
384
390
if (_tx_dout1 >= 0 ) if (!perimanSetPinBus (_tx_dout1, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
385
391
392
+ // Set peripheral manager detach function for I2S
393
+ perimanSetBusDeinit (ESP32_BUS_TYPE_I2S_PDM_TX, I2SClass::i2sDetachBus);
394
+
386
395
// I2S configuration
387
396
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG ();
388
397
I2S_ERROR_CHECK_RETURN_FALSE (i2s_new_channel (&chan_cfg, &tx_chan, NULL ));
@@ -397,9 +406,9 @@ bool I2SClass::initPDMtx(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_
397
406
}
398
407
399
408
// Peripheral manager set bus type to I2S
400
- if (_tx_clk >= 0 ) if (!perimanSetPinBus (_tx_clk, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
401
- if (_tx_dout0 >= 0 ) if (!perimanSetPinBus (_tx_dout0, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
402
- if (_tx_dout1 >= 0 ) if (!perimanSetPinBus (_tx_dout1, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
409
+ if (_tx_clk >= 0 ) if (!perimanSetPinBus (_tx_clk, ESP32_BUS_TYPE_I2S_PDM_TX , (void *)(this ))){ goto err; }
410
+ if (_tx_dout0 >= 0 ) if (!perimanSetPinBus (_tx_dout0, ESP32_BUS_TYPE_I2S_PDM_TX , (void *)(this ))){ goto err; }
411
+ if (_tx_dout1 >= 0 ) if (!perimanSetPinBus (_tx_dout1, ESP32_BUS_TYPE_I2S_PDM_TX , (void *)(this ))){ goto err; }
403
412
404
413
return true ;
405
414
err:
@@ -418,6 +427,9 @@ bool I2SClass::initPDMrx(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_
418
427
if (_rx_din2 >= 0 ) if (!perimanSetPinBus (_rx_din2, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
419
428
if (_rx_din3 >= 0 ) if (!perimanSetPinBus (_rx_din3, ESP32_BUS_TYPE_INIT, NULL )){ return false ; }
420
429
430
+ // Set peripheral manager detach function for I2S
431
+ perimanSetBusDeinit (ESP32_BUS_TYPE_I2S_PDM_RX, I2SClass::i2sDetachBus);
432
+
421
433
// I2S configuration
422
434
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG ();
423
435
I2S_ERROR_CHECK_RETURN_FALSE (i2s_new_channel (&chan_cfg, NULL , &rx_chan));
@@ -432,11 +444,11 @@ bool I2SClass::initPDMrx(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_
432
444
}
433
445
434
446
// Peripheral manager set bus type to I2S
435
- if (_rx_clk >= 0 ) if (!perimanSetPinBus (_rx_clk, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
436
- if (_rx_din0 >= 0 ) if (!perimanSetPinBus (_rx_din0, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
437
- if (_rx_din1 >= 0 ) if (!perimanSetPinBus (_rx_din1, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
438
- if (_rx_din2 >= 0 ) if (!perimanSetPinBus (_rx_din2, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
439
- if (_rx_din3 >= 0 ) if (!perimanSetPinBus (_rx_din3, ESP32_BUS_TYPE_I2S_PDM , (void *)(this ))){ goto err; }
447
+ if (_rx_clk >= 0 ) if (!perimanSetPinBus (_rx_clk, ESP32_BUS_TYPE_I2S_PDM_RX , (void *)(this ))){ goto err; }
448
+ if (_rx_din0 >= 0 ) if (!perimanSetPinBus (_rx_din0, ESP32_BUS_TYPE_I2S_PDM_RX , (void *)(this ))){ goto err; }
449
+ if (_rx_din1 >= 0 ) if (!perimanSetPinBus (_rx_din1, ESP32_BUS_TYPE_I2S_PDM_RX , (void *)(this ))){ goto err; }
450
+ if (_rx_din2 >= 0 ) if (!perimanSetPinBus (_rx_din2, ESP32_BUS_TYPE_I2S_PDM_RX , (void *)(this ))){ goto err; }
451
+ if (_rx_din3 >= 0 ) if (!perimanSetPinBus (_rx_din3, ESP32_BUS_TYPE_I2S_PDM_RX , (void *)(this ))){ goto err; }
440
452
441
453
return true ;
442
454
err:
0 commit comments