Skip to content

Commit

Permalink
stm32/uart: Configure pull-up only on RX and CTS, not TX and RTS.
Browse files Browse the repository at this point in the history
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
8f7491a).

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 <damien@micropython.org>
  • Loading branch information
dpgeorge committed May 20, 2021
1 parent a96afae commit 748339b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ports/stm32/uart.c
Expand Up @@ -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;
Expand Down

0 comments on commit 748339b

Please sign in to comment.