pub struct I2cInterface<I2C> { /* private fields */ }Expand description
I2C interface for the ICM-20948
Implementations§
Source§impl<I2C> I2cInterface<I2C>
impl<I2C> I2cInterface<I2C>
Sourcepub const fn default(i2c: I2C) -> Self
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)?;Sourcepub const fn alternative(i2c: I2C) -> Self
pub const fn alternative(i2c: I2C) -> Self
Sourcepub const fn new(i2c: I2C, address: u8) -> Self
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 peripheraladdress- The I2C device address
Trait Implementations§
Source§impl<I2C, E> AsyncRegisterInterface for I2cInterface<I2C>where
I2C: I2c<Error = E>,
Available on crate feature async only.
impl<I2C, E> AsyncRegisterInterface for I2cInterface<I2C>where
I2C: I2c<Error = E>,
Available on crate feature
async only.Source§type AddressType = u8
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>
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>
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>,
impl<I2C, E> RegisterInterface for I2cInterface<I2C>where
I2C: I2c<Error = E>,
Source§type AddressType = u8
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>
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>
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> 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