From 0b26efe73dd3396bdc2b77651a78d9f2edeb9004 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Sun, 28 Aug 2022 18:14:53 +0200 Subject: [PATCH] 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. --- extmod/machine_i2c.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c index 2aa217914bfb..ff597b58c5e5 100644 --- a/extmod/machine_i2c.c +++ b/extmod/machine_i2c.c @@ -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; }