From 748339b28126e69fd2dc2778b2a182901d0a4693 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 18 May 2021 22:17:45 +1000 Subject: [PATCH] stm32/uart: Configure pull-up only on RX and CTS, not TX and RTS. RX and CTS are the input pins and pull-ups are enabled so they don't cause a problem if left unconnected. But the output pins don't need a pull up (they were originally all configured with pull up in commit 8f7491a109a555ca897ae49efe98f4cc2b080311). If needed, the pull-ups can be disabled in Python using machine.Pin after the UART is constructed. See issue #4369. Signed-off-by: Damien George --- ports/stm32/uart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/stm32/uart.c b/ports/stm32/uart.c index a2b69967b6..9f74416170 100644 --- a/ports/stm32/uart.c +++ b/ports/stm32/uart.c @@ -474,10 +474,11 @@ bool uart_init(pyb_uart_obj_t *uart_obj, } uint32_t mode = MP_HAL_PIN_MODE_ALT; - uint32_t pull = MP_HAL_PIN_PULL_UP; for (uint i = 0; i < 4; i++) { if (pins[i] != NULL) { + // Configure pull-up on RX and CTS (the input pins). + uint32_t pull = (i & 1) ? MP_HAL_PIN_PULL_UP : MP_HAL_PIN_PULL_NONE; bool ret = mp_hal_pin_config_alt(pins[i], mode, pull, uart_fn, uart_unit); if (!ret) { return false;