Skip to content

Commit

Permalink
extmod/machine_i2c: Call MICROPY_PY_EVENT_HOOK during i2c.scan().
Browse files Browse the repository at this point in the history
Avoiding a watchdog reset during i2c.scan() if the hardware is not properly
set up (eg on esp8266), and also allowing to stop the scan with a
KeyboardInterrupt.

Fixes issue micropython#8876.
  • Loading branch information
robert-hh authored and dpgeorge committed Aug 31, 2022
1 parent af100b7 commit 0b26efe
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extmod/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
if (ret == 0) {
mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr));
}
#ifdef MICROPY_EVENT_POLL_HOOK
MICROPY_EVENT_POLL_HOOK
#endif
}
return list;
}
Expand Down

0 comments on commit 0b26efe

Please sign in to comment.