pub struct Lis2dtw12<I> { /* private fields */ }Expand description
LIS2DTW12 driver
Implementations§
source§impl<I: Interface> Lis2dtw12<I>
impl<I: Interface> Lis2dtw12<I>
LIS2DTW12 driver
sourcepub fn get_device_id(&mut self) -> Result<u8, I::Error>
pub fn get_device_id(&mut self) -> Result<u8, I::Error>
Read the WHO_AM_I register
sourcepub fn get_temperature_raw(&mut self) -> Result<i16, I::Error>
pub fn get_temperature_raw(&mut self) -> Result<i16, I::Error>
Read the RAW temperature data
sourcepub fn get_temperature(&mut self) -> Result<f32, I::Error>
pub fn get_temperature(&mut self) -> Result<f32, I::Error>
Read the temperature data
sourcepub fn set_output_data_rate(
&mut self,
odr: OutputDataRate,
) -> Result<(), I::Error>
pub fn set_output_data_rate( &mut self, odr: OutputDataRate, ) -> Result<(), I::Error>
Set the Output Data Rate
sourcepub fn set_low_power_mode(
&mut self,
low_power_mode: LowPowerMode,
) -> Result<(), I::Error>
pub fn set_low_power_mode( &mut self, low_power_mode: LowPowerMode, ) -> Result<(), I::Error>
Set the Low Power Mode
sourcepub fn reset_settings(&mut self) -> Result<(), I::Error>
pub fn reset_settings(&mut self) -> Result<(), I::Error>
Reset all settings (CTRL registers to default)
sourcepub fn disconnect_cs_pull_up(
&mut self,
disconnect: bool,
) -> Result<(), I::Error>
pub fn disconnect_cs_pull_up( &mut self, disconnect: bool, ) -> Result<(), I::Error>
(Dis-)connect CS pull-up (only relevant when using SPI interface)
sourcepub fn enable_continuous_update(&mut self, enable: bool) -> Result<(), I::Error>
pub fn enable_continuous_update(&mut self, enable: bool) -> Result<(), I::Error>
Enable or disable block data update
When enabled, the output registers are continously updated
When disabled, the output registers are updated only after MSB and LSB reading
Enabled by default
sourcepub fn set_bandwidth(
&mut self,
bandwidth: BandwidthSelection,
) -> Result<(), I::Error>
pub fn set_bandwidth( &mut self, bandwidth: BandwidthSelection, ) -> Result<(), I::Error>
Set the bandwidth selection
sourcepub fn set_full_scale(&mut self, full_scale: FullScale) -> Result<(), I::Error>
pub fn set_full_scale(&mut self, full_scale: FullScale) -> Result<(), I::Error>
Set the full-scale selection
sourcepub fn enable_filtered_data_selection(
&mut self,
enable: bool,
) -> Result<(), I::Error>
pub fn enable_filtered_data_selection( &mut self, enable: bool, ) -> Result<(), I::Error>
Enable/Disable Filtered data type selection
disabled: low-pass filter path selected
enabled: high-pass filter path selected
Disabled by default
sourcepub fn enable_low_noise(&mut self, enable: bool) -> Result<(), I::Error>
pub fn enable_low_noise(&mut self, enable: bool) -> Result<(), I::Error>
Enable/Disable low-noise configuration Disabled by default
sourcepub fn get_status(&mut self) -> Result<Status, I::Error>
pub fn get_status(&mut self) -> Result<Status, I::Error>
Get the status of the device
§NOTE
Status and Event Status registers are mostly the same with the exceptions:
-
Status register reports the status of the FIFO threshold
INSTEAD
Event Status register reports the status of the FIFO overrun
-
Status register reports the wake-up event detection status
INSTEAD
Event Status register reports the temperature data ready status
The rest is the same
sourcepub fn get_event_status(&mut self) -> Result<EventStatus, I::Error>
pub fn get_event_status(&mut self) -> Result<EventStatus, I::Error>
Get the Event Status register
§NOTE
Status and Event Status registers are mostly the same with the exceptions:
-
Status register reports the status of the FIFO threshold
INSTEAD
Event Status register reports the status of the FIFO overrun
-
Status register reports the wake-up event detection status
INSTEAD
Event Status register reports the temperature data ready status
The rest is the same
sourcepub fn get_x_accel_raw(&mut self) -> Result<i16, I::Error>
pub fn get_x_accel_raw(&mut self) -> Result<i16, I::Error>
Get the X-axis RAW acceleration data
§NOTE
The data is 12/14-bit (depending on Mode and LowPowerMode) left-justified!
sourcepub fn get_y_accel_raw(&mut self) -> Result<i16, I::Error>
pub fn get_y_accel_raw(&mut self) -> Result<i16, I::Error>
Get the Y-axis RAW acceleration data
§NOTE
The data is 12/14-bit (depending on Mode and LowPowerMode) left-justified!
sourcepub fn get_z_accel_raw(&mut self) -> Result<i16, I::Error>
pub fn get_z_accel_raw(&mut self) -> Result<i16, I::Error>
Get the Z-axis RAW acceleration data
§NOTE
The data is 12/14-bit (depending on Mode and LowPowerMode) left-justified!
sourcepub fn get_x_accel(&mut self) -> Result<f32, I::Error>
pub fn get_x_accel(&mut self) -> Result<f32, I::Error>
sourcepub fn get_y_accel(&mut self) -> Result<f32, I::Error>
pub fn get_y_accel(&mut self) -> Result<f32, I::Error>
sourcepub fn get_z_accel(&mut self) -> Result<f32, I::Error>
pub fn get_z_accel(&mut self) -> Result<f32, I::Error>
sourcepub fn get_accel_data_raw(&mut self) -> Result<RawAccelerationData, I::Error>
pub fn get_accel_data_raw(&mut self) -> Result<RawAccelerationData, I::Error>
Get the RAW acceleration data
§NOTE
The data is 12/14-bit (depending on Mode and LowPowerMode) left-justified!
sourcepub fn get_accel_data(&mut self) -> Result<AccelerationData, I::Error>
pub fn get_accel_data(&mut self) -> Result<AccelerationData, I::Error>
sourcepub fn set_fifo_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
pub fn set_fifo_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
Set the FIFO threshold
§NOTE
Fifo threshold is a 5-bit value (0-31).
If the given threshold value is greater than 31, it will be set to 31
sourcepub fn get_fifo_samples_status(&mut self) -> Result<FifoSamplesStatus, I::Error>
pub fn get_fifo_samples_status(&mut self) -> Result<FifoSamplesStatus, I::Error>
Get the FIFO samples status
sourcepub fn enable_4d_detection(&mut self, enable: bool) -> Result<(), I::Error>
pub fn enable_4d_detection(&mut self, enable: bool) -> Result<(), I::Error>
Enable 4D decection portrait/landscape position
Disabled by default
sourcepub fn set_6d_threshold(
&mut self,
threshold: Threshold6D,
) -> Result<(), I::Error>
pub fn set_6d_threshold( &mut self, threshold: Threshold6D, ) -> Result<(), I::Error>
Set the 6D threshold
Thresholds for 4D/6D function @ FS = ±2g
sourcepub fn set_tap_priority(
&mut self,
tap_priority: TapPriority,
) -> Result<(), I::Error>
pub fn set_tap_priority( &mut self, tap_priority: TapPriority, ) -> Result<(), I::Error>
Set the tap priority
Tap Priority axis selection for tap detection
sourcepub fn enable_xyz_tap_detection(
&mut self,
x_enable: bool,
y_enable: bool,
z_enable: bool,
) -> Result<(), I::Error>
pub fn enable_xyz_tap_detection( &mut self, x_enable: bool, y_enable: bool, z_enable: bool, ) -> Result<(), I::Error>
Enable X/Y/Z direction tap recognition
sourcepub fn set_x_tap_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
pub fn set_x_tap_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
Set the tap Threshold for X direction
§NOTE
Threshold is a 5-bit value (0-31).
If the given threshold value is greater than 31, it will be set to 31
sourcepub fn set_y_tap_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
pub fn set_y_tap_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
Set the tap Threshold for Y direction
§NOTE
Threshold is a 5-bit value (0-31).
If the given threshold value is greater than 31, it will be set to 31
sourcepub fn set_z_tap_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
pub fn set_z_tap_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
Set the tap Threshold for Z direction
§NOTE
Threshold is a 5-bit value (0-31).
If the given threshold value is greater than 31, it will be set to 31
sourcepub fn set_double_tap_latency(&mut self, latency: u8) -> Result<(), I::Error>
pub fn set_double_tap_latency(&mut self, latency: u8) -> Result<(), I::Error>
Duration of maximum time gap for double-tap recognition. When double-tap recognition is enabled, this register expresses the maximum time between two successive detected taps to determine a double-tap event.
Default value is LATENCY[3:0] = 0000 (which is 16 * 1/ODR)
1 LSB = 32 * 1/ODR
§NOTE
Latency is a 4-bit value (0-15).
If the given latency value is greater than 15, it will be set to 15
sourcepub fn set_tap_quiet_time(&mut self, quiet_time: u8) -> Result<(), I::Error>
pub fn set_tap_quiet_time(&mut self, quiet_time: u8) -> Result<(), I::Error>
Expected quiet time after a tap detection: this register represents the time after the first detected tap in which there must not be any overthreshold event.
Default value is QUIET[1:0] = 00 (which is 2 * 1/ODR)
1 LSB = 4 * 1/ODR
§NOTE
Quiet time is a 2-bit value (0-3).
If the given quiet time value is greater than 3, it will be set to 3
sourcepub fn set_tap_shock_time(&mut self, shock_time: u8) -> Result<(), I::Error>
pub fn set_tap_shock_time(&mut self, shock_time: u8) -> Result<(), I::Error>
Maximum duration of overthreshold event: this register represents the maximum time of an overthreshold signal detection to be recognized as a tap event.
Default value is SHOCK[1:0] = 00 (which is 4 * 1/ODR) 1 LSB = 8 *1/ODR
§NOTE
Shock time is a 2-bit value (0-3).
If the given shock time value is greater than 3, it will be set to 3
sourcepub fn enable_double_tap_detection(
&mut self,
enable: bool,
) -> Result<(), I::Error>
pub fn enable_double_tap_detection( &mut self, enable: bool, ) -> Result<(), I::Error>
Enable/Disable double-tap detection
enabled: Single and double tap detection enabled
disabled: Only single tap detection enabled
Disabled by default
sourcepub fn enable_sleep_mode(&mut self, enable: bool) -> Result<(), I::Error>
pub fn enable_sleep_mode(&mut self, enable: bool) -> Result<(), I::Error>
Enable/Disable sleep mode
enabled: Sleep mode enabled
disabled: Sleep mode disabled
Disabled by default
sourcepub fn set_wake_up_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
pub fn set_wake_up_threshold(&mut self, threshold: u8) -> Result<(), I::Error>
Set the wake-up threshold
Wake-up threshold, 6-bit unsigned 1 LSB = 1/64 of FS.
Default value: 000000
§NOTE
Threshold is a 6-bit value (0-63).
If the given threshold value is greater than 63, it will be set to 63
sourcepub fn set_wake_up_duration(&mut self, duration: u8) -> Result<(), I::Error>
pub fn set_wake_up_duration(&mut self, duration: u8) -> Result<(), I::Error>
Set the wake-up duration
Wake-up duration. 1 LSB = 1 *1/ODR
§NOTE
Duration is a 2-bit value (0-3).
If the given duration value is greater than 3, it will be set to 3
sourcepub fn enable_stationary_detection(
&mut self,
enable: bool,
) -> Result<(), I::Error>
pub fn enable_stationary_detection( &mut self, enable: bool, ) -> Result<(), I::Error>
Enable/Disable stationary detection / motion detection with no automatic ODR change when detecting stationary state
enabled: Stationary detection enabled
disabled: Stationary detection disabled
Disabled by default
sourcepub fn set_sleep_duration(&mut self, duration: u8) -> Result<(), I::Error>
pub fn set_sleep_duration(&mut self, duration: u8) -> Result<(), I::Error>
Set duration to go i nsleep mode
Default value is SLEEP_ DUR[3:0] = 0000 (which is 16 * 1/ODR).
1 LSB = 512 * 1/ODR
§NOTE
Duration is a 4-bit value (0-15).
If the given duration value is greater than 15, it will be set to 15
sourcepub fn set_free_fall_duration(&mut self, duration: u8) -> Result<(), I::Error>
pub fn set_free_fall_duration(&mut self, duration: u8) -> Result<(), I::Error>
Set the free-fall duration
1 LSB = 1 * 1/ODR
Default value is FF_DUR[5:0] = 000000
§NOTE
Duration is a 6-bit value (0-63).
If the given duration value is greater than 63, it will be set to 63
sourcepub fn set_free_fall_threshold(
&mut self,
threshold: FreeFallThreshold,
) -> Result<(), I::Error>
pub fn set_free_fall_threshold( &mut self, threshold: FreeFallThreshold, ) -> Result<(), I::Error>
Set the free-fall threshold
Free-fall threshold @ FS = ±2 g
sourcepub fn get_wake_up_source(&mut self) -> Result<WakeUpSource, I::Error>
pub fn get_wake_up_source(&mut self) -> Result<WakeUpSource, I::Error>
Get the wake-up source
sourcepub fn get_tap_source(&mut self) -> Result<TapSource, I::Error>
pub fn get_tap_source(&mut self) -> Result<TapSource, I::Error>
Get the tap source
sourcepub fn get_6d_source(&mut self) -> Result<SixDSource, I::Error>
pub fn get_6d_source(&mut self) -> Result<SixDSource, I::Error>
Get the 6D source
sourcepub fn get_all_interrupt_sources(
&mut self,
) -> Result<AllInterruptSources, I::Error>
pub fn get_all_interrupt_sources( &mut self, ) -> Result<AllInterruptSources, I::Error>
Get all interrupt sources
§NOTE
Reading this register clears all interrupt function flags routed to the INT pads simultaneously!
sourcepub fn set_x_offset(&mut self, offset: i8) -> Result<(), I::Error>
pub fn set_x_offset(&mut self, offset: i8) -> Result<(), I::Error>
Set the X axis user offset value
§ARGUMENTS
offset: Two’s complement user offset value on X-axis data, used for wake-up function
sourcepub fn set_y_offset(&mut self, offset: i8) -> Result<(), I::Error>
pub fn set_y_offset(&mut self, offset: i8) -> Result<(), I::Error>
Set the Y axis user offset value
§ARGUMENTS
offset: Two’s complement user offset value on Y-axis data, used for wake-up function
sourcepub fn set_z_offset(&mut self, offset: i8) -> Result<(), I::Error>
pub fn set_z_offset(&mut self, offset: i8) -> Result<(), I::Error>
Set the Z axis user offset value
§ARGUMENTS
offset: Two’s complement user offset value on Z-axis data, used for wake-up function
sourcepub fn set_pulsed_interrupt_mode(
&mut self,
enable: bool,
) -> Result<(), I::Error>
pub fn set_pulsed_interrupt_mode( &mut self, enable: bool, ) -> Result<(), I::Error>
Switch between latched and pulsed mode for data ready interrupt
§ARGUMENTS
enable: Enable pulsed interrupt mode (true: enabled - pulsed mode, false: disabled - latched mode)
Disabled by default
sourcepub fn route_int2_to_int1(&mut self, enable: bool) -> Result<(), I::Error>
pub fn route_int2_to_int1(&mut self, enable: bool) -> Result<(), I::Error>
Route interrupts from INT2 pad to INT1
§ARGUMENTS
enabled: Enable routing (true: enabled - All signals available only on INT2 are routed to INT1, false: disabled)
Disabled by default
sourcepub fn enable_interrupts(&mut self, enable: bool) -> Result<(), I::Error>
pub fn enable_interrupts(&mut self, enable: bool) -> Result<(), I::Error>
Enable/Disable interrupts
§ARGUMENTS
enable: Enable interrupts (true: enabled, false: disabled)
Disabled by default
sourcepub fn enable_user_offset_on_wake_up(
&mut self,
enable: bool,
) -> Result<(), I::Error>
pub fn enable_user_offset_on_wake_up( &mut self, enable: bool, ) -> Result<(), I::Error>
Enable/Disable application of user offset values to wake-up function only
§ARGUMENTS
enable: Enable user offset values (true: enabled, false: disabled)
Disabled by default
sourcepub fn set_user_offset_weight(
&mut self,
high_weight: bool,
) -> Result<(), I::Error>
pub fn set_user_offset_weight( &mut self, high_weight: bool, ) -> Result<(), I::Error>
Set the weight of the user offset values
§ARGUMENTS
high_weight: true: 15.6 mg/LSB, false: 977 µg/LSB
Default value is 977 µg/LSB (false)
sourcepub fn enable_high_pass_filter_reference_mode(
&mut self,
enable: bool,
) -> Result<(), I::Error>
pub fn enable_high_pass_filter_reference_mode( &mut self, enable: bool, ) -> Result<(), I::Error>
Enable/Disable high-pass filter reference mode
§ARGUMENTS
enable: Enable high-pass filter reference mode (true: enabled, false: disabled)
Disabled by default
sourcepub fn enable_low_pass_filter_6d_interrupt(
&mut self,
enable: bool,
) -> Result<(), I::Error>
pub fn enable_low_pass_filter_6d_interrupt( &mut self, enable: bool, ) -> Result<(), I::Error>
Enable/Disable low-pass filter for 6D interrupt function
§ARGUMENTS
-
enable: Enable low-pass filtertrue: LPF2 output data sent to 6D interrupt function
false: OD2/2 low-pass filtered data sent to 6D interrupt function
Disabled by default