Commit 050e645e authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

esp8266/modmachine: Add reset_cause() function.

parent 53ac7830
...@@ -64,6 +64,11 @@ STATIC mp_obj_t machine_reset(void) { ...@@ -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_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) { STATIC mp_obj_t machine_unique_id(void) {
uint32_t id = system_get_chip_id(); uint32_t id = system_get_chip_id();
return mp_obj_new_bytes((byte*)&id, sizeof(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[] = { ...@@ -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_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), 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_unique_id), MP_ROM_PTR(&machine_unique_id_obj) },
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&esp_timer_type) }, { MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&esp_timer_type) },
......
...@@ -214,6 +214,7 @@ Q(time) ...@@ -214,6 +214,7 @@ Q(time)
// machine // machine
Q(reset) Q(reset)
Q(reset_cause)
Q(Timer) Q(Timer)
Q(callback) Q(callback)
Q(deinit) Q(deinit)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment