Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for esp8266 I2S/NoDAC #344

Merged
merged 5 commits into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/AudioOutputI2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool AudioOutputI2S::SetOutputModeMono(bool mono)
return true;
}

bool AudioOutputI2S::begin()
bool AudioOutputI2S::begin(bool txDAC)
{
#ifdef ESP32
if (!i2sOn)
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/AudioOutputI2S.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
1 change: 1 addition & 0 deletions src/AudioOutputI2SNoDAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down