From a446a7bdef86c2e4fef673e0d1f07e5a35672831 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 7 Jun 2022 14:19:22 +1000 Subject: [PATCH] rp2/mpnetworkport: Fix lwip alarm callback timing to use microseconds. The callback passed to add_alarm_in_ms must return microseconds, even though the initial delay is in milliseconds. Fix this use, and to avoid further confusion use the add_alarm_in_us function instead. Signed-off-by: Damien George --- ports/rp2/mpnetworkport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/rp2/mpnetworkport.c b/ports/rp2/mpnetworkport.c index 7ee10bb03e0f..b481abba2323 100644 --- a/ports/rp2/mpnetworkport.c +++ b/ports/rp2/mpnetworkport.c @@ -106,7 +106,7 @@ STATIC int64_t alarm_callback(alarm_id_t id, void *user_data) { #if MICROPY_PY_WIZNET5K wiznet5k_try_poll(); #endif - return lwip_try_poll(); + return (int64_t)lwip_try_poll() * 1000; } void mod_network_lwip_init(void) { @@ -116,7 +116,7 @@ void mod_network_lwip_init(void) { if (lwip_alarm_id != -1) { cancel_alarm(lwip_alarm_id); } - lwip_alarm_id = add_alarm_in_ms(LWIP_TICK_RATE_MS, alarm_callback, mp_const_true, true); + lwip_alarm_id = add_alarm_in_us(LWIP_TICK_RATE_MS * 1000, alarm_callback, mp_const_true, true); } #endif // MICROPY_PY_LWIP