8000 extmod/machine_i2c: Do a fast poll during I2C.scan(). · micropython/micropython@dff2938 · GitHub
[go: up one dir, main page]

Skip to content

Commit dff2938

Browse files
committed
extmod/machine_i2c: Do a fast poll during I2C.scan().
Fixes issue #12912. Signed-off-by: Damien George <damien@micropython.org>
1 parent 958c6d9 commit dff2938

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

extmod/machine_i2c.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,12 @@ STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
328328
if (ret == 0) {
329329
mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr));
330330
}
331-
#ifdef MICROPY_EVENT_POLL_HOOK
331+
// This scan loop may run for some time, so process any pending events/exceptions,
332+
// or allow the port to run any necessary background tasks. But do it as fast as
333+
// possible, in particular we are not waiting on any events.
334+
#if defined(MICROPY_EVENT_POLL_HOOK_FAST)
335+
MICROPY_EVENT_POLL_HOOK_FAST;
336+
#elif defined(MICROPY_EVENT_POLL_HOOK)
332337
MICROPY_EVENT_POLL_HOOK
333338
#endif
334339
}

0 commit comments

Comments
 (0)
0