summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-11-08 23:34:08 +1100
committerDamien George <damien@micropython.org>2023-11-08 23:34:08 +1100
commitdff293840e381444bcd843a325ab3dd7da685733 (patch)
tree9a55f4b4f338aa479237c01307055b8644181075
parent958c6d917dac86e844458974e6faa8f9552c04f7 (diff)
extmod/machine_i2c: Do a fast poll during I2C.scan().
Fixes issue #12912. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--extmod/machine_i2c.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c
index 44e692130..6cc2aa5bb 100644
--- a/extmod/machine_i2c.c
+++ b/extmod/machine_i2c.c
@@ -328,7 +328,12 @@ 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
+ // This scan loop may run for some time, so process any pending events/exceptions,
+ // or allow the port to run any necessary background tasks. But do it as fast as
+ // possible, in particular we are not waiting on any events.
+ #if defined(MICROPY_EVENT_POLL_HOOK_FAST)
+ MICROPY_EVENT_POLL_HOOK_FAST;
+ #elif defined(MICROPY_EVENT_POLL_HOOK)
MICROPY_EVENT_POLL_HOOK
#endif
}