8000 esp32/modmachine: Add implementation of machine.soft_reset(). · micropython/micropython@6632dd3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6632dd3

Browse files
tvedpgeorge
authored andcommitted
esp32/modmachine: Add implementation of machine.soft_reset().
1 parent 1caede9 commit 6632dd3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ports/esp32/modmachine.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
#include "py/obj.h"
4848
#include "py/runtime.h"
49+
#include "lib/utils/pyexec.h"
4950
#include "extmod/machine_mem.h"
5051
#include "extmod/machine_signal.h"
5152
#include "extmod/machine_pulse.h"
@@ -193,6 +194,12 @@ STATIC mp_obj_t machine_reset(void) {
193194
}
194195
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset);
195196

197+
STATIC mp_obj_t machine_soft_reset(void) {
198+
pyexec_system_exit = PYEXEC_FORCED_EXIT;
199+
nlr_raise(mp_obj_new_exception(&mp_type_SystemExit));
200+
}
201+
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
202 7A39 +
196203
STATIC mp_obj_t machine_unique_id(void) {
197204
uint8_t chipid[6];
198205
esp_efuse_mac_get_default(chipid);
@@ -228,6 +235,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
228235

229236
{ MP_ROM_QSTR(MP_QSTR_freq), MP_ROM_PTR(&machine_freq_obj) },
230237
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) },
238+
{ MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) },
231239
{ MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) },
232240
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_lightsleep_obj) },
233241
{ MP_ROM_QSTR(MP_QSTR_lightsleep), MP_ROM_PTR(&machine_lightsleep_obj) },

0 commit comments

Comments
 (0)
0