Skip to content

Commit c961889

Browse files
committed
esp8266: Add basic support for duplicating REPL output.
1 parent 6ca17c1 commit c961889

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

esp8266/esp_mphal.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "ets_alt_task.h"
3434
#include "py/obj.h"
3535
#include "py/mpstate.h"
36+
#include "extmod/misc.h"
3637

3738
extern void ets_wdt_disable(void);
3839
extern void wdt_feed(void);
@@ -68,24 +69,29 @@ int mp_hal_stdin_rx_chr(void) {
6869
}
6970
}
7071

72+
void mp_hal_stdout_tx_char(char c) {
73+
uart_tx_one_char(UART0, c);
74+
mp_uos_dupterm_tx_strn(&c, 1);
75+
}
76+
7177
void mp_hal_stdout_tx_str(const char *str) {
7278
while (*str) {
73-
uart_tx_one_char(UART0, *str++);
79+
mp_hal_stdout_tx_char(*str++);
7480
}
7581
}
7682

7783
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
7884
while (len--) {
79-
uart_tx_one_char(UART0, *str++);
85+
mp_hal_stdout_tx_char(*str++);
8086
}
8187
}
8288

8389
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
8490
while (len--) {
8591
if (*str == '\n') {
86-
uart_tx_one_char(UART0, '\r');
92+
mp_hal_stdout_tx_char('\r');
8793
}
88-
uart_tx_one_char(UART0, *str++);
94+
mp_hal_stdout_tx_char(*str++);
8995
}
9096
}
9197

esp8266/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#define MICROPY_PY_LWIP (1)
5252
#define MICROPY_PY_MACHINE (1)
5353
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
54+
#define MICROPY_PY_OS_DUPTERM (1)
5455
#define MICROPY_CPYTHON_COMPAT (1)
5556
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
5657
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)

0 commit comments

Comments
 (0)