Skip to content

Commit 2f29b9a

Browse files
committed
[STM32L4XX] Fix deinit of SystemCoreClock on ARM toolchain
1 parent 32bca79 commit 2f29b9a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32L4/serial_api.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void init_uart(serial_t *obj)
6767
UartHandle.Init.HwFlowCtl = SERIAL_OBJ(hw_flow_ctl);
6868
#else
6969
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
70-
#endif
70+
#endif
7171
UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
7272
UartHandle.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_ENABLE;
7373

@@ -79,6 +79,9 @@ static void init_uart(serial_t *obj)
7979
UartHandle.Init.Mode = UART_MODE_TX_RX;
8080
}
8181

82+
// Fix because HAL_RCC_GetHCLKFreq() don't update anymore SystemCoreClock
83+
SystemCoreClockUpdate();
84+
8285
if (HAL_UART_Init(&UartHandle) != HAL_OK) {
8386
error("Cannot initialize UART\n");
8487
}
@@ -250,17 +253,17 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
250253
*/
251254
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
252255
{
253-
256+
254257
// Determine the UART to use (UART_1, UART_2, ...)
255258
UARTName uart_rts = (UARTName)pinmap_peripheral(rxflow, PinMap_UART_RTS);
256259
UARTName uart_cts = (UARTName)pinmap_peripheral(txflow, PinMap_UART_CTS);
257-
260+
258261
// Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object
259262
SERIAL_OBJ(uart) = (UARTName)pinmap_merge(uart_cts, uart_rts);
260-
263+
261264
MBED_ASSERT(SERIAL_OBJ(uart) != (UARTName)NC);
262265
UartHandle.Instance = (USART_TypeDef *)(SERIAL_OBJ(uart));
263-
266+
264267
if(type == FlowControlNone) {
265268
// Disable hardware flow control
266269
SERIAL_OBJ(hw_flow_ctl) = UART_HWCONTROL_NONE;

0 commit comments

Comments
 (0)