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:
committed by
Karl Palsson
parent
e643f66342
commit
4d7a2ca271
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user