Skip to content

Commit 900fcfe

Browse files
authored
Merge pull request #2355 from evark/stm32f1-serial
STM32F1 serial_api initialize failure message
2 parents f52111d + b27a5aa commit 900fcfe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32F1/serial_api.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "cmsis.h"
3636
#include "pinmap.h"
37+
#include "mbed_error.h"
3738
#include <string.h>
3839
#include "PeripheralPins.h"
3940

@@ -67,7 +68,12 @@ static void init_uart(serial_t *obj)
6768
UartHandle.Init.Mode = UART_MODE_TX_RX;
6869
}
6970

70-
HAL_UART_Init(&UartHandle);
71+
// Fix because HAL_RCC_GetHCLKFreq() don't update anymore SystemCoreClock
72+
SystemCoreClockUpdate();
73+
74+
if (HAL_UART_Init(&UartHandle) != HAL_OK) {
75+
error("Cannot initialize UART\n");
76+
}
7177

7278
}
7379

0 commit comments

Comments
 (0)