[HAL][SMBUS] Update SMBUS_ITErrorHandler to flush TXDR just in case of error
diff --git a/Src/stm32wlxx_hal_smbus.c b/Src/stm32wlxx_hal_smbus.c
index c572fcc..b5a9a1f 100644
--- a/Src/stm32wlxx_hal_smbus.c
+++ b/Src/stm32wlxx_hal_smbus.c
@@ -2605,8 +2605,11 @@
     __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_PECERR);
   }
 
-  /* Flush TX register */
-  SMBUS_Flush_TXDR(hsmbus);
+  if (hsmbus->ErrorCode != HAL_SMBUS_ERROR_NONE)
+  {
+    /* Flush TX register */
+    SMBUS_Flush_TXDR(hsmbus);
+  }
 
   /* Store current volatile hsmbus->ErrorCode, misra rule */
   tmperror = hsmbus->ErrorCode;