stm32/uart: Use LL_USART_GetBaudRate to compute baudrate.
This function includes the UART prescaler in the calculation (if it has one, eg on H7 and WB MCUs). Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
25c029ce9f
commit
2ac09c2694
@ -711,16 +711,11 @@ uint32_t uart_get_source_freq(pyb_uart_obj_t *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t uart_get_baudrate(pyb_uart_obj_t *self) {
|
uint32_t uart_get_baudrate(pyb_uart_obj_t *self) {
|
||||||
// This formula assumes UART_OVERSAMPLING_16
|
return LL_USART_GetBaudRate(self->uartx, uart_get_source_freq(self),
|
||||||
uint32_t source_freq = uart_get_source_freq(self);
|
#if defined(STM32H7) || defined(STM32WB)
|
||||||
#if defined(LPUART1)
|
self->uartx->PRESC,
|
||||||
if (self->uart_id == PYB_LPUART_1) {
|
|
||||||
return source_freq / (self->uartx->BRR >> 8);
|
|
||||||
} else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
LL_USART_OVERSAMPLING_16);
|
||||||
return source_freq / self->uartx->BRR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uart_set_baudrate(pyb_uart_obj_t *self, uint32_t baudrate) {
|
void uart_set_baudrate(pyb_uart_obj_t *self, uint32_t baudrate) {
|
||||||
|
Loading…
Reference in New Issue
Block a user