diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h index 8431357ffe..ce89763d5e 100644 --- a/ports/rp2/mpconfigport.h +++ b/ports/rp2/mpconfigport.h @@ -245,19 +245,6 @@ extern const struct _mp_obj_type_t mod_network_nic_type_wiznet5k; #define MICROPY_HW_BOOTSEL_DELAY_US 8 #endif -// Port level Wait-for-Event macro -// -// Do not use this macro directly, include py/runtime.h and -// call mp_event_wait_indefinite() or mp_event_wait_ms(timeout) -#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) \ - do { \ - if ((TIMEOUT_MS) < 0) { \ - __wfe(); \ - } else { \ - best_effort_wfe_or_timeout(make_timeout_time_ms(TIMEOUT_MS)); \ - } \ - } while (0) - #define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1)) #define MP_SSIZE_MAX (0x7fffffff) diff --git a/ports/rp2/mphalport.h b/ports/rp2/mphalport.h index b2576c2275..c8e2301a92 100644 --- a/ports/rp2/mphalport.h +++ b/ports/rp2/mphalport.h @@ -48,6 +48,19 @@ #define MICROPY_PY_LWIP_REENTER lwip_lock_acquire(); #define MICROPY_PY_LWIP_EXIT lwip_lock_release(); +// Port level Wait-for-Event macro +// +// Do not use this macro directly, include py/runtime.h and +// call mp_event_wait_indefinite() or mp_event_wait_ms(timeout) +#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) \ + do { \ + if ((TIMEOUT_MS) < 0) { \ + __wfe(); \ + } else { \ + best_effort_wfe_or_timeout(make_timeout_time_ms(TIMEOUT_MS)); \ + } \ + } while (0) + extern int mp_interrupt_char; extern ringbuf_t stdin_ringbuf; diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index c7e7347cbb..1086baea06 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -221,12 +221,6 @@ static inline unsigned long mp_random_seed_init(void) { #include #endif -// In lieu of a WFI(), slow down polling from being a tight loop. -// -// 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 #define MICROPY_UNIX_MACHINE_IDLE sched_yield(); diff --git a/ports/unix/mphalport.h b/ports/unix/mphalport.h index ca951e5001..02b60d8a87 100644 --- a/ports/unix/mphalport.h +++ b/ports/unix/mphalport.h @@ -36,6 +36,12 @@ #define MICROPY_END_ATOMIC_SECTION(x) (void)x; mp_thread_unix_end_atomic_section() #endif +// In lieu of a WFI(), slow down polling from being a tight loop. +// +// 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) + void mp_hal_set_interrupt_char(char c); #define mp_hal_stdio_poll unused // this is not implemented, nor needed diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h index e615fe8502..dee5568c62 100644 --- a/ports/windows/mpconfigport.h +++ b/ports/windows/mpconfigport.h @@ -224,15 +224,6 @@ typedef long mp_off_t; #include "realpath.h" #include "init.h" -#include "sleep.h" - -#if MICROPY_ENABLE_SCHEDULER -// Use minimum 1mSec sleep to make sure there is effectively a wait period: -// something like usleep(500) truncates and ends up calling Sleep(0). -#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) msec_sleep(MAX(1.0, (double)(TIMEOUT_MS))) -#else -#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) /* No-op */ -#endif #ifdef __GNUC__ #define MP_NOINLINE __attribute__((noinline)) diff --git a/ports/windows/windows_mphal.h b/ports/windows/windows_mphal.h index 2b7aab44a0..e70d00def7 100644 --- a/ports/windows/windows_mphal.h +++ b/ports/windows/windows_mphal.h @@ -27,6 +27,17 @@ #include "sleep.h" #include "ports/unix/mphalport.h" +// Don't use the unix version of this macro. +#undef MICROPY_INTERNAL_WFE + +#if MICROPY_ENABLE_SCHEDULER +// Use minimum 1mSec sleep to make sure there is effectively a wait period: +// something like usleep(500) truncates and ends up calling Sleep(0). +#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) msec_sleep(MAX(1.0, (double)(TIMEOUT_MS))) +#else +#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) /* No-op */ +#endif + #define MICROPY_HAL_HAS_VT100 (0) void mp_hal_move_cursor_back(unsigned int pos);