diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c index 7068d8e609..2f813ca22f 100644 --- a/esp8266/esp_mphal.c +++ b/esp8266/esp_mphal.c @@ -66,7 +66,7 @@ void mp_hal_delay_us(uint32_t us) { int mp_hal_stdin_rx_chr(void) { for (;;) { - int c = uart0_rx(); + int c = ringbuf_get(&input_buf); if (c != -1) { return c; } @@ -156,7 +156,9 @@ void __assert_func(const char *file, int line, const char *func, const char *exp } void mp_hal_signal_input(void) { + #if MICROPY_REPL_EVENT_DRIVEN system_os_post(UART_TASK_ID, 0, 0); + #endif } static int call_dupterm_read(void) { diff --git a/esp8266/main.c b/esp8266/main.c index bb282462fd..de9df74135 100644 --- a/esp8266/main.c +++ b/esp8266/main.c @@ -62,15 +62,38 @@ void soft_reset(void) { mp_hal_stdout_tx_str("PYB: soft reboot\r\n"); mp_hal_delay_us(10000); // allow UART to flush output mp_reset(); + #if MICROPY_REPL_EVENT_DRIVEN pyexec_event_repl_init(); + #endif } void init_done(void) { + #if MICROPY_REPL_EVENT_DRIVEN uart_task_init(); + #endif mp_reset(); mp_hal_stdout_tx_str("\r\n"); + #if MICROPY_REPL_EVENT_DRIVEN pyexec_event_repl_init(); + #endif dupterm_task_init(); + + #if !MICROPY_REPL_EVENT_DRIVEN +soft_reset: + for (;;) { + if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { + if (pyexec_raw_repl() != 0) { + break; + } + } else { + if (pyexec_friendly_repl() != 0) { + break; + } + } + } + soft_reset(); + goto soft_reset; + #endif } void user_init(void) { diff --git a/esp8266/uart.c b/esp8266/uart.c index 9b2bfb4c83..bfc380ae4a 100644 --- a/esp8266/uart.c +++ b/esp8266/uart.c @@ -233,6 +233,7 @@ void soft_reset(void); void mp_keyboard_interrupt(void); int interrupt_char; +#if MICROPY_REPL_EVENT_DRIVEN void uart_task_handler(os_event_t *evt) { if (pyexec_repl_active) { // TODO: Just returning here isn't exactly right. @@ -264,3 +265,4 @@ void uart_task_handler(os_event_t *evt) { void uart_task_init() { system_os_task(uart_task_handler, UART_TASK_ID, uart_evt_queue, sizeof(uart_evt_queue) / sizeof(*uart_evt_queue)); } +#endif