[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/stm32l4xx_hal_spi.c b/Src/stm32l4xx_hal_spi.c
index 49b328d..deae017 100644
--- a/Src/stm32l4xx_hal_spi.c
+++ b/Src/stm32l4xx_hal_spi.c
@@ -1550,6 +1550,14 @@
     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);