Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix too small timeout in
i2c_start()
In qmk#11930 the I2C master driver for AVR was changed to perform multiple retries (20 by default, configurable via `I2C_START_RETRY_COUNT`) in `i2c_start()`, apparently as a workaround for failures when the slave half had interrupts disabled for some time. Unfortunately, the implementation of those retries limited the minimum timeout for a single start attempt to 1 ms, but the timeout handling in the I2C master driver handles the partial millisecond before the next timer tick as if it was a full millisecond, therefore the timeout for a single attempt could be really short in some cases. These short timeouts resulted in some problems when various I2C APIs were invoked with timeouts not greater than 40 ms - e.g., qmk#14935. As a minimal fix for this problem, limit the minimum timeout for a single start attempt to 2 ms instead of 1 (the actual timeout will be 1...2 ms, instead of 0...1 ms before the change).
- Loading branch information