Skip to main content

Bmi270

Struct Bmi270 

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

BMI270 driver.

Implementations§

Source§

impl<I2C: I2c> Bmi270<I2C>

Source

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

Wraps a bus handle. Call init before reading.

Source

pub async fn chip_id(&mut self) -> Result<u8, I2C::Error>

Reads CHIP_ID.

Source

pub async fn init( &mut self, config: Config, delay: &mut impl DelayNs, ) -> Result<(), Error<I2C::Error>>

Resets the chip, uploads CONFIG_FILE, and starts both sensors with config. Takes roughly 250 ms at 400 kHz, mostly the upload.

Source

pub async fn configure( &mut self, config: Config, ) -> Result<(), Error<I2C::Error>>

Changes ranges and rate. The chip must already be initialised.

Source

pub async fn read_raw(&mut self) -> Result<RawSample, I2C::Error>

Reads both sensors in one 12-byte burst.

Source

pub async fn read(&mut self) -> Result<Sample, I2C::Error>

Reads both sensors, scaled to g and °/s.

Source

pub fn scale(&self, raw: RawSample) -> Sample

Converts a raw sample using the current ranges.

Source

pub async fn temperature(&mut self) -> Result<Option<f32>, I2C::Error>

Die temperature in °C, or None while no valid reading exists yet.

Source

pub fn release(self) -> I2C

Returns the bus handle.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<I2C> UnsafeUnpin for Bmi270<I2C>
where I2C: UnsafeUnpin,

§

impl<I2C> UnwindSafe for Bmi270<I2C>
where I2C: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.