diff options
Diffstat (limited to 'embassy-embedded-hal/src/shared_bus/asynch/i2c.rs')
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/asynch/i2c.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index 87e8a4304..1053d3849 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs | |||
| @@ -125,14 +125,14 @@ where | |||
| 125 | { | 125 | { |
| 126 | async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), I2cDeviceError<BUS::Error>> { | 126 | async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), I2cDeviceError<BUS::Error>> { |
| 127 | let mut bus = self.bus.lock().await; | 127 | let mut bus = self.bus.lock().await; |
| 128 | bus.set_config(&self.config); | 128 | bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?; |
| 129 | bus.read(address, buffer).await.map_err(I2cDeviceError::I2c)?; | 129 | bus.read(address, buffer).await.map_err(I2cDeviceError::I2c)?; |
| 130 | Ok(()) | 130 | Ok(()) |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | async fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), I2cDeviceError<BUS::Error>> { | 133 | async fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), I2cDeviceError<BUS::Error>> { |
| 134 | let mut bus = self.bus.lock().await; | 134 | let mut bus = self.bus.lock().await; |
| 135 | bus.set_config(&self.config); | 135 | bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?; |
| 136 | bus.write(address, bytes).await.map_err(I2cDeviceError::I2c)?; | 136 | bus.write(address, bytes).await.map_err(I2cDeviceError::I2c)?; |
| 137 | Ok(()) | 137 | Ok(()) |
| 138 | } | 138 | } |
| @@ -144,7 +144,7 @@ where | |||
| 144 | rd_buffer: &mut [u8], | 144 | rd_buffer: &mut [u8], |
| 145 | ) -> Result<(), I2cDeviceError<BUS::Error>> { | 145 | ) -> Result<(), I2cDeviceError<BUS::Error>> { |
| 146 | let mut bus = self.bus.lock().await; | 146 | let mut bus = self.bus.lock().await; |
| 147 | bus.set_config(&self.config); | 147 | bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?; |
| 148 | bus.write_read(address, wr_buffer, rd_buffer) | 148 | bus.write_read(address, wr_buffer, rd_buffer) |
| 149 | .await | 149 | .await |
| 150 | .map_err(I2cDeviceError::I2c)?; | 150 | .map_err(I2cDeviceError::I2c)?; |
| @@ -153,7 +153,7 @@ where | |||
| 153 | 153 | ||
| 154 | async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> { | 154 | async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> { |
| 155 | let mut bus = self.bus.lock().await; | 155 | let mut bus = self.bus.lock().await; |
| 156 | bus.set_config(&self.config); | 156 | bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?; |
| 157 | bus.transaction(address, operations) | 157 | bus.transaction(address, operations) |
| 158 | .await | 158 | .await |
| 159 | .map_err(I2cDeviceError::I2c)?; | 159 | .map_err(I2cDeviceError::I2c)?; |
