[][src]Struct lis3mdl::Lis3mdl

pub struct Lis3mdl<I2C> { /* fields omitted */ }

LIS3MDL driver

Methods

impl<I2C, E> Lis3mdl<I2C> where
    I2C: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn new(i2c: I2C) -> Result<Self, Error>[src]

Create a new driver from an I2C peripheral and configures default settings:

  • Full Scale Range: 12G
  • Measurement Mode: Continuous Measurement
  • Operating Mode: Ultra High Performance
  • Enable the temperature sensor
  • Set data rate to fast
  • Enables Block Data Update

These defaults may be changed after initialization with set_full_scale, set_measurement_mode, set_operating_mode set_temperature_sensor, set_data_rate, and set_block_data_update, respectively.

pub fn who_am_i(&mut self) -> Result<u8, Error>[src]

Reads the WHO_AM_I register; should return 0x3D

pub fn get_raw_mag_axes(&mut self) -> Result<I16xyz, Error>[src]

Reads the XYZ components values of the magnetic field and returns the raw signed 16-bit integer value of each axis. This will return whatever is present in the data registers for each axis, so it is recommend to ensure that you are in the proper measurement mode and either synchronizing the read with interrupt/xyz_data_available or using set_block_data_update.

To obtain the value in Gauss or milliGauss either use get_mag_axes_mgauss or divide by column 2 in the table below (obtained from Table 2 in AN4602 Rev 1):

Full-scale (G) Gain@16-bit (LSB/Gauss)
4 6842
8 3421
12 2281
16 1711

pub fn xyz_data_available(&mut self) -> Result<bool, Error>[src]

True if the XYZ data is available to be read

pub fn get_mag_axes_mgauss(&mut self) -> Result<I32xyz, Error>[src]

Provide the magnetic field strength in each axis in milliGauss. Uses get_raw_mag_axes to obtain the value.

pub fn set_full_scale(&mut self, scale: FullScale) -> Result<(), Error>[src]

Set the Full Scale from between 4 Gauss and 16 Gauss to adjust the input dynamic range, based on the magnetic field to be measured. This will affect the output of get_raw_mag_axes so use get_mag_axes_mgauss unless you intend to adjust the values yourself.

pub fn set_operating_mode(&mut self, mode: OperatingMode) -> Result<(), Error>[src]

Adjust the operating mode. This will have an impact on current consumption, the max data rate, and the output noise with Ultra High Performance (UHP) being the slowest and highest current consumption with the lowest noise, and Low Power (LP) being the highest level of noise, but offering up to 1000 Hz data rate and lowest current consumption. See AN4602 for more details.

pub fn set_measurement_mode(
    &mut self,
    mode: MeasurementMode
) -> Result<(), Error>
[src]

Select between 3 measurement modes: Idle, Single Measurement, and Continuous. Configure to Idle if not being used, Single Measurement if only one measurement is desired, and Continuous if a constant stream of data is needed.

pub fn set_data_rate(&mut self, rate: DataRate) -> Result<(), Error>[src]

Set the output data rate. Specific data rates from 0.625 Hz to 80 Hz can be configured for any given operating mode, and Fast will be the highest achievable data rate for the given operating mode at 1000 Hz for Low Power and 155 Hz for Ultra High Performance. See AN4602 for more details.

pub fn set_block_data_update(&mut self, block: bool) -> Result<(), Error>[src]

Blocks the refresh of data for a given axis until the initiated read for that axis completes. Strongly recommended if the reading of the magnetic data cannot be synchronized with the XYZDA in the status register. Ensures that data registers for each channel always contain the most recent magnetic data.

pub fn set_temperature_sensor_enable(
    &mut self,
    enabled: bool
) -> Result<(), Error>
[src]

Enables the temperature sensor

Auto Trait Implementations

impl<I2C> Send for Lis3mdl<I2C> where
    I2C: Send

impl<I2C> Sync for Lis3mdl<I2C> where
    I2C: Sync

Blanket Implementations

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> From for T[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]