diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-10-04 21:20:47 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-10-04 21:20:47 +0300 |
commit | 52784bf5951b6b76cf2c3125a7b78bcfef0553c3 (patch) | |
tree | 30dc2becfb451dcdb0c4472cc43e2f11fae3fb1e /esp8266/modmachine.c | |
parent | addd1d3db1e8835f9e2d73fd4fbd5ee818bbcb4a (diff) |
esp8266/modmachine: idle(): Return number of CPU cycles spent idling.
Useful to better understand esp8266 inner workings and compare behavior
in different cases.
Diffstat (limited to 'esp8266/modmachine.c')
-rw-r--r-- | esp8266/modmachine.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/esp8266/modmachine.c b/esp8266/modmachine.c index 8a81cba53..0ab3c122b 100644 --- a/esp8266/modmachine.c +++ b/esp8266/modmachine.c @@ -86,8 +86,10 @@ 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) { + uint32_t t = mp_hal_ticks_cpu(); asm("waiti 0"); - return mp_const_none; + t = mp_hal_ticks_cpu() - t; + return MP_OBJ_NEW_SMALL_INT(t); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle); |