Skip to content

Commit f5b027c

Browse files
authored
let TwoWire() handle resetting the Hardware
The i2c data bus must be disconnected from the i2c peripheral before it is init'd. Else it will generate a glitch on both pins. Since the Hal layer does not remember which pins are assigned, just return the error and let `TwoWire()` handle re-initing.
1 parent ef95f86 commit f5b027c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

cores/esp32/esp32-hal-i2c.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,11 +974,9 @@ i2c_err_t i2cProcQueue(i2c_t * i2c, uint32_t *readCount, uint16_t timeOutMillis)
974974
if(i2c == NULL){
975975
return I2C_ERROR_DEV;
976976
}
977-
if (i2c->dev->status_reg.bus_busy){
977+
if (i2c->dev->status_reg.bus_busy){ // return error, let TwoWire() handle resetting the hardware.
978978
log_i("Bus busy, reinit");
979-
i2cInit(i2c->num);
980-
if (i2c->dev->status_reg.bus_busy) return I2C_ERROR_BUSY;
981-
else log_i("recovered");
979+
return I2C_ERROR_BUSY;
982980
}
983981
I2C_MUTEX_LOCK();
984982
/* what about co-existance with SLAVE mode?

0 commit comments

Comments
 (0)