Interface

Trait Interface 

Source
pub trait Interface {
    type Error;

    // Required methods
    fn write(&mut self, addr: u8, value: u8) -> Result<(), Self::Error>;
    fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error>;
}
Expand description

Interface Trait. SpiInterface and I2cInterface implement this.

Required Associated Types§

Required Methods§

Source

fn write(&mut self, addr: u8, value: u8) -> Result<(), Self::Error>

Writes a byte to a sensor’s specified register address.

§Arguments
  • addr - register address
  • value - value to write
Source

fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error>

Reads multiple bytes from a sensor’s specified register address.

§Arguments
  • addr - register address
  • buffer - buffer to store read data

Implementors§

Source§

impl<I2C, CommE> Interface for I2cInterface<I2C>
where I2C: WriteRead<Error = CommE> + Write<Error = CommE>,

Implementation of Interface

Source§

type Error = Error<CommE>