diff options
| author | Damien George <damien@micropython.org> | 2023-11-23 16:36:52 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-11-30 16:11:11 +1100 |
| commit | 30a63a204dc6ad02c996d5c40c34b67c85c650e4 (patch) | |
| tree | 464f08a0b2cd65e773daaf93101fdeeee25cfb81 /ports/unix/modmachine.c | |
| parent | 7d39db2503cab67f03216161b0e829939f80fff7 (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/unix/modmachine.c')
| -rw-r--r-- | ports/unix/modmachine.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/ports/unix/modmachine.c b/ports/unix/modmachine.c index 91e3e6134..9eacd5539 100644 --- a/ports/unix/modmachine.c +++ b/ports/unix/modmachine.c @@ -36,14 +36,7 @@ #define MICROPY_PAGE_MASK (MICROPY_PAGE_SIZE - 1) #endif -#ifdef MICROPY_UNIX_MACHINE_IDLE -#define MICROPY_PY_MACHINE_IDLE_ENTRY { MP_ROM_QSTR(MP_QSTR_idle), MP_ROM_PTR(&machine_idle_obj) }, -#else -#define MICROPY_PY_MACHINE_IDLE_ENTRY -#endif - #define MICROPY_PY_MACHINE_EXTRA_GLOBALS \ - MICROPY_PY_MACHINE_IDLE_ENTRY \ { MP_ROM_QSTR(MP_QSTR_PinBase), MP_ROM_PTR(&machine_pinbase_type) }, \ // This variable is needed for machine.soft_reset(), but the variable is otherwise unused. @@ -80,10 +73,10 @@ uintptr_t mod_machine_mem_get_addr(mp_obj_t addr_o, uint align) { return addr; } -#ifdef MICROPY_UNIX_MACHINE_IDLE -STATIC mp_obj_t machine_idle(void) { +STATIC void mp_machine_idle(void) { + #ifdef MICROPY_UNIX_MACHINE_IDLE MICROPY_UNIX_MACHINE_IDLE - return mp_const_none; + #else + // Do nothing. + #endif } -MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle); -#endif |
