From 6e90111eb9df25933f522b170dad408fec98b3c8 Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Fri, 8 Jan 2021 11:25:37 +0100 Subject: [PATCH] stm32/periph/uart: set flow control bits before enabling uart --- cpu/stm32/periph/uart.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cpu/stm32/periph/uart.c b/cpu/stm32/periph/uart.c index afc7821367..44f57c8b77 100644 --- a/cpu/stm32/periph/uart.c +++ b/cpu/stm32/periph/uart.c @@ -215,6 +215,15 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) * sent. */ uart_init_pins(uart, rx_cb); +#ifdef MODULE_PERIPH_UART_HW_FC + if (uart_config[uart].cts_pin != GPIO_UNDEF) { + dev(uart)->CR3 |= USART_CR3_CTSE; + } + if (uart_config[uart].rts_pin != GPIO_UNDEF) { + dev(uart)->CR3 |= USART_CR3_RTSE; + } +#endif + /* enable RX interrupt if applicable */ if (rx_cb) { NVIC_EnableIRQ(uart_config[uart].irqn); @@ -228,15 +237,6 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) NVIC_EnableIRQ(uart_config[uart].irqn); #endif -#ifdef MODULE_PERIPH_UART_HW_FC - if (uart_config[uart].cts_pin != GPIO_UNDEF) { - dev(uart)->CR3 |= USART_CR3_CTSE; - } - if (uart_config[uart].rts_pin != GPIO_UNDEF) { - dev(uart)->CR3 |= USART_CR3_RTSE; - } -#endif - return UART_OK; }