Add MCLK support for RP2040 (#707)
This commit is contained in:
1 parent
79208f6701
commit
50bc3f7279
1 file changed
+13
-7
+13
-7
@@ -116,7 +116,7 @@ bool AudioOutputI2S::SetPinout(int bclk, int wclk, int dout, int mclk)
|
|||||||
bclkPin = bclk;
|
bclkPin = bclk;
|
||||||
wclkPin = wclk;
|
wclkPin = wclk;
|
||||||
doutPin = dout;
|
doutPin = dout;
|
||||||
#ifdef ESP32
|
#if defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
|
||||||
mclkPin = mclk;
|
mclkPin = mclk;
|
||||||
if (i2sOn)
|
if (i2sOn)
|
||||||
return SetPinout();
|
return SetPinout();
|
||||||
@@ -184,6 +184,8 @@ bool AudioOutputI2S::SetMclk(bool enabled){
|
|||||||
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
||||||
return false; // Not allowed
|
return false; // Not allowed
|
||||||
|
|
||||||
|
use_mclk = enabled;
|
||||||
|
#elif defined(ARDUINO_ARCH_RP2040)
|
||||||
use_mclk = enabled;
|
use_mclk = enabled;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@@ -310,12 +312,16 @@ bool AudioOutputI2S::begin(bool txDAC)
|
|||||||
#elif defined(ARDUINO_ARCH_RP2040)
|
#elif defined(ARDUINO_ARCH_RP2040)
|
||||||
(void)txDAC;
|
(void)txDAC;
|
||||||
if (!i2sOn) {
|
if (!i2sOn) {
|
||||||
i2s.setBCLK(bclkPin);
|
i2s.setSysClk(hertz);
|
||||||
i2s.setDATA(doutPin);
|
i2s.setBCLK(bclkPin);
|
||||||
if (swap_clocks) {
|
i2s.setDATA(doutPin);
|
||||||
i2s.swapClocks();
|
i2s.setMCLK(mclkPin);
|
||||||
}
|
i2s.setMCLKmult(256);
|
||||||
i2s.begin(hertz);
|
if (swap_clocks) {
|
||||||
|
i2s.swapClocks();
|
||||||
|
}
|
||||||
|
i2s.setBitsPerSample(bps);
|
||||||
|
i2s.begin(hertz);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
i2sOn = true;
|
i2sOn = true;
|
||||||
|
|||||||
Reference in new issue
Block a user