Clear i2c abort reason less often. (#2026)

It seems to be possible to get stuck in the loop which is checking for
abort. It can take 100s of iterations before an abort happens and on
each iteration we're clearing the abort interrupt even when it's not
required. If we only clear the abort when needed the lockup doesn't seem
to be reproducible.

Fixes #2025
This commit is contained in:
Peter Harper 2024-11-11 16:09:08 +00:00 committed by GitHub
parent 4726a56d24
commit 68778b1135
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -298,7 +298,10 @@ static int i2c_read_blocking_internal(i2c_inst_t *i2c, uint8_t addr, uint8_t *ds
do {
abort_reason = i2c->hw->tx_abrt_source;
abort = (bool) i2c->hw->clr_tx_abrt;
if (i2c->hw->raw_intr_stat & I2C_IC_RAW_INTR_STAT_TX_ABRT_BITS) {
abort = true;
i2c->hw->clr_tx_abrt;
}
if (timeout_check) {
timeout = timeout_check(ts, false);
abort |= timeout;