Use MM specific I2C related functions for ES8388 and ES7243

In contrast to upstream, MM follows a "no pin stealing" approach, so the Wire interfaces are only initialized when needed.
pinManager.joinWire() will take care of the details, and will return false if something went wrong.
This commit is contained in:
Frank
2023-08-07 18:06:31 +02:00
parent e19e464e13
commit 3503ccd958

View File

@@ -456,6 +456,15 @@ public:
void initialize(int8_t i2swsPin, int8_t i2ssdPin, int8_t i2sckPin, int8_t mclkPin) {
// check that pins are valid
if ((i2c_sda < 0) || (i2c_scl < 0)) { // check that global I2C pins are not "undefined"
ERRORSR_PRINTF("\nAR: invalid ES7243 global I2C pins: SDA=%d, SCL=%d\n", i2c_sda, i2c_scl);
return;
}
if (!pinManager.joinWire()) { // WLEDMM specific: start I2C with globally defined pins
ERRORSR_PRINTF("\nAR: failed to start I2C bus with SDA=%d, SCL=%d\n", i2c_sda, i2c_scl);
return;
}
if ((i2sckPin < 0) || (mclkPin < 0)) {
ERRORSR_PRINTF("\nAR: invalid I2S pin: SCK=%d, MCLK=%d\n", i2sckPin, mclkPin);
return;
@@ -574,6 +583,15 @@ class ES8388Source : public I2SSource {
void initialize(int8_t i2swsPin, int8_t i2ssdPin, int8_t i2sckPin, int8_t mclkPin) {
if ((i2c_sda < 0) || (i2c_scl < 0)) { // check that global I2C pins are not "undefined"
ERRORSR_PRINTF("\nAR: invalid ES8388 global I2C pins: SDA=%d, SCL=%d\n", i2c_sda, i2c_scl);
return;
}
if (!pinManager.joinWire()) { // WLEDMM specific: start I2C with globally defined pins
ERRORSR_PRINTF("\nAR: failed to start I2C bus with SDA=%d, SCL=%d\n", i2c_sda, i2c_scl);
return;
}
if ((i2sckPin < 0) || (mclkPin < 0)) {
ERRORSR_PRINTF("\nAR: invalid I2S pin: SCK=%d, MCLK=%d\n", i2sckPin, mclkPin);
return;