Skip to main content

Sccb

Struct Sccb 

Source
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>

Source

pub fn new(i2c: I, addr: u8, width: RegWidth) -> Self

Talk to the sensor at 7-bit address addr with width register addresses.

Source

pub fn for_sensor(i2c: I, desc: &SensorDesc) -> Self

Talk to the sensor desc describes.

Source

pub fn addr(&self) -> u8

The 7-bit bus address.

Source

pub fn release(self) -> I

Give the bus back.

Source

pub fn write(&mut self, reg: u16, value: u8) -> Result<()>

Write one register.

Source

pub fn write_reg(&mut self, reg: Register) -> Result<()>

Write one Register.

Source

pub fn read(&mut self, reg: u16) -> Result<u8>

Read one register (write the address, then read one byte).

Source

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.

Source

pub fn probe(&mut self, desc: &SensorDesc) -> Result<bool>

Read the product id and compare with desc.

Trait Implementations§

Source§

impl<I: Debug> Debug for Sccb<I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.