summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266
diff options
context:
space:
mode:
Diffstat (limited to 'esp8266')
-rw-r--r--esp8266/main.c34
-rw-r--r--esp8266/uart.c10
2 files changed, 20 insertions, 24 deletions
diff --git a/esp8266/main.c b/esp8266/main.c
index b6024f3c57..a3878c0e75 100644
--- a/esp8266/main.c
+++ b/esp8266/main.c
@@ -39,8 +39,7 @@
STATIC char heap[16384];
-void user_init(void) {
-soft_reset:
+STATIC void mp_reset(void) {
mp_stack_set_limit(10240);
mp_hal_init();
gc_init(heap, heap + sizeof(heap));
@@ -48,29 +47,20 @@ soft_reset:
mp_init();
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_init(mp_sys_argv, 0);
+}
- printf("\n");
+void soft_reset(void) {
+ mp_hal_stdout_tx_str("PYB: soft reset\r\n");
+ mp_hal_udelay(10000); // allow UART to flush output
+ mp_reset();
+ pyexec_event_repl_init();
+}
-#if MICROPY_REPL_EVENT_DRIVEN
- pyexec_friendly_repl_init();
+void user_init(void) {
+ mp_reset();
+ mp_hal_stdout_tx_str("\r\n");
+ pyexec_event_repl_init();
uart_task_init();
- return;
- goto soft_reset;
-#else
- for (;;) {
- if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
- if (pyexec_raw_repl() != 0) {
- break;
- }
- } else {
- if (pyexec_friendly_repl() != 0) {
- break;
- }
- }
- }
-
- goto soft_reset;
-#endif
}
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
diff --git a/esp8266/uart.c b/esp8266/uart.c
index 6087668a70..87bbb7c92e 100644
--- a/esp8266/uart.c
+++ b/esp8266/uart.c
@@ -200,10 +200,16 @@ void ICACHE_FLASH_ATTR uart_reattach() {
// Task-based UART interface
-int pyexec_friendly_repl_process_char(int c);
+#include "py/obj.h"
+#include "stmhal/pyexec.h"
+
+void soft_reset(void);
void uart_task_handler(os_event_t *evt) {
- pyexec_friendly_repl_process_char(evt->par);
+ int ret = pyexec_event_repl_process_char(evt->par);
+ if (ret & PYEXEC_FORCED_EXIT) {
+ soft_reset();
+ }
}
void uart_task_init() {