summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/modmachine.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-04-15 22:07:28 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-04-15 22:08:04 +0300
commit050e645ef2380d14a2833edb509d4f7498f6d035 (patch)
tree017639c2d032bb46d7c5cdb8134246ab4ad105d3 /esp8266/modmachine.c
parent53ac7830cb501834fee9dda0c081261c1b62997c (diff)
downloadmicropython-050e645ef2380d14a2833edb509d4f7498f6d035.tar.gz
micropython-050e645ef2380d14a2833edb509d4f7498f6d035.zip
esp8266/modmachine: Add reset_cause() function.
Diffstat (limited to 'esp8266/modmachine.c')
-rw-r--r--esp8266/modmachine.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/esp8266/modmachine.c b/esp8266/modmachine.c
index 8fb88fafd7..83fb8d3504 100644
--- a/esp8266/modmachine.c
+++ b/esp8266/modmachine.c
@@ -64,6 +64,11 @@ STATIC mp_obj_t machine_reset(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset);
+STATIC mp_obj_t machine_reset_cause(void) {
+ return MP_OBJ_NEW_SMALL_INT(system_get_rst_info()->reason);
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause);
+
STATIC mp_obj_t machine_unique_id(void) {
uint32_t id = system_get_chip_id();
return mp_obj_new_bytes((byte*)&id, sizeof(id));
@@ -153,6 +158,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_freq), MP_ROM_PTR(&machine_freq_obj) },
{ 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_Timer), MP_ROM_PTR(&esp_timer_type) },