This commit is contained in:
xoviat 2023-04-28 16:46:32 -05:00 committed by GitHub
parent 2119b8e1ca
commit ba886b45b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -621,12 +621,18 @@ mod eh02 {
impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Transactional for I2c<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Transactional for I2c<'d, T, M> {
type Error = Error; type Error = Error;
fn exec(&mut self, address: u8, operations: &mut [embedded_hal_02::blocking::i2c::Operation<'_>]) -> Result<(), Self::Error> { fn exec(
&mut self,
address: u8,
operations: &mut [embedded_hal_02::blocking::i2c::Operation<'_>],
) -> Result<(), Self::Error> {
Self::setup(address.into())?; Self::setup(address.into())?;
for i in 0..operations.len() { for i in 0..operations.len() {
let last = i == operations.len() - 1; let last = i == operations.len() - 1;
match &mut operations[i] { match &mut operations[i] {
embedded_hal_02::blocking::i2c::Operation::Read(buf) => self.read_blocking_internal(buf, false, last)?, embedded_hal_02::blocking::i2c::Operation::Read(buf) => {
self.read_blocking_internal(buf, false, last)?
}
embedded_hal_02::blocking::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?, embedded_hal_02::blocking::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?,
} }
} }