Browse Source

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>
pull/1464/head
Harry Geyer 2 years ago
committed by Karl Palsson
parent
commit
4d7a2ca271
  1. 12
      lib/stm32/common/usart_common_all.c

12
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

Loading…
Cancel
Save