diff options
author | Damien George <damien@micropython.org> | 2024-08-07 17:47:46 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-08-29 23:46:13 +1000 |
commit | c94a3205b044fb27fa703d5c280fb02a094f12e3 (patch) | |
tree | c4f82c2f067cba6b1b47bc711531d9efcf281b43 | |
parent | a5cc4d46237bf5c905bdddd0a117b8fea35b7f7d (diff) |
stm32/machine_uart: Allow changing only the baudrate.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/stm32/machine_uart.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ports/stm32/machine_uart.c b/ports/stm32/machine_uart.c index 277ae67ef..9bd4c5e01 100644 --- a/ports/stm32/machine_uart.c +++ b/ports/stm32/machine_uart.c @@ -154,6 +154,12 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args, { MP_QSTR_read_buf_len, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, // legacy }; + if (self->is_enabled && n_args == 1 && kw_args->used == 0) { + // Only change the baudrate if that's all that is given. + uart_set_baudrate(self, mp_obj_get_int(pos_args[0])); + return; + } + // parse args struct { mp_arg_val_t baudrate, bits, parity, stop, flow, timeout, timeout_char, rxbuf, read_buf_len; |