diff options
| author | Caleb Jamison <[email protected]> | 2023-05-22 21:26:03 -0400 |
|---|---|---|
| committer | Caleb Jamison <[email protected]> | 2023-05-22 21:26:03 -0400 |
| commit | 49eaf000b89aab5b1f7fa524c06c4c37a1aec63d (patch) | |
| tree | 65bc8d62c38af702d64148887d16f647fc3027e9 /embassy-embedded-hal/src | |
| parent | ab7d129e152a9450b2a6445397365bcb3a3ce183 (diff) | |
Add i2c transaction
Diffstat (limited to 'embassy-embedded-hal/src')
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/asynch/i2c.rs | 19 |
1 files 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 | |||
| 84 | address: u8, | 84 | address: u8, |
| 85 | operations: &mut [embedded_hal_async::i2c::Operation<'_>], | 85 | operations: &mut [embedded_hal_async::i2c::Operation<'_>], |
| 86 | ) -> Result<(), I2cDeviceError<BUS::Error>> { | 86 | ) -> Result<(), I2cDeviceError<BUS::Error>> { |
| 87 | let _ = address; | 87 | defmt::info!("lock"); |
| 88 | let _ = operations; | 88 | let mut bus = self.bus.lock().await; |
| 89 | todo!() | 89 | defmt::info!("transact"); |
| 90 | bus.transaction(address, operations) | ||
| 91 | .await | ||
| 92 | .map_err(I2cDeviceError::I2c)?; | ||
| 93 | Ok(()) | ||
| 90 | } | 94 | } |
| 91 | } | 95 | } |
| 92 | 96 | ||
| @@ -150,8 +154,11 @@ where | |||
| 150 | } | 154 | } |
| 151 | 155 | ||
| 152 | async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> { | 156 | async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> { |
| 153 | let _ = address; | 157 | let mut bus = self.bus.lock().await; |
| 154 | let _ = operations; | 158 | bus.set_config(&self.config); |
| 155 | todo!() | 159 | bus.transaction(address, operations) |
| 160 | .await | ||
| 161 | .map_err(I2cDeviceError::I2c)?; | ||
| 162 | Ok(()) | ||
| 156 | } | 163 | } |
| 157 | } | 164 | } |
