From 62ae9ed0394fd8b69ce6e4213e067d8266c8ec2a Mon Sep 17 00:00:00 2001 From: fengsi Date: Fri, 6 Oct 2023 22:18:31 +0800 Subject: [PATCH] [BACKPORT] UART needs to be disabled before changing setup --- arch/arm/src/stm32/stm32_serial.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 04d53c5037a..cad5ff9320f 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -1445,6 +1445,10 @@ static void up_set_format(struct uart_dev_s *dev) regval = up_serialin(priv, STM32_USART_CR1_OFFSET); +#if defined(CONFIG_STM32_STM32G4XXX) + regval &= ~(USART_CR1_UE | USART_CR1_TE | USART_CR1_RE); + up_serialout(priv, STM32_USART_CR1_OFFSET, regval); +#endif #if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)|| \ defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32G4XXX) /* This first implementation is for U[S]ARTs that support oversampling @@ -1623,6 +1627,11 @@ static void up_set_format(struct uart_dev_s *dev) #endif up_serialout(priv, STM32_USART_CR3_OFFSET, regval); +#if defined(CONFIG_STM32_STM32G4XXX) + regval = up_serialin(priv, STM32_USART_CR1_OFFSET); + regval |= (USART_CR1_UE | USART_CR1_TE | USART_CR1_RE); + up_serialout(priv, STM32_USART_CR1_OFFSET, regval); +#endif } #endif /* CONFIG_SUPPRESS_UART_CONFIG */