@@ -67,7 +67,7 @@ static void init_uart(serial_t *obj)
67
67
UartHandle .Init .HwFlowCtl = SERIAL_OBJ (hw_flow_ctl );
68
68
#else
69
69
UartHandle .Init .HwFlowCtl = UART_HWCONTROL_NONE ;
70
- #endif
70
+ #endif
71
71
UartHandle .Init .OverSampling = UART_OVERSAMPLING_16 ;
72
72
UartHandle .Init .OneBitSampling = UART_ONE_BIT_SAMPLE_ENABLE ;
73
73
@@ -79,6 +79,9 @@ static void init_uart(serial_t *obj)
79
79
UartHandle .Init .Mode = UART_MODE_TX_RX ;
80
80
}
81
81
82
+ // Fix because HAL_RCC_GetHCLKFreq() don't update anymore SystemCoreClock
83
+ SystemCoreClockUpdate ();
84
+
82
85
if (HAL_UART_Init (& UartHandle ) != HAL_OK ) {
83
86
error ("Cannot initialize UART\n" );
84
87
}
@@ -250,17 +253,17 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
250
253
*/
251
254
void serial_set_flow_control (serial_t * obj , FlowControl type , PinName rxflow , PinName txflow )
252
255
{
253
-
256
+
254
257
// Determine the UART to use (UART_1, UART_2, ...)
255
258
UARTName uart_rts = (UARTName )pinmap_peripheral (rxflow , PinMap_UART_RTS );
256
259
UARTName uart_cts = (UARTName )pinmap_peripheral (txflow , PinMap_UART_CTS );
257
-
260
+
258
261
// Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object
259
262
SERIAL_OBJ (uart ) = (UARTName )pinmap_merge (uart_cts , uart_rts );
260
-
263
+
261
264
MBED_ASSERT (SERIAL_OBJ (uart ) != (UARTName )NC );
262
265
UartHandle .Instance = (USART_TypeDef * )(SERIAL_OBJ (uart ));
263
-
266
+
264
267
if (type == FlowControlNone ) {
265
268
// Disable hardware flow control
266
269
SERIAL_OBJ (hw_flow_ctl ) = UART_HWCONTROL_NONE ;
0 commit comments