extmod/machine_i2c: Call MICROPY_PY_EVENT_HOOK during i2c.scan().

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 #8876.
This commit is contained in:
robert-hh 2022-08-28 18:14:53 +02:00 committed by Damien George
parent af100b7029
commit 0b26efe73d
1 changed files with 3 additions and 0 deletions

View File

@ -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;
}