diff options
| author | Thorsten von Eicken | 2020-01-09 17:43:28 -0800 |
|---|---|---|
| committer | Damien George | 2020-01-12 13:38:45 +1100 |
| commit | 6632dd3981cbdca8e70c0bf19e36338101e9ce0e (patch) | |
| tree | fc8e6189c02940ba51f9a8be58ec8ba748d167b5 | |
| parent | 1caede927ab946e989946d78878934a15ed3d487 (diff) | |
esp32/modmachine: Add implementation of machine.soft_reset().
| -rw-r--r-- | ports/esp32/modmachine.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index e722ed2c5..6e0d0593a 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -46,6 +46,7 @@ #include "py/obj.h" #include "py/runtime.h" +#include "lib/utils/pyexec.h" #include "extmod/machine_mem.h" #include "extmod/machine_signal.h" #include "extmod/machine_pulse.h" @@ -193,6 +194,12 @@ STATIC mp_obj_t machine_reset(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset); +STATIC mp_obj_t machine_soft_reset(void) { + pyexec_system_exit = PYEXEC_FORCED_EXIT; + nlr_raise(mp_obj_new_exception(&mp_type_SystemExit)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset); + STATIC mp_obj_t machine_unique_id(void) { uint8_t chipid[6]; esp_efuse_mac_get_default(chipid); @@ -228,6 +235,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_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_lightsleep_obj) }, { MP_ROM_QSTR(MP_QSTR_lightsleep), MP_ROM_PTR(&machine_lightsleep_obj) }, |
