Skip to content

Commit 68778b1

Browse files
Clear i2c abort reason less often. (raspberrypi#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 raspberrypi#2025
1 parent 4726a56 commit 68778b1

File tree

1 file changed

+4
-1
lines changed
  • src/rp2_common/hardware_i2c

1 file changed

+4
-1
lines changed

src/rp2_common/hardware_i2c/i2c.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ static int i2c_read_blocking_internal(i2c_inst_t *i2c, uint8_t addr, uint8_t *ds
298298

299299
do {
300300
abort_reason = i2c->hw->tx_abrt_source;
301-
abort = (bool) i2c->hw->clr_tx_abrt;
301+
if (i2c->hw->raw_intr_stat & I2C_IC_RAW_INTR_STAT_TX_ABRT_BITS) {
302+
abort = true;
303+
i2c->hw->clr_tx_abrt;
304+
}
302305
if (timeout_check) {
303306
timeout = timeout_check(ts, false);
304307
abort |= timeout;

0 commit comments

Comments
 (0)