Skip to content

Commit 5846770

Browse files
committed
zephyr/modmachine: Implement machine.reset().
1 parent 1f3887d commit 5846770

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

zephyr/modmachine.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <stdint.h>
3030
#include <stdio.h>
31+
#include <misc/reboot.h>
3132

3233
#include "py/obj.h"
3334
#include "py/runtime.h"
@@ -40,7 +41,8 @@
4041
#if MICROPY_PY_MACHINE
4142

4243
STATIC mp_obj_t machine_reset(void) {
43-
printf("Warning: %s is not implemented\n", __func__);
44+
sys_reboot(SYS_REBOOT_COLD);
45+
// Won't get here, Zephyr has infiniloop on its side
4446
return mp_const_none;
4547
}
4648
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);
5355

5456
STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
5557
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) },
58+
#ifdef CONFIG_REBOOT
5659
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) },
60+
#endif
5761
{ MP_ROM_QSTR(MP_QSTR_reset_cause), MP_ROM_PTR(&machine_reset_cause_obj) },
5862

5963
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) },

zephyr/prj_base.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CONFIG_LEGACY_KERNEL=n
2+
CONFIG_REBOOT=y
23

34
CONFIG_STDOUT_CONSOLE=y
45
CONFIG_CONSOLE_HANDLER=y

0 commit comments

Comments
 (0)