esp8266: Support dedicated REPL loop (aka pull-style).
Event-driven loop (push-style) is still supported and default (controlled by MICROPY_REPL_EVENT_DRIVEN setting, as expected). Dedicated loop worked even without adding ets_loop_iter(), though that needs to be revisited later.
This commit is contained in:
parent
777232c9a5
commit
785cf9a61f
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue