summaryrefslogtreecommitdiff
path: root/ports/stm32/modpyb.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-11-23 16:36:52 +1100
committerDamien George <damien@micropython.org>2023-11-30 16:11:11 +1100
commit30a63a204dc6ad02c996d5c40c34b67c85c650e4 (patch)
tree464f08a0b2cd65e773daaf93101fdeeee25cfb81 /ports/stm32/modpyb.c
parent7d39db2503cab67f03216161b0e829939f80fff7 (diff)
extmod/modmachine: Provide common Python bindings for machine.idle().
And use it in all ports. The ports are unchanged, except esp8266 which now just returns None from this function instead of the time elapsed (to match other ports), and qemu-arm which gains this function. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/stm32/modpyb.c')
-rw-r--r--ports/stm32/modpyb.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c
index 0bf2d6a2c..165c982f5 100644
--- a/ports/stm32/modpyb.c
+++ b/ports/stm32/modpyb.c
@@ -65,6 +65,12 @@ STATIC mp_obj_t pyb_fault_debug(mp_obj_t value) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_fault_debug_obj, pyb_fault_debug);
+STATIC mp_obj_t pyb_idle(void) {
+ __WFI();
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_idle_obj, pyb_idle);
+
#if MICROPY_PY_PYB_LEGACY
// Returns the number of milliseconds which have elapsed since `start`.
@@ -144,7 +150,7 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_repl_info), MP_ROM_PTR(&pyb_set_repl_info_obj) },
#endif
- { MP_ROM_QSTR(MP_QSTR_wfi), MP_ROM_PTR(&machine_idle_obj) },
+ { MP_ROM_QSTR(MP_QSTR_wfi), MP_ROM_PTR(&pyb_idle_obj) },
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) },
#if IRQ_ENABLE_STATS