[HAL][SMBUS] Update to fix issue of mismatched data received by master in case of data size to be transmitted by the slave is greater than the data size to be received by the master and add flush on TX register
diff --git a/Src/stm32f4xx_hal_smbus.c b/Src/stm32f4xx_hal_smbus.c
index 25c72fd..58622e4 100644
--- a/Src/stm32f4xx_hal_smbus.c
+++ b/Src/stm32f4xx_hal_smbus.c
@@ -213,6 +213,7 @@
 
 static HAL_StatusTypeDef SMBUS_WaitOnFlagUntilTimeout(SMBUS_HandleTypeDef *hsmbus, uint32_t Flag, FlagStatus Status, uint32_t Timeout, uint32_t Tickstart);
 static void SMBUS_ITError(SMBUS_HandleTypeDef *hsmbus);
+static void SMBUS_Flush_DR(SMBUS_HandleTypeDef *hsmbus);
 
 /* Private functions for SMBUS transfer IRQ handler */
 static HAL_StatusTypeDef SMBUS_MasterTransmit_TXE(SMBUS_HandleTypeDef *hsmbus);
@@ -846,6 +847,18 @@
 #endif /* USE_HAL_SMBUS_REGISTER_CALLBACKS */
 
 /**
+  * @brief  SMBUS data register flush process.
+  * @param  hsmbus SMBUS handle.
+  * @retval None
+  */
+static void SMBUS_Flush_DR(SMBUS_HandleTypeDef *hsmbus)
+{
+  /* Write a dummy data in DR to clear it */
+  hsmbus->Instance->DR = 0x00U;
+
+}
+
+/**
   * @}
   */
 
@@ -1680,6 +1693,13 @@
 
       /* Clear AF flag */
       __HAL_SMBUS_CLEAR_FLAG(hsmbus, SMBUS_FLAG_AF);
+
+      /* Disable EVT, BUF and ERR interrupt */
+      __HAL_SMBUS_DISABLE_IT(hsmbus, SMBUS_IT_EVT | SMBUS_IT_BUF | SMBUS_IT_ERR);
+
+      /* Flush data register */
+      SMBUS_Flush_DR(hsmbus);
+
     }
   }