pub struct Sccb<I> { /* private fields */ }Expand description
A sensor’s control interface over an I²C bus.
Implementations§
Source§impl<I: I2c> Sccb<I>
impl<I: I2c> Sccb<I>
Sourcepub fn new(i2c: I, addr: u8, width: RegWidth) -> Self
pub fn new(i2c: I, addr: u8, width: RegWidth) -> Self
Talk to the sensor at 7-bit address addr with width register addresses.
Sourcepub fn for_sensor(i2c: I, desc: &SensorDesc) -> Self
pub fn for_sensor(i2c: I, desc: &SensorDesc) -> Self
Talk to the sensor desc describes.
Sourcepub fn read(&mut self, reg: u16) -> Result<u8>
pub fn read(&mut self, reg: u16) -> Result<u8>
Read one register (write the address, then read one byte).
Sourcepub fn apply(
&mut self,
table: &[RegOp],
delay_ms: impl FnMut(u16),
) -> Result<usize>
pub fn apply( &mut self, table: &[RegOp], delay_ms: impl FnMut(u16), ) -> Result<usize>
Run a register sequence. delay_ms is called for each
RegOp::DelayMs step (the caller owns the clock). Returns the number
of registers written.
Sourcepub fn probe(&mut self, desc: &SensorDesc) -> Result<bool>
pub fn probe(&mut self, desc: &SensorDesc) -> Result<bool>
Read the product id and compare with desc.
Trait Implementations§
Auto Trait Implementations§
impl<I> Freeze for Sccb<I>where
I: Freeze,
impl<I> RefUnwindSafe for Sccb<I>where
I: RefUnwindSafe,
impl<I> Send for Sccb<I>where
I: Send,
impl<I> Sync for Sccb<I>where
I: Sync,
impl<I> Unpin for Sccb<I>where
I: Unpin,
impl<I> UnsafeUnpin for Sccb<I>where
I: UnsafeUnpin,
impl<I> UnwindSafe for Sccb<I>where
I: UnwindSafe,
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