pub struct I2C<const CLK_HZ: u32> { /* private fields */ }
Expand description
Implementation of the I2C interface.
Implementations§
Source§impl<const CLK_HZ: u32> I2C<CLK_HZ>
impl<const CLK_HZ: u32> I2C<CLK_HZ>
Sourcepub fn blocking_write_read(
&mut self,
address: I2CAddr,
write: &[u8],
read: &mut [u8],
) -> Result<(), I2CError>
pub fn blocking_write_read( &mut self, address: I2CAddr, write: &[u8], read: &mut [u8], ) -> Result<(), I2CError>
Writes bytes and reads bytes over the I2C bus.
§Examples
let mut buffer = [0; 4];
i2c.blocking_write_read(I2CAddr::SevenBitAddress(0x48), &[0x00, 0x01], &mut buffer)?;
assert_eq!(buffer, [0x02, 0x03, 0x04, 0x05]);
Master: ST SAD+W O0 O1 ... OM SR SAD+R MAK MAK ... NMAK SP
Slave: SAK SAK SAK ... SAK SAK I0 I1 ... IN
Sourcepub fn blocking_write(
&mut self,
address: I2CAddr,
write: &[u8],
) -> Result<(), I2CError>
pub fn blocking_write( &mut self, address: I2CAddr, write: &[u8], ) -> Result<(), I2CError>
Writes bytes over the I2C bus.
§Examples
i2c.blocking_write(I2CAddr::SevenBitAddress(0x48), &[0x00, 0x01])?;
Master: ST SAD+W B0 B1 ... BN SP
Slave: SAK SAK SAK ... SAK
Sourcepub fn blocking_read(
&mut self,
address: I2CAddr,
read: &mut [u8],
) -> Result<(), I2CError>
pub fn blocking_read( &mut self, address: I2CAddr, read: &mut [u8], ) -> Result<(), I2CError>
Reads bytes over the I2C bus.
§Examples
let mut buffer = [0; 4];
i2c.blocking_read(I2CAddr::SevenBitAddress(0x48), &mut buffer)?;
assert_eq!(buffer, [0x02, 0x03, 0x04, 0x05]);
Master: ST SAD+R MAK MAK ... NMAK SP
Slave: SAK B0 B1 ... BN
Trait Implementations§
Source§impl<const CLK_HZ: u32> I2c<u16> for I2C<CLK_HZ>
impl<const CLK_HZ: u32> I2c<u16> for I2C<CLK_HZ>
Source§fn write(&mut self, address: u16, write: &[u8]) -> Result<(), Self::Error>
fn write(&mut self, address: u16, write: &[u8]) -> Result<(), Self::Error>
Writes bytes to slave with address
address
. Read moreSource§impl<const CLK_HZ: u32> I2c for I2C<CLK_HZ>
impl<const CLK_HZ: u32> I2c for I2C<CLK_HZ>
Source§fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error>
fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error>
Writes bytes to slave with address
address
. Read moreAuto Trait Implementations§
impl<const CLK_HZ: u32> Freeze for I2C<CLK_HZ>
impl<const CLK_HZ: u32> RefUnwindSafe for I2C<CLK_HZ>
impl<const CLK_HZ: u32> Send for I2C<CLK_HZ>
impl<const CLK_HZ: u32> Sync for I2C<CLK_HZ>
impl<const CLK_HZ: u32> Unpin for I2C<CLK_HZ>
impl<const CLK_HZ: u32> UnwindSafe for I2C<CLK_HZ>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more