From a3ef4786886e726a5e92b6add24a7d5a9fcf7c25 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 10 Dec 2024 17:10:24 +0800 Subject: [PATCH] more mpw vs nto differences --- libs/cramium-hal/src/udma/i2c.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/cramium-hal/src/udma/i2c.rs b/libs/cramium-hal/src/udma/i2c.rs index ebd514e6c..da9abc3ef 100644 --- a/libs/cramium-hal/src/udma/i2c.rs +++ b/libs/cramium-hal/src/udma/i2c.rs @@ -286,7 +286,10 @@ impl<'a> I2c<'a> { let ret = match self.pending.take() { I2cPending::Read(len) => { if let Some(buf) = rx_buf { + #[cfg(feature = "mpw")] buf[..len].copy_from_slice(&self.rx_buf[3..3 + len]); + #[cfg(not(feature = "mpw"))] + buf[..len].copy_from_slice(&self.rx_buf[..len]); Ok(len) } else { // the pending transaction was a read, but the user did not call us @@ -408,8 +411,11 @@ impl<'a> I2c<'a> { // safety: this is safe because the cmd_buf_phys() slice is passed to a function that only // uses it as a base/bounds reference and it will not actually access the data. unsafe { - // the extra 3 are dummy bytes that were received while the address was being set up + // the extra 3 are dummy bytes that were received while the address was being set up - MPW bug + #[cfg(feature = "mpw")] self.udma_enqueue(Bank::Rx, &self.rx_buf_phys[..len + 3], CFG_EN); + #[cfg(not(feature = "mpw"))] + self.udma_enqueue(Bank::Rx, &self.rx_buf_phys[..len], CFG_EN); self.udma_enqueue(Bank::Custom, &self.cmd_buf_phys[..self.seq_len], CFG_EN); } self.pending = I2cPending::Read(len);