@@ -648,7 +648,7 @@ static void spi_stm32_iodev_msg_start(const struct device *dev, struct spi_confi
648648 const uint8_t * tx_buf , uint8_t * rx_buf , uint32_t buf_len )
649649{
650650 struct spi_stm32_data * data = dev -> data ;
651- uint32_t size = buf_len / ( SPI_WORD_SIZE_GET ( config -> operation ) / BITS_PER_BYTE );
651+ uint32_t size = buf_len / bits2bytes ( config -> operation );
652652
653653 const struct spi_buf current_tx = {.buf = NULL , .len = size };
654654 const struct spi_buf current_rx = {.buf = NULL , .len = size };
@@ -674,6 +674,10 @@ static void spi_stm32_iodev_msg_start(const struct device *dev, struct spi_confi
674674 SPI_TypeDef * spi = cfg -> spi ;
675675
676676 if (cfg -> fifo_enabled && SPI_OP_MODE_GET (config -> operation ) == SPI_OP_MODE_MASTER ) {
677+ if (LL_SPI_IsEnabled (spi )) {
678+ /* SPI needs to be disabled to set the transfer size */
679+ ll_func_disable_spi (spi );
680+ }
677681 LL_SPI_SetTransferSize (spi , size );
678682 }
679683#endif /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_spi) */
@@ -773,6 +777,12 @@ static void spi_stm32_complete(const struct device *dev, int status)
773777
774778#ifdef CONFIG_SPI_RTIO
775779 if (data -> rtio_ctx -> txn_head != NULL ) {
780+ #if DT_HAS_COMPAT_STATUS_OKAY (st_stm32h7_spi )
781+ if (cfg -> fifo_enabled ) {
782+ LL_SPI_ClearFlag_TXTF (spi );
783+ LL_SPI_ClearFlag_OVR (spi );
784+ }
785+ #endif /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_spi) */
776786 spi_stm32_iodev_complete (dev , status );
777787 return ;
778788 }
0 commit comments