Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F4_HAL/uart: UART9 and UART10 should be on APB2. #8

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -2486,7 +2486,17 @@ static void UART_SetConfig(UART_HandleTypeDef *huart)
if(huart->Init.OverSampling == UART_OVERSAMPLING_8)
{
/*-------------------------- USART BRR Configuration ---------------------*/
#if defined(USART6)
#if defined(UART10)
if((huart->Instance == USART1) || (huart->Instance == USART6) || (huart->Instance == UART9) || (huart->Instance == UART10))
{
huart->Instance->BRR = UART_BRR_SAMPLING8(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
}
#elif defined(UART9)
if((huart->Instance == USART1) || (huart->Instance == USART6) || (huart->Instance == UART9))
{
huart->Instance->BRR = UART_BRR_SAMPLING8(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
}
#elif defined(USART6)
if((huart->Instance == USART1) || (huart->Instance == USART6))
{
huart->Instance->BRR = UART_BRR_SAMPLING8(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
Expand All @@ -2496,7 +2506,7 @@ static void UART_SetConfig(UART_HandleTypeDef *huart)
{
huart->Instance->BRR = UART_BRR_SAMPLING8(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
}
#endif /* USART6 */
#endif /* USART6 UART9 UART10 */
else
{
huart->Instance->BRR = UART_BRR_SAMPLING8(HAL_RCC_GetPCLK1Freq(), huart->Init.BaudRate);
Expand All @@ -2505,7 +2515,17 @@ static void UART_SetConfig(UART_HandleTypeDef *huart)
else
{
/*-------------------------- USART BRR Configuration ---------------------*/
#if defined(USART6)
#if defined(UART10)
if((huart->Instance == USART1) || (huart->Instance == USART6) || (huart->Instance == UART9) || (huart->Instance == UART10))
{
huart->Instance->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
}
#elif defined(UART9)
if((huart->Instance == USART1) || (huart->Instance == USART6) || (huart->Instance == UART9))
{
huart->Instance->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
}
#elif defined(USART6)
if((huart->Instance == USART1) || (huart->Instance == USART6))
{
huart->Instance->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
Expand All @@ -2515,7 +2535,7 @@ static void UART_SetConfig(UART_HandleTypeDef *huart)
{
huart->Instance->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate);
}
#endif /* USART6 */
#endif /* USART6 UART9 UART10 */
else
{
huart->Instance->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK1Freq(), huart->Init.BaudRate);
Expand Down