extmod: Switch to use new event functions.

See previous commit for details of these functions.  As of this commit,
these still call the old hook macros on all ports.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2023-11-30 14:32:41 +11:00
committed by Damien George
parent f5be0128e4
commit df3948d3c2
7 changed files with 29 additions and 27 deletions

View File

@@ -222,8 +222,13 @@ STATIC mp_obj_t network_cyw43_scan(size_t n_args, const mp_obj_t *pos_args, mp_m
// Wait for scan to finish, with a 10s timeout
uint32_t start = mp_hal_ticks_ms();
while (cyw43_wifi_scan_active(self->cyw) && mp_hal_ticks_ms() - start < 10000) {
MICROPY_EVENT_POLL_HOOK
const uint32_t TIMEOUT = 10000;
while (cyw43_wifi_scan_active(self->cyw)) {
uint32_t elapsed = mp_hal_ticks_ms() - start;
if (elapsed >= TIMEOUT) {
break;
}
mp_event_wait_ms(TIMEOUT - elapsed);
}
return res;