Commit 58467709 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

zephyr/modmachine: Implement machine.reset().

parent 1f3887dc
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <misc/reboot.h>
#include "py/obj.h" #include "py/obj.h"
#include "py/runtime.h" #include "py/runtime.h"
...@@ -40,7 +41,8 @@ ...@@ -40,7 +41,8 @@
#if MICROPY_PY_MACHINE #if MICROPY_PY_MACHINE
STATIC mp_obj_t machine_reset(void) { STATIC mp_obj_t machine_reset(void) {
printf("Warning: %s is not implemented\n", __func__); sys_reboot(SYS_REBOOT_COLD);
// Won't get here, Zephyr has infiniloop on its side
return mp_const_none; return mp_const_none;
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset); STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset);
...@@ -53,7 +55,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause); ...@@ -53,7 +55,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause);
STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) },
#ifdef CONFIG_REBOOT
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) },
#endif
{ MP_ROM_QSTR(MP_QSTR_reset_cause), MP_ROM_PTR(&machine_reset_cause_obj) }, { MP_ROM_QSTR(MP_QSTR_reset_cause), MP_ROM_PTR(&machine_reset_cause_obj) },
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) }, { MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) },
......
CONFIG_LEGACY_KERNEL=n CONFIG_LEGACY_KERNEL=n
CONFIG_REBOOT=y
CONFIG_STDOUT_CONSOLE=y CONFIG_STDOUT_CONSOLE=y
CONFIG_CONSOLE_HANDLER=y CONFIG_CONSOLE_HANDLER=y
......
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