pub struct Lsm303agr<DI, MODE> { /* private fields */ }
Expand description
LSM303AGR device driver
Implementations§
source§impl<DI, CommE, MODE> Lsm303agr<DI, MODE>
impl<DI, CommE, MODE> Lsm303agr<DI, MODE>
sourcepub fn set_accel_mode_and_odr<D: DelayNs>(
&mut self,
delay: &mut D,
mode: AccelMode,
odr: impl Into<Option<AccelOutputDataRate>>
) -> Result<(), Error<CommE>>
pub fn set_accel_mode_and_odr<D: DelayNs>( &mut self, delay: &mut D, mode: AccelMode, odr: impl Into<Option<AccelOutputDataRate>> ) -> Result<(), Error<CommE>>
Set accelerometer power/resolution mode and output data rate.
Returns Error::InvalidInputData
if the mode is incompatible with
the given output data rate.
The given delay
is used to wait for the sensor to turn on or change modes,
according to the times specified in Table 14 and Table 15 in the datasheet.
You can opt out of this by using a no-op delay implementation, see
embedded_hal_mock::delay::MockNoop
for an example of such an
implementation.
sourcepub fn get_accel_mode(&mut self) -> AccelMode
pub fn get_accel_mode(&mut self) -> AccelMode
Get the accelerometer mode
sourcepub fn set_accel_scale(&mut self, scale: AccelScale) -> Result<(), Error<CommE>>
pub fn set_accel_scale(&mut self, scale: AccelScale) -> Result<(), Error<CommE>>
Set accelerometer scaling factor
This changes the scale at which the acceleration is read.
AccelScale::G2
for example can return values between -2g and +2g
where g is the gravity of the earth (~9.82 m/s²).
sourcepub fn get_accel_scale(&self) -> AccelScale
pub fn get_accel_scale(&self) -> AccelScale
Get accelerometer scaling factor
source§impl<I2C> Lsm303agr<I2cInterface<I2C>, MagOneShot>
impl<I2C> Lsm303agr<I2cInterface<I2C>, MagOneShot>
sourcepub fn new_with_i2c(i2c: I2C) -> Self
pub fn new_with_i2c(i2c: I2C) -> Self
Create new instance of the LSM303AGR device communicating through I2C.
source§impl<I2C, MODE> Lsm303agr<I2cInterface<I2C>, MODE>
impl<I2C, MODE> Lsm303agr<I2cInterface<I2C>, MODE>
source§impl<SPIXL, SPIMAG> Lsm303agr<SpiInterface<SPIXL, SPIMAG>, MagOneShot>
impl<SPIXL, SPIMAG> Lsm303agr<SpiInterface<SPIXL, SPIMAG>, MagOneShot>
sourcepub fn new_with_spi(spi_accel: SPIXL, spi_mag: SPIMAG) -> Self
pub fn new_with_spi(spi_accel: SPIXL, spi_mag: SPIMAG) -> Self
Create new instance of the LSM303AGR device communicating through SPI.
source§impl<SPIXL, SPIMAG, MODE> Lsm303agr<SpiInterface<SPIXL, SPIMAG>, MODE>
impl<SPIXL, SPIMAG, MODE> Lsm303agr<SpiInterface<SPIXL, SPIMAG>, MODE>
sourcepub fn destroy(self) -> (SPIXL, SPIMAG)
pub fn destroy(self) -> (SPIXL, SPIMAG)
Destroy driver instance, return SPI bus instance and chip select pin.
source§impl<DI, CommE, MODE> Lsm303agr<DI, MODE>
impl<DI, CommE, MODE> Lsm303agr<DI, MODE>
sourcepub fn acc_set_fifo_mode(
&mut self,
mode: FifoMode,
fth: u8
) -> Result<(), Error<CommE>>
pub fn acc_set_fifo_mode( &mut self, mode: FifoMode, fth: u8 ) -> Result<(), Error<CommE>>
Set the accelerometer FIFO mode and full threshold.
The threshold is clamped to [0, 31].
sourcepub fn acc_enable_interrupt(
&mut self,
interrupt: Interrupt
) -> Result<(), Error<CommE>>
pub fn acc_enable_interrupt( &mut self, interrupt: Interrupt ) -> Result<(), Error<CommE>>
Enable accelerometer interrupt.
sourcepub fn acc_disable_interrupt(
&mut self,
interrupt: Interrupt
) -> Result<(), Error<CommE>>
pub fn acc_disable_interrupt( &mut self, interrupt: Interrupt ) -> Result<(), Error<CommE>>
Disable accelerometer interrupt.
sourcepub fn mag_enable_int(&mut self) -> Result<(), Error<CommE>>
pub fn mag_enable_int(&mut self) -> Result<(), Error<CommE>>
Configure the DRDY pin as a digital output.
sourcepub fn mag_enable_low_pass_filter(&mut self) -> Result<(), Error<CommE>>
pub fn mag_enable_low_pass_filter(&mut self) -> Result<(), Error<CommE>>
Enable magnetometer low-pass filter.
sourcepub fn mag_disable_low_pass_filter(&mut self) -> Result<(), Error<CommE>>
pub fn mag_disable_low_pass_filter(&mut self) -> Result<(), Error<CommE>>
Disable magnetometer low-pass filter.
sourcepub fn accel_status(&mut self) -> Result<Status, Error<CommE>>
pub fn accel_status(&mut self) -> Result<Status, Error<CommE>>
Accelerometer status
sourcepub fn acceleration(&mut self) -> Result<Acceleration, Error<CommE>>
pub fn acceleration(&mut self) -> Result<Acceleration, Error<CommE>>
Get measured acceleration.
sourcepub fn mag_status(&mut self) -> Result<Status, Error<CommE>>
pub fn mag_status(&mut self) -> Result<Status, Error<CommE>>
Magnetometer status
sourcepub fn accelerometer_id(&mut self) -> Result<AccelerometerId, Error<CommE>>
pub fn accelerometer_id(&mut self) -> Result<AccelerometerId, Error<CommE>>
Get the accelerometer device ID.
sourcepub fn magnetometer_id(&mut self) -> Result<MagnetometerId, Error<CommE>>
pub fn magnetometer_id(&mut self) -> Result<MagnetometerId, Error<CommE>>
Get the magnetometer device ID.
sourcepub fn temperature(&mut self) -> Result<Temperature, Error<CommE>>
pub fn temperature(&mut self) -> Result<Temperature, Error<CommE>>
Get measured temperature.
sourcepub fn temperature_status(&mut self) -> Result<TemperatureStatus, Error<CommE>>
pub fn temperature_status(&mut self) -> Result<TemperatureStatus, Error<CommE>>
Temperature sensor status
source§impl<DI, CommE> Lsm303agr<DI, MagOneShot>
impl<DI, CommE> Lsm303agr<DI, MagOneShot>
sourcepub fn into_mag_continuous(
self
) -> Result<Lsm303agr<DI, MagContinuous>, ModeChangeError<CommE, Self>>
pub fn into_mag_continuous( self ) -> Result<Lsm303agr<DI, MagContinuous>, ModeChangeError<CommE, Self>>
Change the magnetometer to continuous measurement mode
source§impl<DI, CommE> Lsm303agr<DI, MagContinuous>
impl<DI, CommE> Lsm303agr<DI, MagContinuous>
sourcepub fn into_mag_one_shot(
self
) -> Result<Lsm303agr<DI, MagOneShot>, ModeChangeError<CommE, Self>>
pub fn into_mag_one_shot( self ) -> Result<Lsm303agr<DI, MagOneShot>, ModeChangeError<CommE, Self>>
Change the magnetometer to one-shot mode
After this the magnetometer is in idle mode until a one-shot measurement is started.
source§impl<DI, CommE, MODE> Lsm303agr<DI, MODE>
impl<DI, CommE, MODE> Lsm303agr<DI, MODE>
sourcepub fn set_mag_mode_and_odr<D: DelayNs>(
&mut self,
delay: &mut D,
mode: MagMode,
odr: MagOutputDataRate
) -> Result<(), Error<CommE>>
pub fn set_mag_mode_and_odr<D: DelayNs>( &mut self, delay: &mut D, mode: MagMode, odr: MagOutputDataRate ) -> Result<(), Error<CommE>>
Set magnetometer power/resolution mode and output data rate.
The given delay
is used to wait for the sensor to turn on or change modes,
according to the times specified in Table 14 and Table 15 in the datasheet.
You can opt out of this by using a no-op delay implementation, see
embedded_hal_mock::delay::MockNoop
for an example of such an
implementation.
sourcepub fn get_mag_mode(&self) -> MagMode
pub fn get_mag_mode(&self) -> MagMode
Get magnetometer power/resolution mode.
source§impl<DI, CommE> Lsm303agr<DI, MagContinuous>
impl<DI, CommE> Lsm303agr<DI, MagContinuous>
sourcepub fn magnetic_field(&mut self) -> Result<MagneticField, Error<CommE>>
pub fn magnetic_field(&mut self) -> Result<MagneticField, Error<CommE>>
Get the measured magnetic field.
sourcepub fn enable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
pub fn enable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
Enable the magnetometer’s built in offset cancellation.
Offset cancellation is automatically managed by the device in continuous mode.
To later disable offset cancellation, use the disable_mag_offset_cancellation
function
sourcepub fn disable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
pub fn disable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
Disable the magnetometer’s built in offset cancellation.
source§impl<DI, CommE> Lsm303agr<DI, MagOneShot>
impl<DI, CommE> Lsm303agr<DI, MagOneShot>
sourcepub fn magnetic_field(&mut self) -> Result<MagneticField, Error<CommE>>
pub fn magnetic_field(&mut self) -> Result<MagneticField, Error<CommE>>
Get the measured magnetic field.
sourcepub fn enable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
pub fn enable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
Enable the magnetometer’s built in offset cancellation.
Offset cancellation has to be managed by the user in single measurement (OneShot) mode averaging two consecutive measurements Hn and Hn-1.
To later disable offset cancellation, use the disable_mag_offset_cancellation
function
sourcepub fn disable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
pub fn disable_mag_offset_cancellation(&mut self) -> Result<(), Error<CommE>>
Disable the magnetometer’s built in offset cancellation.