Skip to content

Commit 819aae4

Browse files
authored
I2S fix missing perimanSetBusDeinit() (#8782)
* add missing perimanSetBusDeinit * fix printPerimanInfo
1 parent 5f30a41 commit 819aae4

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

Diff for: cores/esp32/chip-debug-report.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ static void printPerimanInfo(void){
278278
#endif
279279
#if SOC_I2S_SUPPORTED
280280
case ESP32_BUS_TYPE_I2S_STD: chip_report_printf("I2S_STD\n"); break;
281-
case ESP32_BUS_TYPE_I2S_PDM: chip_report_printf("I2S_PDM\n"); break;
282281
case ESP32_BUS_TYPE_I2S_TDM: chip_report_printf("I2S_TDM\n"); break;
282+
case ESP32_BUS_TYPE_I2S_PDM_TX: chip_report_printf("I2S_PDM_TX\n"); break;
283+
case ESP32_BUS_TYPE_I2S_PDM_RX: chip_report_printf("I2S_PDM_RX\n"); break;
283284
#endif
284285
#if SOC_I2C_SUPPORTED
285286
case ESP32_BUS_TYPE_I2C_MASTER: chip_report_printf("I2C_MASTER\n"); break;

Diff for: cores/esp32/esp32-hal-periman.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ typedef enum {
4242
#endif
4343
#if SOC_I2S_SUPPORTED
4444
ESP32_BUS_TYPE_I2S_STD, // IO is used as I2S STD pin
45-
ESP32_BUS_TYPE_I2S_PDM, // IO is used as I2S PDM pin
4645
ESP32_BUS_TYPE_I2S_TDM, // IO is used as I2S TDM pin
46+
ESP32_BUS_TYPE_I2S_PDM_TX, // IO is used as I2S PDM pin
47+
ESP32_BUS_TYPE_I2S_PDM_RX, // IO is used as I2S PDM pin
4748
#endif
4849
#if SOC_I2C_SUPPORTED
4950
ESP32_BUS_TYPE_I2C_MASTER, // IO is used as I2C master pin

Diff for: libraries/ESP_I2S/src/ESP_I2S.cpp

+20-8
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ bool I2SClass::initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mo
286286
if (_dout >= 0) if (!perimanSetPinBus(_dout, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
287287
if (_din >= 0) if (!perimanSetPinBus(_din, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
288288

289+
// Set peripheral manager detach function for I2S
290+
perimanSetBusDeinit(ESP32_BUS_TYPE_I2S_STD, I2SClass::i2sDetachBus);
291+
289292
// I2S configuration
290293
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG();
291294
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
335338
if (_dout >= 0) if (!perimanSetPinBus(_dout, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
336339
if (_din >= 0) if (!perimanSetPinBus(_din, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
337340

341+
// Set peripheral manager detach function for I2S
342+
perimanSetBusDeinit(ESP32_BUS_TYPE_I2S_TDM, I2SClass::i2sDetachBus);
343+
338344
// I2S configuration
339345
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG();
340346
if (_dout >= 0 && _din >= 0) {
@@ -383,6 +389,9 @@ bool I2SClass::initPDMtx(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_
383389
if (_tx_dout0 >= 0) if (!perimanSetPinBus(_tx_dout0, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
384390
if (_tx_dout1 >= 0) if (!perimanSetPinBus(_tx_dout1, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
385391

392+
// Set peripheral manager detach function for I2S
393+
perimanSetBusDeinit(ESP32_BUS_TYPE_I2S_PDM_TX, I2SClass::i2sDetachBus);
394+
386395
// I2S configuration
387396
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG();
388397
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_
397406
}
398407

399408
// 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; }
403412

404413
return true;
405414
err:
@@ -418,6 +427,9 @@ bool I2SClass::initPDMrx(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_
418427
if (_rx_din2 >= 0) if (!perimanSetPinBus(_rx_din2, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
419428
if (_rx_din3 >= 0) if (!perimanSetPinBus(_rx_din3, ESP32_BUS_TYPE_INIT, NULL)){ return false; }
420429

430+
// Set peripheral manager detach function for I2S
431+
perimanSetBusDeinit(ESP32_BUS_TYPE_I2S_PDM_RX, I2SClass::i2sDetachBus);
432+
421433
// I2S configuration
422434
i2s_chan_config_t chan_cfg = I2S_DEFAULT_CFG();
423435
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_
432444
}
433445

434446
// 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; }
440452

441453
return true;
442454
err:

0 commit comments

Comments
 (0)