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 <jepler@unpythonic.net>
This commit is contained in:
Jeff Epler
2025-11-18 21:50:02 -06:00
committed by Damien George
parent 16ccf55fd8
commit 8e3ee303ce

View File

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