FuriHal: fix LPUART crash (#820)

This commit is contained in:
あく 2021-11-15 23:36:57 +03:00 committed by GitHub
parent 1571d4ec54
commit 7f814b5197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -105,7 +105,7 @@ void furi_hal_uart_set_br(FuriHalUartId ch, uint32_t baud) {
// Wait for transfer complete flag // Wait for transfer complete flag
while (!LL_LPUART_IsActiveFlag_TC(LPUART1)); while (!LL_LPUART_IsActiveFlag_TC(LPUART1));
LL_LPUART_Disable(LPUART1); LL_LPUART_Disable(LPUART1);
uint32_t uartclk = LL_RCC_GetLPUARTClockFreq(LL_RCC_GetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1)); uint32_t uartclk = LL_RCC_GetLPUARTClockFreq(LL_RCC_LPUART1_CLKSOURCE);
if (uartclk/baud > 4095) { if (uartclk/baud > 4095) {
LL_LPUART_SetPrescaler(LPUART1, LL_LPUART_PRESCALER_DIV32); LL_LPUART_SetPrescaler(LPUART1, LL_LPUART_PRESCALER_DIV32);
LL_LPUART_SetBaudRate(LPUART1, uartclk, LL_LPUART_PRESCALER_DIV32, baud); LL_LPUART_SetBaudRate(LPUART1, uartclk, LL_LPUART_PRESCALER_DIV32, baud);

View File

@ -105,7 +105,7 @@ void furi_hal_uart_set_br(FuriHalUartId ch, uint32_t baud) {
// Wait for transfer complete flag // Wait for transfer complete flag
while (!LL_LPUART_IsActiveFlag_TC(LPUART1)); while (!LL_LPUART_IsActiveFlag_TC(LPUART1));
LL_LPUART_Disable(LPUART1); LL_LPUART_Disable(LPUART1);
uint32_t uartclk = LL_RCC_GetLPUARTClockFreq(LL_RCC_GetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1)); uint32_t uartclk = LL_RCC_GetLPUARTClockFreq(LL_RCC_LPUART1_CLKSOURCE);
if (uartclk/baud > 4095) { if (uartclk/baud > 4095) {
LL_LPUART_SetPrescaler(LPUART1, LL_LPUART_PRESCALER_DIV32); LL_LPUART_SetPrescaler(LPUART1, LL_LPUART_PRESCALER_DIV32);
LL_LPUART_SetBaudRate(LPUART1, uartclk, LL_LPUART_PRESCALER_DIV32, baud); LL_LPUART_SetBaudRate(LPUART1, uartclk, LL_LPUART_PRESCALER_DIV32, baud);