1 parent
12131e9826
commit
0abcf71012
2 files changed
+15
No files matched your search
@@ -64,6 +64,7 @@ AudioOutputI2S::AudioOutputI2S(long sampleRate, pin_size_t sck, pin_size_t data)
|
|||||||
doutPin = data;
|
doutPin = data;
|
||||||
mclkPin = 0;
|
mclkPin = 0;
|
||||||
use_mclk = false;
|
use_mclk = false;
|
||||||
|
swap_clocks = false;
|
||||||
SetGain(1.0);
|
SetGain(1.0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -168,6 +169,15 @@ bool AudioOutputI2S::SetLsbJustified(bool lsbJustified)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioOutputI2S::SwapClocks(bool swap_clocks)
|
||||||
|
{
|
||||||
|
if (i2sOn) {
|
||||||
|
return false; // Not allowed
|
||||||
|
}
|
||||||
|
this->swap_clocks = swap_clocks;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool AudioOutputI2S::SetMclk(bool enabled){
|
bool AudioOutputI2S::SetMclk(bool enabled){
|
||||||
(void)enabled;
|
(void)enabled;
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
@@ -302,6 +312,9 @@ bool AudioOutputI2S::begin(bool txDAC)
|
|||||||
if (!i2sOn) {
|
if (!i2sOn) {
|
||||||
i2s.setBCLK(bclkPin);
|
i2s.setBCLK(bclkPin);
|
||||||
i2s.setDATA(doutPin);
|
i2s.setDATA(doutPin);
|
||||||
|
if (swap_clocks) {
|
||||||
|
i2s.swapClocks();
|
||||||
|
}
|
||||||
i2s.begin(hertz);
|
i2s.begin(hertz);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class AudioOutputI2S : public AudioOutput
|
|||||||
bool SetOutputModeMono(bool mono); // Force mono output no matter the input
|
bool SetOutputModeMono(bool mono); // Force mono output no matter the input
|
||||||
bool SetLsbJustified(bool lsbJustified); // Allow supporting non-I2S chips, e.g. PT8211
|
bool SetLsbJustified(bool lsbJustified); // Allow supporting non-I2S chips, e.g. PT8211
|
||||||
bool SetMclk(bool enabled); // Enable MCLK output (if supported)
|
bool SetMclk(bool enabled); // Enable MCLK output (if supported)
|
||||||
|
bool SwapClocks(bool swap_clocks); // Swap BCLK and WCLK
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool SetPinout();
|
bool SetPinout();
|
||||||
@@ -64,6 +65,7 @@ class AudioOutputI2S : public AudioOutput
|
|||||||
int dma_buf_count;
|
int dma_buf_count;
|
||||||
int use_apll;
|
int use_apll;
|
||||||
bool use_mclk;
|
bool use_mclk;
|
||||||
|
bool swap_clocks;
|
||||||
// We can restore the old values and free up these pins when in NoDAC mode
|
// We can restore the old values and free up these pins when in NoDAC mode
|
||||||
uint32_t orig_bck;
|
uint32_t orig_bck;
|
||||||
uint32_t orig_ws;
|
uint32_t orig_ws;
|
||||||
|
|||||||
Reference in new issue
Block a user