diff --git a/src/AudioOutputI2S.cpp b/src/AudioOutputI2S.cpp index e575472..6d0762d 100644 --- a/src/AudioOutputI2S.cpp +++ b/src/AudioOutputI2S.cpp @@ -129,7 +129,7 @@ bool AudioOutputI2S::SetOutputModeMono(bool mono) return true; } -bool AudioOutputI2S::begin() +bool AudioOutputI2S::begin(bool txDAC) { #ifdef ESP32 if (!i2sOn) @@ -196,7 +196,18 @@ bool AudioOutputI2S::begin() { orig_bck = READ_PERI_REG(PERIPHS_IO_MUX_MTDO_U); orig_ws = READ_PERI_REG(PERIPHS_IO_MUX_GPIO2_U); - i2s_begin(); + #ifdef I2S_HAS_BEGIN_RXTX_DRIVE_CLOCKS + if (!i2s_rxtxdrive_begin(false, true, false, txDAC)) { + return false; + } + #else + if (!i2s_rxtx_begin(false, true)) { + return false; + } + if (!txDAC) { + audioLogger->printf_P(PSTR("I2SNoDAC: esp8266 arduino core should be upgraded to avoid conflicts with SPI\n")); + } + #endif } #endif i2sOn = true; diff --git a/src/AudioOutputI2S.h b/src/AudioOutputI2S.h index 3e881e7..f221d2e 100644 --- a/src/AudioOutputI2S.h +++ b/src/AudioOutputI2S.h @@ -32,11 +32,12 @@ class AudioOutputI2S : public AudioOutput virtual bool SetRate(int hz) override; virtual bool SetBitsPerSample(int bits) override; virtual bool SetChannels(int channels) override; - virtual bool begin() override; + virtual bool begin() override { return begin(true); } virtual bool ConsumeSample(int16_t sample[2]) override; virtual void flush() override; virtual bool stop() override; + bool begin (bool txDAC); bool SetOutputModeMono(bool mono); // Force mono output no matter the input enum : int { APLL_AUTO = -1, APLL_ENABLE = 1, APLL_DISABLE = 0 }; diff --git a/src/AudioOutputI2SNoDAC.h b/src/AudioOutputI2SNoDAC.h index b5f3214..d1738d1 100644 --- a/src/AudioOutputI2SNoDAC.h +++ b/src/AudioOutputI2SNoDAC.h @@ -28,6 +28,7 @@ class AudioOutputI2SNoDAC : public AudioOutputI2S public: AudioOutputI2SNoDAC(int port = 0); virtual ~AudioOutputI2SNoDAC() override; + virtual bool begin() override { return AudioOutputI2S::begin(false); } virtual bool ConsumeSample(int16_t sample[2]) override; bool SetOversampling(int os);