diff options
| -rw-r--r-- | embassy-rp/src/i2c.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs index 40e85c66f..cd5364393 100644 --- a/embassy-rp/src/i2c.rs +++ b/embassy-rp/src/i2c.rs | |||
| @@ -617,6 +617,28 @@ mod eh02 { | |||
| 617 | self.blocking_write_read(address, bytes, buffer) | 617 | self.blocking_write_read(address, bytes, buffer) |
| 618 | } | 618 | } |
| 619 | } | 619 | } |
| 620 | |||
| 621 | impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Transactional for I2c<'d, T, M> { | ||
| 622 | type Error = Error; | ||
| 623 | |||
| 624 | fn exec( | ||
| 625 | &mut self, | ||
| 626 | address: u8, | ||
| 627 | operations: &mut [embedded_hal_02::blocking::i2c::Operation<'_>], | ||
| 628 | ) -> Result<(), Self::Error> { | ||
| 629 | Self::setup(address.into())?; | ||
| 630 | for i in 0..operations.len() { | ||
| 631 | let last = i == operations.len() - 1; | ||
| 632 | match &mut operations[i] { | ||
| 633 | embedded_hal_02::blocking::i2c::Operation::Read(buf) => { | ||
| 634 | self.read_blocking_internal(buf, false, last)? | ||
| 635 | } | ||
| 636 | embedded_hal_02::blocking::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?, | ||
| 637 | } | ||
| 638 | } | ||
| 639 | Ok(()) | ||
| 640 | } | ||
| 641 | } | ||
| 620 | } | 642 | } |
| 621 | 643 | ||
| 622 | #[cfg(feature = "unstable-traits")] | 644 | #[cfg(feature = "unstable-traits")] |
