Skip to content

Commit

Permalink
Added explicit embedded_hal::i2c::I2c import
Browse files Browse the repository at this point in the history
  • Loading branch information
asasine committed May 26, 2024
1 parent 5f7fd16 commit 6672a97
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/eh1/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
use eh1 as embedded_hal;
use embedded_hal::{
i2c,
i2c::{ErrorKind, ErrorType},
i2c::{ErrorKind, ErrorType, I2c},
};

use crate::common::Generic;
Expand Down Expand Up @@ -183,7 +183,7 @@ impl ErrorType for Mock {
type Error = ErrorKind;
}

impl i2c::I2c for Mock {
impl I2c for Mock {
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
let e = self
.next()
Expand Down Expand Up @@ -301,11 +301,11 @@ impl i2c::I2c for Mock {
#[cfg(feature = "embedded-hal-async")]
impl embedded_hal_async::i2c::I2c for Mock {
async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
eh1::i2c::I2c::read(self, address, buffer)
I2c::read(self, address, buffer)
}

async fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error> {
eh1::i2c::I2c::write(self, address, bytes)
I2c::write(self, address, bytes)
}

async fn write_read(
Expand All @@ -314,24 +314,22 @@ impl embedded_hal_async::i2c::I2c for Mock {
bytes: &[u8],
buffer: &mut [u8],
) -> Result<(), Self::Error> {
eh1::i2c::I2c::write_read(self, address, bytes, buffer)
I2c::write_read(self, address, bytes, buffer)
}

async fn transaction<'a>(
&mut self,
address: u8,
operations: &mut [i2c::Operation<'a>],
) -> Result<(), Self::Error> {
eh1::i2c::I2c::transaction(self, address, operations)
I2c::transaction(self, address, operations)
}
}

#[cfg(test)]
mod test {
use std::time::SystemTime;

use embedded_hal::i2c::I2c;

use super::*;

#[test]
Expand Down

0 comments on commit 6672a97

Please sign in to comment.