[HAL][UART] Avoid ORE flag to be cleared by a transmit process in polling mode
diff --git a/Src/stm32l1xx_hal_uart.c b/Src/stm32l1xx_hal_uart.c
index 97e42a6..2429b38 100644
--- a/Src/stm32l1xx_hal_uart.c
+++ b/Src/stm32l1xx_hal_uart.c
@@ -1167,7 +1167,7 @@
       {
         huart->gState = HAL_UART_STATE_READY;
 
-		return HAL_TIMEOUT;
+        return HAL_TIMEOUT;
       }
       if (pdata8bits == NULL)
       {
@@ -1186,7 +1186,7 @@
     {
       huart->gState = HAL_UART_STATE_READY;
 
-	  return HAL_TIMEOUT;
+      return HAL_TIMEOUT;
     }
 
     /* At end of Tx process, restore huart->gState to Ready */
@@ -1253,9 +1253,9 @@
     {
       if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
       {
-		huart->RxState = HAL_UART_STATE_READY;
+        huart->RxState = HAL_UART_STATE_READY;
 
-		return HAL_TIMEOUT;
+        return HAL_TIMEOUT;
       }
       if (pdata8bits == NULL)
       {
@@ -3191,7 +3191,7 @@
         return HAL_TIMEOUT;
       }
 
-      if (READ_BIT(huart->Instance->CR1, USART_CR1_RE) != 0U)
+      if ((READ_BIT(huart->Instance->CR1, USART_CR1_RE) != 0U) && (Flag != UART_FLAG_TXE) && (Flag != UART_FLAG_TC))
       {
         if (__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE) == SET)
         {