unix: Update port to use the new event functions.

Necessary to get coverage of the new event functions.

Deletes the case that called usleep(delay) for mp_hal_delay_ms(), it seems
like this wouldn't have ever happened anyhow (MICROPY_EVENT_POOL_HOOK is
always defined for the unix port).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2023-12-07 13:32:41 +11:00
committed by Damien George
parent 73879734d9
commit 2c828a8815
3 changed files with 8 additions and 18 deletions

View File

@@ -237,17 +237,10 @@ uint64_t mp_hal_time_ns(void) {
#ifndef mp_hal_delay_ms
void mp_hal_delay_ms(mp_uint_t ms) {
#ifdef MICROPY_EVENT_POLL_HOOK
mp_uint_t start = mp_hal_ticks_ms();
while (mp_hal_ticks_ms() - start < ms) {
// MICROPY_EVENT_POLL_HOOK does usleep(500).
MICROPY_EVENT_POLL_HOOK
mp_event_wait_ms(1);
}
#else
// TODO: POSIX et al. define usleep() as guaranteedly capable only of 1s sleep:
// "The useconds argument shall be less than one million."
usleep(ms * 1000);
#endif
}
#endif