Struct linux_embedded_hal::I2cdev 
source · [−]pub struct I2cdev { /* private fields */ }Expand description
Newtype around i2cdev::linux::LinuxI2CDevice that implements the embedded-hal traits
Implementations
sourceimpl I2cdev
 
impl I2cdev
sourcepub fn new<P>(path: P) -> Result<Self, LinuxI2CError> where
    P: AsRef<Path>, 
 
pub fn new<P>(path: P) -> Result<Self, LinuxI2CError> where
    P: AsRef<Path>, 
See i2cdev::linux::LinuxI2CDevice::new for details.
Methods from Deref<Target = LinuxI2CDevice>
sourcepub fn set_slave_address(
    &mut self,
    slave_address: u16
) -> Result<(), LinuxI2CError>
 
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.
sourcepub fn set_smbus_pec(&mut self, enable: bool) -> Result<(), LinuxI2CError>
 
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
sourceimpl Deref for I2cdev
 
impl Deref for I2cdev
type Target = LinuxI2CDevice
type Target = LinuxI2CDevice
The resulting type after dereferencing.
sourceimpl I2c<u8> for I2cdev
 
impl I2c<u8> for I2cdev
sourcefn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error>
 
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error>
Reads enough bytes from slave with address to fill buffer Read more
sourcefn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>
 
fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>
Writes bytes to slave with address address Read more
sourcefn write_iter<B>(&mut self, address: u8, bytes: B) -> Result<(), Self::Error> where
    B: IntoIterator<Item = u8>, 
 
fn write_iter<B>(&mut self, address: u8, bytes: B) -> Result<(), Self::Error> where
    B: IntoIterator<Item = u8>, 
Writes bytes to slave with address address Read more
sourcefn write_read(
    &mut self,
    address: u8,
    bytes: &[u8],
    buffer: &mut [u8]
) -> Result<(), Self::Error>
 
fn write_read(
    &mut self,
    address: u8,
    bytes: &[u8],
    buffer: &mut [u8]
) -> Result<(), Self::Error>
Writes bytes to slave with address address and then reads enough bytes to fill buffer in a
single transaction Read more
sourcefn write_iter_read<B>(
    &mut self,
    address: u8,
    bytes: B,
    buffer: &mut [u8]
) -> Result<(), Self::Error> where
    B: IntoIterator<Item = u8>, 
 
fn write_iter_read<B>(
    &mut self,
    address: u8,
    bytes: B,
    buffer: &mut [u8]
) -> Result<(), Self::Error> where
    B: IntoIterator<Item = u8>, 
Writes bytes to slave with address address and then reads enough bytes to fill buffer in a
single transaction Read more
sourcefn transaction(
    &mut self,
    address: u8,
    operations: &mut [I2cOperation<'_>]
) -> Result<(), Self::Error>
 
fn transaction(
    &mut self,
    address: u8,
    operations: &mut [I2cOperation<'_>]
) -> Result<(), Self::Error>
Execute the provided operations on the I2C bus. Read more
sourcefn transaction_iter<'a, O>(
    &mut self,
    address: u8,
    operations: O
) -> Result<(), Self::Error> where
    O: IntoIterator<Item = I2cOperation<'a>>, 
 
fn transaction_iter<'a, O>(
    &mut self,
    address: u8,
    operations: O
) -> Result<(), Self::Error> where
    O: IntoIterator<Item = I2cOperation<'a>>, 
Execute the provided operations on the I2C bus (iterator version). Read more
Auto Trait Implementations
impl RefUnwindSafe for I2cdev
impl Send for I2cdev
impl Sync for I2cdev
impl Unpin for I2cdev
impl UnwindSafe for I2cdev
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more