Skip to content

Commit

Permalink
rp2/mpnetworkport: Fix lwip alarm callback timing to use microseconds.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dpgeorge committed Jun 7, 2022
1 parent c58dc7f commit a446a7b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ports/rp2/mpnetworkport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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

0 comments on commit a446a7b

Please sign in to comment.