I2cInterface

Struct I2cInterface 

Source
pub struct I2cInterface<I2C> { /* private fields */ }
Expand description

I2C interface for the ICM-20948

Implementations§

Source§

impl<I2C> I2cInterface<I2C>

Source

pub const fn default(i2c: I2C) -> Self

Create a new I2C interface with the default address (0x68, AD0 pin LOW)

This is the most common configuration where the AD0 pin is pulled low or left floating (has internal pull-down on most breakout boards).

§Arguments
  • i2c - The I2C peripheral
§Example
let interface = I2cInterface::default(i2c);
let mut imu = Icm20948Driver::new(interface)?;
Source

pub const fn alternative(i2c: I2C) -> Self

Create a new I2C interface with the alternative address (0x69, AD0 pin HIGH)

Use this when the AD0 pin is explicitly pulled high to VDD.

§Arguments
  • i2c - The I2C peripheral
§Example
let interface = I2cInterface::alternative(i2c);
let mut imu = Icm20948Driver::new(interface)?;
Source

pub const fn new(i2c: I2C, address: u8) -> Self

Create a new I2C interface with a custom device address

This allows specifying any I2C address for advanced use cases. For standard ICM-20948 configurations, prefer default() or alternative().

§Arguments
  • i2c - The I2C peripheral
  • address - The I2C device address
Source

pub fn release(self) -> I2C

Consume the interface and return the I2C peripheral

Trait Implementations§

Source§

impl<I2C, E> AsyncRegisterInterface for I2cInterface<I2C>
where I2C: I2c<Error = E>,

Available on crate feature async only.
Source§

type Error = E

The error type
Source§

type AddressType = u8

The address type used by this interface. Should likely be an integer.
Source§

async fn read_register( &mut self, address: Self::AddressType, size_bits: u32, read_data: &mut [u8], ) -> Result<(), Self::Error>

Read the register located at the given addres to the given data slice
Source§

async fn write_register( &mut self, address: Self::AddressType, size_bits: u32, write_data: &[u8], ) -> Result<(), Self::Error>

Write the given data to the register located at the given address
Source§

impl<I2C, E> RegisterInterface for I2cInterface<I2C>
where I2C: I2c<Error = E>,

Source§

type Error = E

The error type
Source§

type AddressType = u8

The address type used by this interface. Should likely be an integer.
Source§

fn read_register( &mut self, address: Self::AddressType, size_bits: u32, read_data: &mut [u8], ) -> Result<(), Self::Error>

Read the register located at the given addres to the given data slice
Source§

fn write_register( &mut self, address: Self::AddressType, size_bits: u32, write_data: &[u8], ) -> Result<(), Self::Error>

Write the given data to the register located at the given address

Auto Trait Implementations§

§

impl<I2C> Freeze for I2cInterface<I2C>
where I2C: Freeze,

§

impl<I2C> RefUnwindSafe for I2cInterface<I2C>
where I2C: RefUnwindSafe,

§

impl<I2C> Send for I2cInterface<I2C>
where I2C: Send,

§

impl<I2C> Sync for I2cInterface<I2C>
where I2C: Sync,

§

impl<I2C> Unpin for I2cInterface<I2C>
where I2C: Unpin,

§

impl<I2C> UnwindSafe for I2cInterface<I2C>
where I2C: 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 = 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>,

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.