Skip to content

Commit

Permalink
handle esp32 apll issues (earlephilhower#51)
Browse files Browse the repository at this point in the history
* make use_apll user-configurable (fixes earlephilhower#37)

* disable apll per default (fixes earlephilhower#47)
  • Loading branch information
h3ndrik authored and earlephilhower committed Feb 6, 2018
1 parent eb67766 commit 0bb8590
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/AudioOutputI2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@
#endif
#include "AudioOutputI2S.h"

AudioOutputI2S::AudioOutputI2S(int port, bool builtInDAC)
AudioOutputI2S::AudioOutputI2S(int port, bool builtInDAC, int use_apll)
{
portNo = port;
i2sOn = false;
#ifdef ESP32
if (!i2sOn) {
// don't use audio pll on buggy rev0 chips
int use_apll = 0;
esp_chip_info_t out_info;
esp_chip_info(&out_info);
if(out_info.revision > 0) {
use_apll = 1;
if (use_apll == APLL_AUTO) {
// don't use audio pll on buggy rev0 chips
use_apll = APLL_DISABLE;
esp_chip_info_t out_info;
esp_chip_info(&out_info);
if(out_info.revision > 0) {
use_apll = APLL_ENABLE;
}
}
i2s_config_t i2s_config_dac = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | (builtInDAC ? I2S_MODE_DAC_BUILT_IN : 0)),
Expand Down
6 changes: 4 additions & 2 deletions src/AudioOutputI2S.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class AudioOutputI2S : public AudioOutput
{
public:
AudioOutputI2S(int port=0, bool builtInDAC=false);
AudioOutputI2S(int port=0, bool builtInDAC=false, int use_apll=APLL_DISABLE);
virtual ~AudioOutputI2S() override;
bool SetPinout(int bclkPin, int wclkPin, int doutPin);
virtual bool SetRate(int hz) override;
Expand All @@ -37,7 +37,9 @@ class AudioOutputI2S : public AudioOutput
virtual bool stop() override;

bool SetOutputModeMono(bool mono); // Force mono output no matter the input


enum : int { APLL_AUTO = -1, APLL_ENABLE = 1, APLL_DISABLE = 0 };

protected:
virtual int AdjustI2SRate(int hz) { return hz; }
uint8_t portNo;
Expand Down

0 comments on commit 0bb8590

Please sign in to comment.