@@ -457,28 +457,30 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
457457 if (baudrate <= 9600 ) {
458458 /* Enable the clock if not already set by user */
459459 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+ }
463464#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+ }
467468#endif
468469#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+ }
472473#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 ) {
475479 return ;
476480 }
477- } else if (HAL_UART_Init (huart ) == HAL_OK ) {
478- return ;
479481 }
480482 }
481- if (__HAL_RCC_GET_FLAG ( RCC_FLAG_HSIRDY )) {
483+ if (LL_RCC_HSI_IsReady ( )) {
482484 if (obj -> uart == LPUART1 ) {
483485 __HAL_RCC_LPUART1_CONFIG (RCC_LPUART1CLKSOURCE_HSI );
484486 }
0 commit comments