diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-07-16 16:23:30 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-07-16 16:23:30 +0300 |
commit | ddc241e3bf41bc322f31acd650c2f34da34569c1 (patch) | |
tree | 92e846686ce0d61e30f222dcf0ceb8e16d3da44f | |
parent | b66bd9e3d8aafb83fb137909d61fa14cb8ad40ac (diff) |
Invalidate cache after DMA receive on Duet 3 Mini
-rw-r--r-- | src/Linux/DataTransfer.cpp | 13 | ||||
-rw-r--r-- | src/Networking/ESP8266WiFi/WiFiInterface.cpp | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/Linux/DataTransfer.cpp b/src/Linux/DataTransfer.cpp index 85fd9571..1fdc0501 100644 --- a/src/Linux/DataTransfer.cpp +++ b/src/Linux/DataTransfer.cpp @@ -55,6 +55,7 @@ constexpr IRQn SBC_SPI_IRQn = SbcSpiSercomIRQn; #include "ObjectModel/ObjectModel.h" #include "OutputMemory.h" #include "RepRap.h" +#include <Hardware/Cache.h> #include "RTOSIface/RTOSIface.h" #include <General/IP4String.h> @@ -700,6 +701,9 @@ bool DataTransfer::IsReady() noexcept { case SpiState::ExchangingHeader: { +#if SAME5x + Cache::InvalidateAfterDMAReceive(&rxHeader, sizeof(rxHeader)); +#endif // (1) Exchanged transfer headers const uint32_t headerResponse = *reinterpret_cast<const uint32_t*>(&rxHeader); if (headerResponse == TransferResponse::BadResponse) @@ -742,6 +746,9 @@ bool DataTransfer::IsReady() noexcept case SpiState::ExchangingHeaderResponse: // (2) Exchanged response to transfer header +#if SAME5x + Cache::InvalidateAfterDMAReceive(&rxResponse, sizeof(rxResponse)); +#endif if (rxResponse == TransferResponse::Success && txResponse == TransferResponse::Success) { if (rxHeader.dataLength != 0 || txHeader.dataLength != 0) @@ -777,6 +784,9 @@ bool DataTransfer::IsReady() noexcept case SpiState::ExchangingData: { +#if SAME5x + Cache::InvalidateAfterDMAReceive(&rxBuffer32, sizeof(rxBuffer32)); +#endif // (3) Exchanged data if (rxBuffer32[0] == TransferResponse::BadResponse) { @@ -805,6 +815,9 @@ bool DataTransfer::IsReady() noexcept case SpiState::ExchangingDataResponse: // (4) Exchanged response to data transfer +#if SAME5x + Cache::InvalidateAfterDMAReceive(&rxResponse, sizeof(rxResponse)); +#endif if (rxResponse == TransferResponse::Success && txResponse == TransferResponse::Success) { // Everything OK diff --git a/src/Networking/ESP8266WiFi/WiFiInterface.cpp b/src/Networking/ESP8266WiFi/WiFiInterface.cpp index ab870755..ad2c56de 100644 --- a/src/Networking/ESP8266WiFi/WiFiInterface.cpp +++ b/src/Networking/ESP8266WiFi/WiFiInterface.cpp @@ -16,6 +16,7 @@ #include "WifiFirmwareUploader.h" #include "General/IP4String.h" #include "WiFiSocket.h" +#include <Hardware/Cache.h> static_assert(SsidLength == SsidBufferLength, "SSID lengths in NetworkDefs.h and MessageFormats.h don't match"); @@ -1793,6 +1794,7 @@ int32_t WiFiInterface::SendCommand(NetworkCommand cmd, SocketNumber socketNum, u #else while (!spi_dma_check_rx_complete()) { } // Wait for DMA to complete #endif + Cache::InvalidateAfterDMAReceive(&bufferIn, sizeof(bufferIn)); // Look at the response if (bufferIn.hdr.formatVersion != MyFormatVersion) |