diff --git a/src/i2c.rs b/src/i2c.rs index f8452d972bb..dceb064605d 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -384,6 +384,28 @@ impl<'d> embedded_hal_0_2::blocking::i2c::WriteRead for I2cDriver<'d> { } } +impl<'d> embedded_hal_0_2::blocking::i2c::Transactional for I2cDriver<'d> { + type Error = I2cError; + + fn exec<'a>( + &mut self, + address: u8, + operations: &mut [embedded_hal_0_2::blocking::i2c::Operation<'_>], + ) -> Result<(), Self::Error> { + for operation in operations { + match operation { + embedded_hal_0_2::blocking::i2c::Operation::Write(wr) => { + self.write(address, wr, BLOCK)?; + } + embedded_hal_0_2::blocking::i2c::Operation::Read(rd) => { + self.read(address, rd, BLOCK)?; + } + } + } + Ok(()) + } +} + impl<'d> embedded_hal::i2c::ErrorType for I2cDriver<'d> { type Error = I2cError; }