I hate to bring this up again, because I have already looked at the many forum posts on this, but I figure since the forum is going to close down soon, it could be my last chance.
In the Wire.cpp maple library there is the "process" function
Code: Select all
uint8 TwoWire::process(uint8 stop) {
int8 res = i2c_master_xfer(sel_hard, &itc_msg, 1, 0);
if (res == I2C_ERROR_PROTOCOL) {
if (sel_hard->error_flags & I2C_SR1_AF) { /* NACK */
res = (sel_hard->error_flags & I2C_SR1_ADDR ? ENACKADDR :
ENACKTRNS);
} else if (sel_hard->error_flags & I2C_SR1_OVR) { /* Over/Underrun */
res = EDATA;
} else { /* Bus or Arbitration error */
res = EOTHER;
}
i2c_disable(sel_hard);
i2c_master_enable(sel_hard, dev_flags);
}
return res;
}
It would be nice to be able to have some error recovery if the i2c bus doesn't work. I realize the Arduino Wire library has the same behavior, and workarounds "WSWireLib" have been devised for the Arduino to add some sort of error recovery.
Would it be possible to add a method to the Wire class so that while the timeout=0 as a default, it could be changed? For my particular application, the device may be an inaccessible place for long periods of time, and I would prefer if the device had some autonomous recovery. I realize I could use a watchdog to reset the microcontroller, but it would be nice to have an option that does not require a reset.
Thanks,
Dan