diff --git a/stm32h7/spi/SpiComIF.cpp b/stm32h7/spi/SpiComIF.cpp index 5b1b7af..26fb7e7 100644 --- a/stm32h7/spi/SpiComIF.cpp +++ b/stm32h7/spi/SpiComIF.cpp @@ -232,6 +232,12 @@ ReturnValue_t SpiComIF::handleIrqSendOperation(uint8_t *recvPtr, SpiCookie *spiC // yet another HAL driver which is not const-correct.. HAL_StatusTypeDef status = HAL_OK; if(transferMode == spi::TransferModes::DMA) { + if(cacheMaintenanceOnTxBuffer) { + /* Clean D-cache. Make sure the address is 32-byte aligned and add 32-bytes to length, + in case it overlaps cacheline */ + SCB_CleanDCache_by_Addr((uint32_t*)(((uint32_t) sendData ) & ~(uint32_t)0x1F), + sendLen + 32); + } status = HAL_SPI_TransmitReceive_DMA(spiHandle, const_cast(sendData), currentRecvPtr, sendLen); }