aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-01-05 15:47:06 +1100
committerDamien George <damien@micropython.org>2024-01-05 15:49:42 +1100
commit0640ff3b97f608a9f55ac380c6681cc48cc1e737 (patch)
treed72b0aa7c46427593d50257e87a985554ceac237
parentd45176fc271d4d5e264bec2809faeb906787a6f9 (diff)
ports: Move MICROPY_INTERNAL_WFE definition to mphalport.h.
It belongs here because the default value is defined in py/mphal.h. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/rp2/mpconfigport.h13
-rw-r--r--ports/rp2/mphalport.h13
-rw-r--r--ports/unix/mpconfigport.h6
-rw-r--r--ports/unix/mphalport.h6
-rw-r--r--ports/windows/mpconfigport.h9
-rw-r--r--ports/windows/windows_mphal.h11
6 files changed, 30 insertions, 28 deletions
diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h
index 8431357ff..ce89763d5 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 b2576c227..c8e2301a9 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 c7e7347cb..1086baea0 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 <stdio.h>
#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 <sched.h>
#define MICROPY_UNIX_MACHINE_IDLE sched_yield();
diff --git a/ports/unix/mphalport.h b/ports/unix/mphalport.h
index ca951e500..02b60d8a8 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 e615fe850..dee5568c6 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 2b7aab44a..e70d00def 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);