From b6cc800a702d75b045631c4d8ed68e81aabd8112 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Tue, 16 Apr 2024 15:18:04 +0100 Subject: [PATCH] Add more compiler fences. --- nrf-hal-common/src/twim.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nrf-hal-common/src/twim.rs b/nrf-hal-common/src/twim.rs index 2071684d..d7eaa827 100644 --- a/nrf-hal-common/src/twim.rs +++ b/nrf-hal-common/src/twim.rs @@ -399,6 +399,7 @@ where } fn write_part(&mut self, buffer: &[u8], final_operation: bool) -> Result<(), Error> { + compiler_fence(SeqCst); unsafe { self.set_tx_buffer(buffer)? }; // Set appropriate lasttx shortcut. @@ -413,6 +414,7 @@ where self.0.tasks_resume.write(|w| unsafe { w.bits(1) }); self.wait(); + compiler_fence(SeqCst); self.read_errorsrc()?; if self.0.txd.amount.read().bits() != buffer.len() as u32 { return Err(Error::Transmit); @@ -435,6 +437,7 @@ where self.0.tasks_resume.write(|w| unsafe { w.bits(1) }); self.wait(); + compiler_fence(SeqCst); self.read_errorsrc()?; if self.0.rxd.amount.read().bits() != buffer.len() as u32 { return Err(Error::Receive);