Skip to content

Commit b30668f

Browse files
authored
Merge pull request #2 from ABOSTM/SPI_IMPROVEMENT
SPI: Dedicated start/stop transfer for STM32H7 and STM32MP1
2 parents 4e8df33 + 63d541b commit b30668f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

libraries/SPI/src/utility/spi_com.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,10 @@ spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, uint8_t *rx_buffer,
409409
tickstart = HAL_GetTick();
410410

411411
#if defined(STM32H7xx) || defined(STM32MP1xx)
412-
LL_SPI_StartMasterTransfer(_SPI); // start master transfer
412+
/* Start transfer */
413+
LL_SPI_SetTransferSize(_SPI, size);
414+
LL_SPI_Enable(_SPI);
415+
LL_SPI_StartMasterTransfer(_SPI);
413416
#endif
414417

415418
while (size--) {
@@ -434,6 +437,15 @@ spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, uint8_t *rx_buffer,
434437
}
435438
}
436439

440+
#if defined(STM32H7xx) || defined(STM32MP1xx)
441+
/* Close transfer */
442+
/* Clear flags */
443+
LL_SPI_ClearFlag_EOT(_SPI);
444+
LL_SPI_ClearFlag_TXTF(_SPI);
445+
/* Disable SPI peripheral */
446+
LL_SPI_Disable(_SPI);
447+
#endif
448+
437449
return ret;
438450
}
439451

0 commit comments

Comments
 (0)