summaryrefslogtreecommitdiff
path: root/zephyr/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/main.c')
-rw-r--r--zephyr/main.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/zephyr/main.c b/zephyr/main.c
index 9146cfadb..2c7f3fc47 100644
--- a/zephyr/main.c
+++ b/zephyr/main.c
@@ -67,28 +67,34 @@ int real_main(void) {
// Should be set to stack size in prj.mdef minus fuzz factor
mp_stack_set_limit(3584);
+soft_reset:
#if MICROPY_ENABLE_GC
gc_init(heap, heap + sizeof(heap));
#endif
mp_init();
- MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
+ mp_obj_list_init(mp_sys_path, 0);
+ mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script)
+ mp_obj_list_init(mp_sys_argv, 0);
+
#if MICROPY_MODULE_FROZEN
pyexec_frozen_module("main.py");
#endif
- #if MICROPY_REPL_EVENT_DRIVEN
- pyexec_event_repl_init();
+
for (;;) {
- int c = mp_hal_stdin_rx_chr();
- if (pyexec_event_repl_process_char(c)) {
- break;
+ if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
+ if (pyexec_raw_repl() != 0) {
+ break;
+ }
+ } else {
+ if (pyexec_friendly_repl() != 0) {
+ break;
+ }
}
}
- #else
- pyexec_friendly_repl();
- #endif
- //do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\\n')", MP_PARSE_SINGLE_INPUT);
- //do_str("for i in range(10):\r\n print(i)", MP_PARSE_FILE_INPUT);
- mp_deinit();
+
+ printf("soft reboot\n");
+ goto soft_reset;
+
return 0;
}