[HAL][SPI] Fix driver to don't update state in case of error (HAL_SPI_STATE_READY will be set only in case of HAL_TIMEOUT)
diff --git a/Src/stm32l5xx_hal_spi.c b/Src/stm32l5xx_hal_spi.c
index b027095..0f2c8b7 100644
--- a/Src/stm32l5xx_hal_spi.c
+++ b/Src/stm32l5xx_hal_spi.c
@@ -1550,7 +1550,15 @@
     hspi->ErrorCode = HAL_SPI_ERROR_FLAG;
   }
 
-
+  if (hspi->ErrorCode != HAL_SPI_ERROR_NONE)
+  {
+    errorcode = HAL_ERROR;
+  }
+  else
+  {
+    hspi->State = HAL_SPI_STATE_READY;
+  }
+  
 error :
   __HAL_UNLOCK(hspi);
   return errorcode;