summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-06-01 21:22:03 +1000
committerDamien George <damien.p.george@gmail.com>2020-06-01 21:41:50 +1000
commit88971342b17f48fb91619620f4c4c1b5da40aaa4 (patch)
treec90de168345261c6fec880674d69c952463eaab2
parent22806ed5df27c10131af0cedb2f7e8b134fe6e7a (diff)
stm32/machine_uart: Retain attached-to-repl setting when init'ing UART.
-rw-r--r--ports/stm32/machine_uart.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ports/stm32/machine_uart.c b/ports/stm32/machine_uart.c
index 232f3629e..1cf5817e0 100644
--- a/ports/stm32/machine_uart.c
+++ b/ports/stm32/machine_uart.c
@@ -283,11 +283,17 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const
// flow control
uint32_t flow = args.flow.u_int;
+ // Save attach_to_repl setting because uart_init will disable it.
+ bool attach_to_repl = self->attached_to_repl;
+
// init UART (if it fails, it's because the port doesn't exist)
if (!uart_init(self, baudrate, bits, parity, stop, flow)) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART(%d) doesn't exist"), self->uart_id);
}
+ // Restore attach_to_repl setting so UART still works if attached to dupterm.
+ uart_attach_to_repl(self, attach_to_repl);
+
// set timeout
self->timeout = args.timeout.u_int;