1 Commits
Author SHA1 Message Date
aditya 4d19dfb747 Add Wire.setWireTimeout to avoid I2C bus hangs (closes #288)
If the I2C bus stops responding mid-transaction (noise, the display
becomes disconnected, etc.), the underlying Wire library spins in
an indefinite loop and the host MCU effectively hangs. The Arduino
AVR core fixed this in ArduinoCore-avr@deea929 by exposing
setWireTimeout(); cores that implement it define WIRE_HAS_TIMEOUT
so callers can detect the feature at compile time.

Use that detection: when periphBegin owns the wire->begin() call,
follow it with a 25 ms timeout + reset on timeout. We only touch
Wire's configuration when we performed the begin() ourselves; if
the caller managed Wire externally, leave their configuration
untouched.

No behavioural change on cores without WIRE_HAS_TIMEOUT (the entire
block is compiled out).
2026-05-22 17:34:40 +05:30