From 4d7a2ca271b846e7333e5da09ca1a6d0bf4b663f Mon Sep 17 00:00:00 2001 From: Harry Geyer Date: Thu, 12 Jan 2023 13:33:56 +0000 Subject: [PATCH] stm32: When setting baudrate of a USART, first get the clock frequency for that USART. Now that all families have support for calculating the clock of the uart, use that layer. Slightly slower for "old" families, but the only way to be correct for newer families. Reviewed-by: Karl Palsson --- lib/stm32/common/usart_common_all.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/stm32/common/usart_common_all.c b/lib/stm32/common/usart_common_all.c index e30e2feb..8e676c07 100644 --- a/lib/stm32/common/usart_common_all.c +++ b/lib/stm32/common/usart_common_all.c @@ -52,17 +52,7 @@ usart_reg_base void usart_set_baudrate(uint32_t usart, uint32_t baud) { - uint32_t clock = rcc_apb1_frequency; - -#if defined USART1 - if ((usart == USART1) -#if defined USART6 - || (usart == USART6) -#endif - ) { - clock = rcc_apb2_frequency; - } -#endif + uint32_t clock = rcc_get_usart_clk_freq(usart); /* * Yes it is as simple as that. The reference manual is