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 <karlp@tweak.au>
This commit is contained in:
Harry Geyer
2023-01-12 13:33:56 +00:00
committed by Karl Palsson
parent e643f66342
commit 4d7a2ca271

View File

@@ -52,17 +52,7 @@ usart_reg_base
void usart_set_baudrate(uint32_t usart, uint32_t baud) void usart_set_baudrate(uint32_t usart, uint32_t baud)
{ {
uint32_t clock = rcc_apb1_frequency; uint32_t clock = rcc_get_usart_clk_freq(usart);
#if defined USART1
if ((usart == USART1)
#if defined USART6
|| (usart == USART6)
#endif
) {
clock = rcc_apb2_frequency;
}
#endif
/* /*
* Yes it is as simple as that. The reference manual is * Yes it is as simple as that. The reference manual is