@@ -457,28 +457,30 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
457
457
if (baudrate <= 9600 ) {
458
458
/* Enable the clock if not already set by user */
459
459
enableClock (LSE_CLOCK );
460
- if (obj -> uart == LPUART1 ) {
461
- __HAL_RCC_LPUART1_CONFIG (RCC_LPUART1CLKSOURCE_LSE );
462
- }
460
+ if (LL_RCC_LSE_IsReady ()) {
461
+ if (obj -> uart == LPUART1 ) {
462
+ __HAL_RCC_LPUART1_CONFIG (RCC_LPUART1CLKSOURCE_LSE );
463
+ }
463
464
#if defined(LPUART2_BASE )
464
- if (obj -> uart == LPUART2 ) {
465
- __HAL_RCC_LPUART2_CONFIG (RCC_LPUART2CLKSOURCE_LSE );
466
- }
465
+ if (obj -> uart == LPUART2 ) {
466
+ __HAL_RCC_LPUART2_CONFIG (RCC_LPUART2CLKSOURCE_LSE );
467
+ }
467
468
#endif
468
469
#if defined(LPUART3_BASE )
469
- if (obj -> uart == LPUART3 ) {
470
- __HAL_RCC_LPUART3_CONFIG (RCC_LPUART3CLKSOURCE_LSE );
471
- }
470
+ if (obj -> uart == LPUART3 ) {
471
+ __HAL_RCC_LPUART3_CONFIG (RCC_LPUART3CLKSOURCE_LSE );
472
+ }
472
473
#endif
473
- if ((uart_rx == NP ) && (uart_rx_swap == NP )) {
474
- if (HAL_HalfDuplex_Init (huart ) == HAL_OK ) {
474
+ if ((uart_rx == NP ) && (uart_rx_swap == NP )) {
475
+ if (HAL_HalfDuplex_Init (huart ) == HAL_OK ) {
476
+ return ;
477
+ }
478
+ } else if (HAL_UART_Init (huart ) == HAL_OK ) {
475
479
return ;
476
480
}
477
- } else if (HAL_UART_Init (huart ) == HAL_OK ) {
478
- return ;
479
481
}
480
482
}
481
- if (__HAL_RCC_GET_FLAG ( RCC_FLAG_HSIRDY )) {
483
+ if (LL_RCC_HSI_IsReady ( )) {
482
484
if (obj -> uart == LPUART1 ) {
483
485
__HAL_RCC_LPUART1_CONFIG (RCC_LPUART1CLKSOURCE_HSI );
484
486
}
0 commit comments