Skip to content

Commit

Permalink
Merge pull request #126 from CBJamo/master
Browse files Browse the repository at this point in the history
Implement transaction for i2c
  • Loading branch information
golemparts authored Sep 28, 2023
2 parents b39d066 + 2eaa80a commit 082cb46
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/i2c/hal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,22 @@ impl I2cHal for I2c {

fn transaction(
&mut self,
_address: u8,
_operations: &mut [I2cOperation],
address: u8,
operations: &mut [I2cOperation],
) -> Result<(), Self::Error> {
unimplemented!()
self.set_slave_address(u16::from(address))?;
for op in operations {
match op {
I2cOperation::Read(buff) => {
I2c::read(self, buff)?;
}
I2cOperation::Write(buff) => {
I2c::write(self, buff)?;
}
}
}

Ok(())
}

fn transaction_iter<'a, O>(&mut self, address: u8, operations: O) -> Result<(), Self::Error>
Expand Down

0 comments on commit 082cb46

Please sign in to comment.