From 3c09c21fda1acee7e87e8c06daeaa5b2ba6b782c Mon Sep 17 00:00:00 2001 From: Peter Maxwell Warasila Date: Mon, 9 May 2022 16:28:51 -0400 Subject: [PATCH] drivers: serial: uart_stm32: tx/rx swap in init() Previously, the uart_stm32 driver was extended in #44487 to support swapping the tx and rx pins of supported STM32 UART peripherals. However, the original change applied this configuration during the call to the uart_stm32_configure() function. This has now been added to the uart_stm32_init() function to ensure this behavior on startup for ports like the virtual com port. Signed-off-by: Peter Maxwell Warasila --- drivers/serial/uart_stm32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index efa6f2ec67b..a5807563636 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -473,12 +473,6 @@ static int uart_stm32_configure(const struct device *dev, data->baud_rate = cfg->baudrate; } -#ifdef LL_USART_TXRX_SWAPPED - if (config->tx_rx_swap) { - LL_USART_SetTXRXSwap(config->usart, LL_USART_TXRX_SWAPPED); - } -#endif - LL_USART_Enable(config->usart); return 0; }; @@ -1612,6 +1606,12 @@ static int uart_stm32_init(const struct device *dev) LL_USART_EnableHalfDuplex(config->usart); } +#ifdef LL_USART_TXRX_SWAPPED + if (config->tx_rx_swap) { + LL_USART_SetTXRXSwap(config->usart, LL_USART_TXRX_SWAPPED); + } +#endif + LL_USART_Enable(config->usart); #ifdef USART_ISR_TEACK