[−][src]Struct lis3mdl::Lis3mdl
LIS3MDL driver
Methods
impl<I2C, E> Lis3mdl<I2C> where
I2C: WriteRead<Error = E> + Write<Error = E>,
[src]
I2C: WriteRead<Error = E> + Write<Error = E>,
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]
&mut self,
mode: MeasurementMode
) -> Result<(), Error>
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]
&mut self,
enabled: bool
) -> Result<(), Error>
Enables the temperature sensor
Auto Trait Implementations
Blanket Implementations
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> From for T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,