From 88971342b17f48fb91619620f4c4c1b5da40aaa4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 1 Jun 2020 21:22:03 +1000 Subject: [PATCH] stm32/machine_uart: Retain attached-to-repl setting when init'ing UART. --- ports/stm32/machine_uart.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/stm32/machine_uart.c b/ports/stm32/machine_uart.c index 232f3629ee..1cf5817e01 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;