pub struct I2cdev { /* private fields */ }
Expand description

Newtype around i2cdev::linux::LinuxI2CDevice that implements the embedded-hal traits

Implementations§

source§

impl I2cdev

source

pub fn new<P>(path: P) -> Result<Self, LinuxI2CError>
where P: AsRef<Path>,

Methods from Deref<Target = LinuxI2CDevice>§

source

pub fn set_slave_address( &mut self, slave_address: u16 ) -> Result<(), LinuxI2CError>

Set the slave address for this device

Typically the address is expected to be 7-bits but 10-bit addresses may be supported by the kernel driver in some cases. Little validation is done in Rust as the kernel is good at making sure things are valid.

Note that if you have created a device using I2Device::new(...) it is not necesasry to call this method (it is done internally). Calling this method is only necessary if you need to change the slave device and you do not want to create a new device.

source

pub fn set_smbus_pec(&mut self, enable: bool) -> Result<(), LinuxI2CError>

Enable/Disable PEC support for this device

Used only for SMBus transactions. This request only has an effect if the the adapter has I2C_FUNC_SMBUS_PEC; it is still safe if not, it just doesn’t have any effect.

Trait Implementations§

source§

impl Deref for I2cdev

§

type Target = LinuxI2CDevice

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for I2cdev

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl ErrorType for I2cdev

§

type Error = I2CError

Error type
source§

impl I2c<u16> for I2cdev

source§

fn transaction( &mut self, address: u16, operations: &mut [I2cOperation<'_>] ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more
source§

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

Reads enough bytes from slave with address to fill read. Read more
source§

fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address. Read more
source§

fn write_read( &mut self, address: A, write: &[u8], read: &mut [u8] ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
source§

impl I2c for I2cdev

source§

fn transaction( &mut self, address: u8, operations: &mut [I2cOperation<'_>] ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more
source§

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

Reads enough bytes from slave with address to fill read. Read more
source§

fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address. Read more
source§

fn write_read( &mut self, address: A, write: &[u8], read: &mut [u8] ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.