diff --git a/src/AudioOutputI2S.cpp b/src/AudioOutputI2S.cpp index 71ac29e..ad3087b 100644 --- a/src/AudioOutputI2S.cpp +++ b/src/AudioOutputI2S.cpp @@ -85,6 +85,8 @@ AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int (void) dma_buf_count; (void) use_apll; if (!i2sOn) { + orig_bck = READ_PERI_REG(PERIPHS_IO_MUX_MTDO_U); + orig_ws = READ_PERI_REG(PERIPHS_IO_MUX_GPIO2_U); i2s_begin(); } #endif diff --git a/src/AudioOutputI2S.h b/src/AudioOutputI2S.h index bc35945..148481a 100644 --- a/src/AudioOutputI2S.h +++ b/src/AudioOutputI2S.h @@ -47,6 +47,9 @@ class AudioOutputI2S : public AudioOutput int output_mode; bool mono; bool i2sOn; + // We can restore the old values and free up these pins when in NoDAC mode + uint32_t orig_bck; + uint32_t orig_ws; }; #endif diff --git a/src/AudioOutputI2SNoDAC.cpp b/src/AudioOutputI2SNoDAC.cpp index 8fd85fa..cb36e13 100644 --- a/src/AudioOutputI2SNoDAC.cpp +++ b/src/AudioOutputI2SNoDAC.cpp @@ -32,6 +32,10 @@ AudioOutputI2SNoDAC::AudioOutputI2SNoDAC(int port) : AudioOutputI2S(port, false) SetOversampling(32); lastSamp = 0; cumErr = 0; +#ifndef ESP32 + WRITE_PERI_REG(PERIPHS_IO_MUX_MTDO_U, orig_bck); + WRITE_PERI_REG(PERIPHS_IO_MUX_GPIO2_U, orig_ws); +#endif } AudioOutputI2SNoDAC::~AudioOutputI2SNoDAC()