IcmBuilder

Struct IcmBuilder 

Source
pub struct IcmBuilder<TRANSPORT, DELAY> { /* private fields */ }
Expand description

Configure and initialize a new instance of Icm20948. Use either of the [Icm20948::new_i2c] or [Icm20948::new_spi] methods to begin.

§Example

let mut imu = IcmBuilder::new_i2c(i2c, delay)
    .gyr_unit(GyrUnit::Rps)
    .gyr_dlp(GyrDlp::Hz196)
    .initialize_9dof().await?;

Implementations§

Source§

impl<BUS, DELAY> IcmBuilder<I2cDevice<BUS>, DELAY>
where BUS: I2c, DELAY: DelayNs,

Source

pub fn new_i2c(bus: BUS, delay: DELAY) -> IcmBuilder<I2cDevice<BUS>, DELAY>

Creates an uninitialized IMU struct with a default config.

Source

pub fn set_address( self, address: impl Into<I2cAddress>, ) -> IcmBuilder<I2cDevice<BUS>, DELAY>

Set I2C address of ICM module. See I2cAddress for defaults, otherwise u8 implements Into<I2cAddress>

Note: This will not change the actual address, only the address used by this driver.

Source§

impl<SPI, DELAY> IcmBuilder<SpiDevice<SPI>, DELAY>
where SPI: SpiDevice, DELAY: DelayNs,

Source

pub fn new_spi(spi: SPI, delay: DELAY) -> IcmBuilder<SpiDevice<SPI>, DELAY>

Creates an uninitialized IMU struct with a default config.

Source§

impl<TRANPORT, DELAY> IcmBuilder<TRANPORT, DELAY>
where TRANPORT: Icm20948Transport, DELAY: DelayNs,

Source

pub fn with_config(self, config: Config) -> IcmBuilder<TRANPORT, DELAY>

Set the whole IMU config at once

Source

pub fn acc_range(self, acc_range: AccRange) -> IcmBuilder<TRANPORT, DELAY>

Set accelerometer measuring range, choises are 2G, 4G, 8G or 16G

Source

pub fn acc_dlp(self, acc_dlp: AccDlp) -> IcmBuilder<TRANPORT, DELAY>

Set accelerometer digital lowpass filter frequency

Source

pub fn acc_unit(self, acc_unit: AccUnit) -> IcmBuilder<TRANPORT, DELAY>

Set returned unit of accelerometer measurement, choises are Gs or m/s^2

Source

pub fn acc_odr(self, acc_odr: u16) -> IcmBuilder<TRANPORT, DELAY>

Set accelerometer output data rate

Source

pub fn gyr_range(self, gyr_range: GyrRange) -> IcmBuilder<TRANPORT, DELAY>

Set gyroscope measuring range, choises are 250Dps, 500Dps, 1000Dps and 2000Dps

Source

pub fn gyr_dlp(self, gyr_dlp: GyrDlp) -> IcmBuilder<TRANPORT, DELAY>

Set gyroscope digital low pass filter frequency

Source

pub fn gyr_unit(self, gyr_unit: GyrUnit) -> IcmBuilder<TRANPORT, DELAY>

Set returned unit of gyroscope measurement, choises are degrees/s or radians/s

Source

pub fn gyr_odr(self, gyr_odr: u8) -> IcmBuilder<TRANPORT, DELAY>

Set gyroscope output data rate

Source

pub async fn initialize_6dof( self, ) -> Result<Icm20948<TRANPORT, MagDisabled>, SetupError<TRANPORT::Error>>

Initializes the IMU with accelerometer and gyroscope

Source

pub async fn initialize_9dof( self, ) -> Result<Icm20948<TRANPORT, MagEnabled>, SetupError<TRANPORT::Error>>

Initializes the IMU with accelerometer, gyroscope and magnetometer

Auto Trait Implementations§

§

impl<TRANSPORT, DELAY> Freeze for IcmBuilder<TRANSPORT, DELAY>
where TRANSPORT: Freeze, DELAY: Freeze,

§

impl<TRANSPORT, DELAY> RefUnwindSafe for IcmBuilder<TRANSPORT, DELAY>
where TRANSPORT: RefUnwindSafe, DELAY: RefUnwindSafe,

§

impl<TRANSPORT, DELAY> Send for IcmBuilder<TRANSPORT, DELAY>
where TRANSPORT: Send, DELAY: Send,

§

impl<TRANSPORT, DELAY> Sync for IcmBuilder<TRANSPORT, DELAY>
where TRANSPORT: Sync, DELAY: Sync,

§

impl<TRANSPORT, DELAY> Unpin for IcmBuilder<TRANSPORT, DELAY>
where TRANSPORT: Unpin, DELAY: Unpin,

§

impl<TRANSPORT, DELAY> UnwindSafe for IcmBuilder<TRANSPORT, DELAY>
where TRANSPORT: UnwindSafe, DELAY: 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.