extmod/modmachine: Use sys.exit as implementation of machine.soft_reset.
It does the same thing, raising `SystemExit`. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "py/builtin.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
#if MICROPY_PY_MACHINE
|
#if MICROPY_PY_MACHINE
|
||||||
@@ -35,6 +36,10 @@
|
|||||||
#include "drivers/dht/dht.h"
|
#include "drivers/dht/dht.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !MICROPY_PY_SYS_EXIT
|
||||||
|
#error MICROPY_PY_MACHINE requires MICROPY_PY_SYS_EXIT
|
||||||
|
#endif
|
||||||
|
|
||||||
// The port must provide implementations of these low-level machine functions.
|
// The port must provide implementations of these low-level machine functions.
|
||||||
|
|
||||||
static void mp_machine_idle(void);
|
static void mp_machine_idle(void);
|
||||||
@@ -61,11 +66,6 @@ NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args);
|
|||||||
#include MICROPY_PY_MACHINE_INCLUDEFILE
|
#include MICROPY_PY_MACHINE_INCLUDEFILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static mp_obj_t machine_soft_reset(void) {
|
|
||||||
mp_raise_type(&mp_type_SystemExit);
|
|
||||||
}
|
|
||||||
static MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
|
|
||||||
|
|
||||||
#if MICROPY_PY_MACHINE_BOOTLOADER
|
#if MICROPY_PY_MACHINE_BOOTLOADER
|
||||||
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
|
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
|
||||||
mp_machine_bootloader(n_args, args);
|
mp_machine_bootloader(n_args, args);
|
||||||
@@ -156,7 +156,7 @@ static const mp_rom_map_elem_t machine_module_globals_table[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Reset related functions.
|
// Reset related functions.
|
||||||
{ MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&machine_soft_reset_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_soft_reset), MP_ROM_PTR(&mp_sys_exit_obj) },
|
||||||
#if MICROPY_PY_MACHINE_BOOTLOADER
|
#if MICROPY_PY_MACHINE_BOOTLOADER
|
||||||
{ MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_bootloader), MP_ROM_PTR(&machine_bootloader_obj) },
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ MP_DECLARE_CONST_FUN_OBJ_2(mp_op_getitem_obj);
|
|||||||
MP_DECLARE_CONST_FUN_OBJ_3(mp_op_setitem_obj);
|
MP_DECLARE_CONST_FUN_OBJ_3(mp_op_setitem_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_2(mp_op_delitem_obj);
|
MP_DECLARE_CONST_FUN_OBJ_2(mp_op_delitem_obj);
|
||||||
|
|
||||||
|
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj);
|
||||||
|
|
||||||
// Modules needed by the runtime.
|
// Modules needed by the runtime.
|
||||||
extern const mp_obj_dict_t mp_module_builtins_globals;
|
extern const mp_obj_dict_t mp_module_builtins_globals;
|
||||||
extern const mp_obj_module_t mp_module___main__;
|
extern const mp_obj_module_t mp_module___main__;
|
||||||
|
|||||||
Reference in New Issue
Block a user