stm32: usart_common_all: fix bug in baudrate calculation
This function was using apb1 for quite a few families instead of apb2. This only mattered for L1 and F3, and for USART1/USART6, and only if apb1 speed != apb2 speed. Instead of using families explicitly, just check for the peripherals themselves. On F0,F1,F2,F3,F4,F7,H7,L0,L1,L4, usart1/6 are _always_ in the rcc_apb2 register and the other uarts are all on apb1. (F0 doesn't actually _have_ apb2, but it's still called the apb2 register)
This commit is contained in:
parent
874af2e846
commit
5dd0b46298
@ -50,13 +50,12 @@ void usart_set_baudrate(uint32_t usart, uint32_t baud)
|
||||
{
|
||||
uint32_t clock = rcc_apb1_frequency;
|
||||
|
||||
#if defined STM32F2 || defined STM32F4
|
||||
if ((usart == USART1) ||
|
||||
(usart == USART6)) {
|
||||
clock = rcc_apb2_frequency;
|
||||
}
|
||||
#else
|
||||
if (usart == USART1) {
|
||||
#if defined USART1
|
||||
if ((usart == USART1)
|
||||
#if defined USART6
|
||||
|| (usart == USART6)
|
||||
#endif
|
||||
) {
|
||||
clock = rcc_apb2_frequency;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user