pub struct Lis2dh12<I2C> { /* private fields */ }
Expand description
LIS2DH12
driver
Implementations§
Source§impl<I2C: I2c> Lis2dh12<I2C>
impl<I2C: I2c> Lis2dh12<I2C>
Sourcepub fn new(i2c: I2C, addr: SlaveAddr) -> Result<Self, Error<I2C::Error>>
pub fn new(i2c: I2C, addr: SlaveAddr) -> Result<Self, Error<I2C::Error>>
Create a new LIS2DH12
driver from the given I2C
peripheral
Sourcepub fn set_mode(&mut self, mode: Mode) -> Result<(), Error<I2C::Error>>
pub fn set_mode(&mut self, mode: Mode) -> Result<(), Error<I2C::Error>>
Operating mode selection,
CTRL_REG1
: LPen
bit,
CTRL_REG4
: HR
bit
Sourcepub fn set_odr(&mut self, odr: Odr) -> Result<(), Error<I2C::Error>>
pub fn set_odr(&mut self, odr: Odr) -> Result<(), Error<I2C::Error>>
Data rate selection,
CTRL_REG1
: ODR
Sourcepub fn enable_axis(
&mut self,
(x, y, z): (bool, bool, bool),
) -> Result<(), Error<I2C::Error>>
pub fn enable_axis( &mut self, (x, y, z): (bool, bool, bool), ) -> Result<(), Error<I2C::Error>>
X,Y,Z-axis enable,
CTRL_REG1
: Xen
, Yen
, Zen
Sourcepub fn enable_hp_filter(
&mut self,
click: bool,
ia2: bool,
ia1: bool,
) -> Result<(), Error<I2C::Error>>
pub fn enable_hp_filter( &mut self, click: bool, ia2: bool, ia1: bool, ) -> Result<(), Error<I2C::Error>>
Enable high-pass filter for CLICK/IA2/IA1
Sourcepub fn enable_i1_click(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i1_click(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
CLICK
interrupt on INT1
pin,
CTRL_REG3
: I1_CLICK
Sourcepub fn enable_i1_ia1(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i1_ia1(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
IA1
interrupt on INT1
pin,
CTRL_REG3
: I1_IA1
Sourcepub fn enable_i1_ia2(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i1_ia2(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
IA2
interrupt on INT1
pin,
CTRL_REG3
: I1_IA2
Sourcepub fn enable_i1_zyxda(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i1_zyxda(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
ZYXDA
interrupt on INT1
pin,
CTRL_REG3
: I2_ZYXDA
Sourcepub fn enable_i1_wtm(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i1_wtm(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
FIFO watermark on INT1
pin,
CTRL_REG3
: I2_ZYXDA
Sourcepub fn get_stored_samples(&mut self) -> Result<u8, Error<I2C::Error>>
pub fn get_stored_samples(&mut self) -> Result<u8, Error<I2C::Error>>
Get the amount of samples currently stored in the FIFO queue
Sourcepub fn enable_i1_overrun(
&mut self,
enable: bool,
) -> Result<(), Error<I2C::Error>>
pub fn enable_i1_overrun( &mut self, enable: bool, ) -> Result<(), Error<I2C::Error>>
FIFO overrun on INT1
pin,
CTRL_REG3
: I1_OVERRUN
Sourcepub fn set_bdu(&mut self, bdu: bool) -> Result<(), Error<I2C::Error>>
pub fn set_bdu(&mut self, bdu: bool) -> Result<(), Error<I2C::Error>>
Block data update,
CTRL_REG4
: BDU
Sourcepub fn set_fs(&mut self, fs: FullScale) -> Result<(), Error<I2C::Error>>
pub fn set_fs(&mut self, fs: FullScale) -> Result<(), Error<I2C::Error>>
Full-scale selection,
CTRL_REG4
: FS
Sourcepub fn reboot(&mut self, reboot: bool) -> Result<(), Error<I2C::Error>>
pub fn reboot(&mut self, reboot: bool) -> Result<(), Error<I2C::Error>>
Reboot memory content,
CTRL_REG5
: BOOT
Sourcepub fn enable_fifo(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_fifo(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
FIFO enable,
CTRL_REG5
: FIFO_EN
Sourcepub fn enable_lir_int1(&mut self, latch: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_lir_int1(&mut self, latch: bool) -> Result<(), Error<I2C::Error>>
Latch interrupt request on INT1_SRC (31h),
with INT1_SRC (31h) register cleared by reading INT1_SRC (31h) itself,
CTRL_REG5
: LIR_INT1
Sourcepub fn enable_d4d_int1(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_d4d_int1(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
4D enable: 4D detection is enabled on INT1 pin
when 6D bit on INT1_CFG (30h) is set to 1,
CTRL_REG5
: D4D_INT1
Sourcepub fn enable_lir_int2(&mut self, latch: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_lir_int2(&mut self, latch: bool) -> Result<(), Error<I2C::Error>>
Latch interrupt request on INT2_SRC (35h) register,
with INT2_SRC (35h) register cleared by reading INT2_SRC (35h) itself,
CTRL_REG5
: LIR_INT2
Sourcepub fn enable_d4d_int2(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_d4d_int2(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
4D enable: 4D detection is enabled on INT2 pin
when 6D bit on INT2_CFG (34h) is set to 1,
CTRL_REG5
: D4D_INT2
Sourcepub fn enable_i2_click(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i2_click(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
CLICK
interrupt on INT2
pin,
CTRL_REG6
: I2_CLICK
Sourcepub fn enable_i2_ia1(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i2_ia1(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
IA1
interrupt on INT2
pin,
CTRL_REG6
: I2_IA1
Sourcepub fn enable_i2_ia2(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i2_ia2(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
IA2
interrupt on INT2
pin,
CTRL_REG6
: I2_IA2
Sourcepub fn enable_i2_boot(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i2_boot(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
Boot interrupt on INT2
pin,
CTRL_REG6
: I2_BOOT
Sourcepub fn enable_i2_act(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_i2_act(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
Activity interrupt on INT2
pin,
CTRL_REG6
: I2_ACT
Sourcepub fn set_int_polarity(
&mut self,
active_low: bool,
) -> Result<(), Error<I2C::Error>>
pub fn set_int_polarity( &mut self, active_low: bool, ) -> Result<(), Error<I2C::Error>>
INT1/INT2 pin polarity,
CTRL_REG6
: INT_POLARITY
Sourcepub fn get_status(&mut self) -> Result<DataStatus, Error<I2C::Error>>
pub fn get_status(&mut self) -> Result<DataStatus, Error<I2C::Error>>
Data status,
STATUS_REG
: as
DataStatus {zyxor: ZYXOR
, xyzor: (XOR
, YOR
, ZOR
), zyxda: ZYXDA
, xyzda: (XDA
, YDA
, ZDA
)}
Sourcepub fn set_fm(&mut self, fm: FifoMode) -> Result<(), Error<I2C::Error>>
pub fn set_fm(&mut self, fm: FifoMode) -> Result<(), Error<I2C::Error>>
FIFO mode selection,
FIFO_CTRL_REG
: FM
Sourcepub fn set_fth(&mut self, fth: u8) -> Result<(), Error<I2C::Error>>
pub fn set_fth(&mut self, fth: u8) -> Result<(), Error<I2C::Error>>
FIFO threshold,
FIFO_CTRL_REG
: FTH
Sourcepub fn disable_click(&mut self) -> Result<(), Error<I2C::Error>>
pub fn disable_click(&mut self) -> Result<(), Error<I2C::Error>>
Disable click interrupt,
CLICK_CFG
clean all bits
Sourcepub fn enable_double_click(
&mut self,
(x, y, z): (bool, bool, bool),
) -> Result<(), Error<I2C::Error>>
pub fn enable_double_click( &mut self, (x, y, z): (bool, bool, bool), ) -> Result<(), Error<I2C::Error>>
Enable interrupt double-click on X,Y,Z axis,
CLICK_CFG
: XD
, YD
, ZD
Sourcepub fn enable_single_click(
&mut self,
(x, y, z): (bool, bool, bool),
) -> Result<(), Error<I2C::Error>>
pub fn enable_single_click( &mut self, (x, y, z): (bool, bool, bool), ) -> Result<(), Error<I2C::Error>>
Enable interrupt single-click on X,Y,Z axis,
CLICK_CFG
: XS
, YS
, ZS
Sourcepub fn get_click_src(
&mut self,
) -> Result<Option<((bool, bool), bool, (bool, bool, bool))>, Error<I2C::Error>>
pub fn get_click_src( &mut self, ) -> Result<Option<((bool, bool), bool, (bool, bool, bool))>, Error<I2C::Error>>
Click source,
CLICK_SRC
decoded as ((DClick
, SClick
), Sign
, (X
, Y
, Z
))
Sourcepub fn enable_lir_click(&mut self, latch: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_lir_click(&mut self, latch: bool) -> Result<(), Error<I2C::Error>>
If the LIR_Click bit is not set, the interrupt is kept high
for the duration of the latency window.
If the LIR_Click bit is set, the interrupt is kept high
until the CLICK_SRC (39h) register is read.
CLICK_THS
: LIR_Click
Sourcepub fn set_click_ths(&mut self, ths: u8) -> Result<(), Error<I2C::Error>>
pub fn set_click_ths(&mut self, ths: u8) -> Result<(), Error<I2C::Error>>
Click threshold,
CLICK_THS
: Ths
Sourcepub fn set_click_thsf(&mut self, ths: f32) -> Result<(), Error<I2C::Error>>
pub fn set_click_thsf(&mut self, ths: f32) -> Result<(), Error<I2C::Error>>
Click threshold as f32,
CLICK_THS
: Ths
Sourcepub fn set_time_limit(&mut self, tli: u8) -> Result<(), Error<I2C::Error>>
pub fn set_time_limit(&mut self, tli: u8) -> Result<(), Error<I2C::Error>>
Click time limit,
TIME_LIMIT
: TLI
Sourcepub fn set_time_latency(&mut self, tla: u8) -> Result<(), Error<I2C::Error>>
pub fn set_time_latency(&mut self, tla: u8) -> Result<(), Error<I2C::Error>>
Click time latency,
TIME_LATENCY
: TLA
Sourcepub fn set_time_window(&mut self, tw: u8) -> Result<(), Error<I2C::Error>>
pub fn set_time_window(&mut self, tw: u8) -> Result<(), Error<I2C::Error>>
Click time window,
TIME_WINDOW
: TW
Sourcepub fn set_act_ths(&mut self, ths: u8) -> Result<(), Error<I2C::Error>>
pub fn set_act_ths(&mut self, ths: u8) -> Result<(), Error<I2C::Error>>
Sleep-to-wake, return-to-sleep activation threshold in low-power mode,
ACT_THS
: Acth
Sourcepub fn set_act_thsf(&mut self, ths: f32) -> Result<(), Error<I2C::Error>>
pub fn set_act_thsf(&mut self, ths: f32) -> Result<(), Error<I2C::Error>>
Sleep-to-wake, return-to-sleep activation threshold as f32,
ACT_THS
: Acth
Sourcepub fn set_act_dur(&mut self, d: u8) -> Result<(), Error<I2C::Error>>
pub fn set_act_dur(&mut self, d: u8) -> Result<(), Error<I2C::Error>>
Sleep-to-wake, return-to-sleep duration,
ACT_DUR
: ActD
Sourcepub fn enable_temp(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_temp(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
Temperature sensor enable,
TEMP_CFG_REG
: TEMP_EN
,
the BDU
bit in CTRL_REG4
is also set
Sourcepub fn get_temp_status(&mut self) -> Result<(bool, bool), Error<I2C::Error>>
pub fn get_temp_status(&mut self) -> Result<(bool, bool), Error<I2C::Error>>
Temperature data status,
STATUS_REG_AUX
: TOR
- Temperature data overrun,
TDA
- Temperature new data available
Sourcepub fn get_temp_out(&mut self) -> Result<(i8, u8), Error<I2C::Error>>
pub fn get_temp_out(&mut self) -> Result<(i8, u8), Error<I2C::Error>>
Temperature sensor data,
OUT_TEMP_H
, OUT_TEMP_L
Sourcepub fn get_temp_outf(&mut self) -> Result<f32, Error<I2C::Error>>
pub fn get_temp_outf(&mut self) -> Result<f32, Error<I2C::Error>>
Temperature sensor data as float,
OUT_TEMP_H
, OUT_TEMP_L
converted to f32
Sourcepub fn enable_st0(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
pub fn enable_st0(&mut self, enable: bool) -> Result<(), Error<I2C::Error>>
Enable self test 0, this shouldn’t be enabled at the same time as self test 1