From c2070d771a70df6ebe19d6ca97b363b2b38d69fa Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 7 Aug 2016 15:51:04 +0300 Subject: [PATCH] esp8266/modmachine: Implement idle() function. --- esp8266/modmachine.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/esp8266/modmachine.c b/esp8266/modmachine.c index 80ae7ac2a0..f231b9baef 100644 --- a/esp8266/modmachine.c +++ b/esp8266/modmachine.c @@ -82,6 +82,12 @@ STATIC mp_obj_t machine_unique_id(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id); +STATIC mp_obj_t machine_idle(void) { + asm("waiti 0"); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle); + STATIC mp_obj_t machine_deepsleep(void) { // default to sleep forever uint32_t sleep_us = 0; @@ -222,6 +228,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset_cause), MP_ROM_PTR(&machine_reset_cause_obj) }, { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, + { MP_ROM_QSTR(MP_QSTR_idle), MP_ROM_PTR(&machine_idle_obj) }, { MP_ROM_QSTR(MP_QSTR_deepsleep), MP_ROM_PTR(&machine_deepsleep_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },