summaryrefslogtreecommitdiff
path: root/py/mphal.h
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2023-11-30 16:06:32 +1100
committerDamien George <damien@micropython.org>2023-12-08 12:47:00 +1100
commitf5be0128e4da1417136495c20888f8291cd22386 (patch)
tree0a75714bdd2219bfdc36931c7e6a87d18b221950 /py/mphal.h
parent66be82da7ce63e9c907d7d2ed00341dae80ee83f (diff)
py: Add port-agnostic inline functions for event handling.
These are intended to replace MICROPY_EVENT_POLL_HOOK and MICROPY_EVENT_POLL_HOOK_FAST, which are insufficient for tickless ports. This implementation is along the lines suggested here: https://github.com/micropython/micropython/issues/12925#issuecomment-1803038430 Currently any usage of these functions expands to use the existing hook macros, but this can be switched over port by port. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'py/mphal.h')
-rw-r--r--py/mphal.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/py/mphal.h b/py/mphal.h
index 19fceef71..81cf50918 100644
--- a/py/mphal.h
+++ b/py/mphal.h
@@ -98,4 +98,17 @@ uint64_t mp_hal_time_ns(void);
#include "extmod/virtpin.h"
#endif
+// Event handling and wait-for-event functions.
+
+#ifndef MICROPY_INTERNAL_WFE
+// Fallback definition for ports that don't need to suspend the CPU.
+#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) (void)0
+#endif
+
+#ifndef MICROPY_INTERNAL_EVENT_HOOK
+// Fallback definition for ports that don't need any port-specific
+// non-blocking event processing.
+#define MICROPY_INTERNAL_EVENT_HOOK (void)0
+#endif
+
#endif // MICROPY_INCLUDED_PY_MPHAL_H