From 49eaf000b89aab5b1f7fa524c06c4c37a1aec63d Mon Sep 17 00:00:00 2001 From: Caleb Jamison Date: Mon, 22 May 2023 21:26:03 -0400 Subject: [PATCH] Add i2c transaction --- .../src/shared_bus/asynch/i2c.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index 829554045..5d8214db7 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs @@ -84,9 +84,13 @@ where address: u8, operations: &mut [embedded_hal_async::i2c::Operation<'_>], ) -> Result<(), I2cDeviceError> { - let _ = address; - let _ = operations; - todo!() + defmt::info!("lock"); + let mut bus = self.bus.lock().await; + defmt::info!("transact"); + bus.transaction(address, operations) + .await + .map_err(I2cDeviceError::I2c)?; + Ok(()) } } @@ -150,8 +154,11 @@ where } async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> { - let _ = address; - let _ = operations; - todo!() + let mut bus = self.bus.lock().await; + bus.set_config(&self.config); + bus.transaction(address, operations) + .await + .map_err(I2cDeviceError::I2c)?; + Ok(()) } }