Merge pull request #15286 from pilotak/master

STM32G4: Fix serial port at low speed baud
pull/15287/head
Martin Kojtal 2022-05-13 14:47:44 +02:00 committed by GitHub
commit 1ab98dec9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -629,8 +629,12 @@ HAL_StatusTypeDef init_uart(serial_t *obj)
#if defined(UART_ONE_BIT_SAMPLE_DISABLE) // F0/F3/F7/G0/H7/L0/L4/L5/WB
huart->Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
#endif
#if defined(UART_PRESCALER_DIV1) // G0/H7/L4/L5/WB
huart->Init.ClockPrescaler = UART_PRESCALER_DIV1;
#if defined(UART_PRESCALER_DIV1) // G0/G4/H7/L4/L5/U5/WB/WL
if (obj_s->baudrate < 4800) {
huart->Init.ClockPrescaler = UART_PRESCALER_DIV16;
} else {
huart->Init.ClockPrescaler = UART_PRESCALER_DIV1;
}
#endif
#if defined(UART_ADVFEATURE_NO_INIT) // F0/F3/F7/G0/H7/L0/L4//5/WB
huart->AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;