From 8e3ee303ce8bb05b784a3e100f2fac77dec10a49 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 18 Nov 2025 21:50:02 -0600 Subject: [PATCH] unix/unix_mphal: Ensure mp_hal_delay_ms handles pending tasks. This ensures that zero-duration delays run scheduled callbacks. Signed-off-by: Jeff Epler --- ports/unix/unix_mphal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c index 5f5abc2e05..39311c9872 100644 --- a/ports/unix/unix_mphal.c +++ b/ports/unix/unix_mphal.c @@ -242,9 +242,13 @@ uint64_t mp_hal_time_ns(void) { #ifndef mp_hal_delay_ms void mp_hal_delay_ms(mp_uint_t ms) { - mp_uint_t start = mp_hal_ticks_ms(); - while (mp_hal_ticks_ms() - start < ms) { - mp_event_wait_ms(1); + if (ms) { + mp_uint_t start = mp_hal_ticks_ms(); + while (mp_hal_ticks_ms() - start < ms) { + mp_event_wait_ms(1); + } + } else { + mp_handle_pending(true); } } #endif