summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/unix/coverage.c5
-rw-r--r--ports/unix/mpconfigport.h12
-rw-r--r--ports/unix/unix_mphal.c9
3 files changed, 8 insertions, 18 deletions
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c
index 88dd48bfa..543af365c 100644
--- a/ports/unix/coverage.c
+++ b/ports/unix/coverage.c
@@ -578,9 +578,10 @@ STATIC mp_obj_t extra_coverage(void) {
mp_sched_unlock();
mp_printf(&mp_plat_print, "unlocked\n");
- // drain pending callbacks
+ // drain pending callbacks, and test mp_event_wait_indefinite(), mp_event_wait_ms()
+ mp_event_wait_indefinite(); // the unix port only waits 500us in this call
while (mp_sched_num_pending()) {
- mp_handle_pending(true);
+ mp_event_wait_ms(1);
}
// setting the keyboard interrupt and raising it during mp_handle_pending
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index e7ce534a7..c7e7347cb 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -222,14 +222,10 @@ static inline unsigned long mp_random_seed_init(void) {
#endif
// In lieu of a WFI(), slow down polling from being a tight loop.
-#ifndef MICROPY_EVENT_POLL_HOOK
-#define MICROPY_EVENT_POLL_HOOK \
- do { \
- extern void mp_handle_pending(bool); \
- mp_handle_pending(true); \
- usleep(500); /* equivalent to mp_hal_delay_us(500) */ \
- } while (0);
-#endif
+//
+// Note that we don't delay for the full TIMEOUT_MS, as execution
+// can't be woken from the delay.
+#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) mp_hal_delay_us(500)
// Configure the implementation of machine.idle().
#include <sched.h>
diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c
index eafc915ca..8d6539c88 100644
--- a/ports/unix/unix_mphal.c
+++ b/ports/unix/unix_mphal.c
@@ -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