From 1446bab3c5a621cea889d45635a6b04ac536f0ad Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 22 Nov 2022 17:14:02 +0100 Subject: [PATCH] I2S: another attempt to make "slave mode" work --- usermods/audioreactive/audio_source.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usermods/audioreactive/audio_source.h b/usermods/audioreactive/audio_source.h index e32eff1a..afc9d8ed 100644 --- a/usermods/audioreactive/audio_source.h +++ b/usermods/audioreactive/audio_source.h @@ -230,11 +230,18 @@ class I2SSource : public AudioSource { } #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0) + if ((_i2sMaster == false) && (_config.mode & I2S_MODE_SLAVE)) { // I2S slave mode (experimental). + // Seems we need to drive clocks in slave mode + _config.use_apll = true; + _config.fixed_mclk = 512 * int(_config.sample_rate); + } + if (mclkPin != I2S_PIN_NO_CHANGE) { _config.use_apll = true; // experimental - use aPLL clock source to improve sampling quality, and to avoid glitches. // //_config.fixed_mclk = 512 * _sampleRate; // //_config.fixed_mclk = 256 * _sampleRate; } + #if !defined(SOC_I2S_SUPPORTS_APLL) #warning this MCU does not have an APLL high accuracy clock for audio // S3: not supported; S2: supported; C3: not supported