From 90317b0adba5789ca90de040d6a18012f500ba61 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 10 Dec 2024 18:06:24 +0800 Subject: [PATCH] wait for i2c commands to propagate before moving on --- libs/cramium-hal/src/udma/i2c.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/cramium-hal/src/udma/i2c.rs b/libs/cramium-hal/src/udma/i2c.rs index da9abc3ef..0b0a436f8 100644 --- a/libs/cramium-hal/src/udma/i2c.rs +++ b/libs/cramium-hal/src/udma/i2c.rs @@ -360,6 +360,8 @@ impl<'a> I2c<'a> { self.udma_enqueue(Bank::Tx, &self.tx_buf_phys[..data.len()], CFG_EN); self.udma_enqueue(Bank::Custom, &self.cmd_buf_phys[..self.seq_len], CFG_EN); } + // wait for the commands to propagate before returning + while !self.busy() {} self.pending = I2cPending::Write(data.len()); Ok(data.len()) } @@ -418,6 +420,8 @@ impl<'a> I2c<'a> { 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); } + // wait for the commands to propagate before returning + while !self.busy() {} self.pending = I2cPending::Read(len); Ok(len) }