[ESP32-s2] Fix crash when scanning I2C bus

See: https://github.com/espressif/arduino-esp32/issues/5636
This commit is contained in:
TD-er
2021-09-06 12:00:14 +02:00
parent 9bf8961a5b
commit 0a5b435e51
+6 -2
View File
@@ -173,7 +173,6 @@ void initI2C() {
}
addLog(LOG_LEVEL_INFO, F("INIT : I2C"));
I2CSelectClockSpeed(false); // Set normal clock speed
Wire.begin(Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
if (Settings.WireClockStretchLimit)
{
@@ -226,8 +225,13 @@ void I2CSelectClockSpeed(bool setLowSpeed) {
// No need to change the clock speed.
return;
}
lastI2CClockSpeed = newI2CClockSpeed;
lastI2CClockSpeed = newI2CClockSpeed;
#ifdef ESP32
Wire.begin(Settings.Pin_i2c_sda, Settings.Pin_i2c_scl, newI2CClockSpeed);
#else
Wire.begin(Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
Wire.setClock(newI2CClockSpeed);
#endif
}
#ifdef FEATURE_I2CMULTIPLEXER