Add ability to SwapClocks(bool) on I2S. rp2040 only. (#639)

Fixes #638
This commit is contained in:
Nils Trubkin authored and GitHub committed 2023-06-30 11:02:49 -07:00
1 parent 12131e9826
commit 0abcf71012
2 files changed
+15

No files matched your search

+13
View File
@@ -64,6 +64,7 @@ AudioOutputI2S::AudioOutputI2S(long sampleRate, pin_size_t sck, pin_size_t data)
doutPin = data;
mclkPin = 0;
use_mclk = false;
swap_clocks = false;
SetGain(1.0);
}
#endif
@@ -168,6 +169,15 @@ bool AudioOutputI2S::SetLsbJustified(bool lsbJustified)
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){
(void)enabled;
#ifdef ESP32
@@ -302,6 +312,9 @@ bool AudioOutputI2S::begin(bool txDAC)
if (!i2sOn) {
i2s.setBCLK(bclkPin);
i2s.setDATA(doutPin);
if (swap_clocks) {
i2s.swapClocks();
}
i2s.begin(hertz);
}
#endif