iis2dlpc_rs/register/main.rs
1use super::super::{
2 BusOperation, DelayNs, Error, Iis2dlpc, RegisterOperation, SensorOperation, bisync,
3 register::OnState,
4};
5
6use bitfield_struct::bitfield;
7use derive_more::TryFrom;
8use st_mem_bank_macro::register;
9
10/// IIS2DLPC Register Map.
11///
12/// This enum represents the memory-mapped registers of the IIS2DLPC sensor. Each variant corresponds to a specific register address.
13#[repr(u8)]
14#[derive(Clone, Copy, PartialEq)]
15pub enum Reg {
16 /// Temperature output register (low byte).
17 OutTL = 0x0D,
18
19 /// Temperature output register (high byte).
20 OutTH = 0x0E,
21
22 /// Who Am I register.
23 ///
24 /// This register is read-only and contains the device ID. Default value: `0x44`.
25 WhoAmI = 0x0F,
26
27 /// Control register 1.
28 Ctrl1 = 0x20,
29
30 /// Control register 2.
31 Ctrl2 = 0x21,
32
33 /// Control register 3.
34 Ctrl3 = 0x22,
35
36 /// Control register 4 for INT1 pad control.
37 Ctrl4Int1PadCtrl = 0x23,
38
39 /// Control register 5 for INT2 pad control.
40 Ctrl5Int2PadCtrl = 0x24,
41
42 /// Control register 6.
43 Ctrl6 = 0x25,
44
45 /// Temperature output register (8-bit resolution).
46 OutT = 0x26,
47
48 /// Status register.
49 Status = 0x27,
50
51 /// X-axis output register (low byte).
52 OutXL = 0x28,
53
54 /// X-axis output register (high byte).
55 OutXH = 0x29,
56
57 /// Y-axis output register (low byte).
58 OutYL = 0x2A,
59
60 /// Y-axis output register (high byte).
61 OutYH = 0x2B,
62
63 /// Z-axis output register (low byte).
64 OutZL = 0x2C,
65
66 /// Z-axis output register (high byte).
67 OutZH = 0x2D,
68
69 /// FIFO control register.
70 FifoCtrl = 0x2E,
71
72 /// FIFO samples register.
73 FifoSamples = 0x2F,
74
75 /// TAP threshold configuration for the X-axis.
76 TapThsX = 0x30,
77
78 /// TAP threshold configuration for the Y-axis.
79 TapThsY = 0x31,
80
81 /// TAP threshold configuration for the Z-axis.
82 TapThsZ = 0x32,
83
84 /// Interrupt duration configuration.
85 IntDur = 0x33,
86
87 /// Wakeup threshold configuration.
88 WakeUpThs = 0x34,
89
90 /// Wakeup duration configuration.
91 WakeUpDur = 0x35,
92
93 /// Free-fall configuration.
94 FreeFall = 0x36,
95
96 /// Status duplicate register.
97 StatusDup = 0x37,
98
99 /// Wakeup source register.
100 WakeUpSrc = 0x38,
101
102 /// Tap source register.
103 TapSrc = 0x39,
104
105 /// 6D source register.
106 SixdSrc = 0x3A,
107
108 /// All interrupt source register.
109 AllIntSrc = 0x3B,
110
111 /// X-axis user offset register.
112 XOfsUsr = 0x3C,
113
114 /// Y-axis user offset register.
115 YOfsUsr = 0x3D,
116
117 /// Z-axis user offset register.
118 ZOfsUsr = 0x3E,
119
120 /// Control register 7.
121 Ctrl7 = 0x3F,
122}
123
124/// Temperature output register (12-bit resolution, read-only).
125///
126/// The `OutT` register contains the raw temperature sensor output as a 12-bit two's complement value.
127/// The temperature data is left-justified within the 16-bit register.
128///
129/// The bit order for this struct can be configured using the `bit_order_msb` feature:
130/// * `Msb`: Most significant bit first.
131/// * `Lsb`: Least significant bit first (default).
132#[register(address = Reg::OutTL, access_type = "Iis2dlpc<B, T, OnState>")]
133#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
134#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
135pub struct OutT {
136 #[bits(4, access = RO, default = 0)]
137 not_used: u8,
138 /// Temperature sensor output value.
139 #[bits(12, access = RO, default = 0)]
140 pub temp: i16,
141}
142
143/// Control register 1 (R/W).
144///
145/// The `CTRL1` register is used to configure the operating mode, low-power mode, and output data rate (ODR) of the IIS2DLPC sensor.
146///
147/// The bit order for this struct can be configured using the `bit_order_msb` feature:
148/// * `Msb`: Most significant bit first.
149/// * `Lsb`: Least significant bit first (default).
150#[register(address = Reg::Ctrl1, access_type = "Iis2dlpc<B, T, OnState>")]
151#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
152#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
153pub struct Ctrl1 {
154 /// Low-power mode selection.
155 ///
156 /// Configures the low-power mode.
157 ///
158 /// Default value: `0`.
159 #[bits(2, default = 0)]
160 pub lp_mode: u8,
161
162 /// Mode selection.
163 ///
164 /// Configures the operating mode of the sensor.
165 ///
166 /// Default value: `0`.
167 #[bits(2, default = 0)]
168 pub mode: u8,
169
170 /// Output data rate (ODR) selection.
171 ///
172 /// Configures the output data rate and power mode.
173 ///
174 /// Default value: `0`.
175 #[bits(4, default = 0)]
176 pub odr: u8,
177}
178
179/// Control register 2 (R/W).
180///
181/// The `CTRL2` register is used to configure the SPI interface mode, I²C disable, address increment, block data update, and other settings.
182///
183/// The bit order for this struct can be configured using the `bit_order_msb` feature:
184/// * `Msb`: Most significant bit first.
185/// * `Lsb`: Least significant bit first (default).
186#[register(address = Reg::Ctrl2, access_type = "Iis2dlpc<B, T, OnState>")]
187#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
188#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
189pub struct Ctrl2 {
190 /// SPI serial interface mode selection.
191 ///
192 /// Configures the SPI interface mode:
193 /// * `0`: 4-wire interface.
194 /// * `1`: 3-wire interface.
195 ///
196 /// Default value: `0`.
197 #[bits(1, default = 0)]
198 pub sim: u8,
199
200 /// I²C disable.
201 ///
202 /// Disables the I²C communication protocol:
203 /// * `0`: SPI and I²C interfaces enabled.
204 /// * `1`: I²C mode disabled.
205 ///
206 /// Default value: `0`.
207 #[bits(1, default = 0)]
208 pub i2c_disable: u8,
209
210 /// Register address auto-increment.
211 ///
212 /// Enables automatic increment of the register address during multiple byte access:
213 /// * `0`: Disabled.
214 /// * `1`: Enabled.
215 ///
216 /// Default value: `1`.
217 #[bits(1, default = 1)]
218 pub if_add_inc: u8,
219
220 /// Block data update.
221 ///
222 /// Configures the update behavior of output registers:
223 /// * `0`: Continuous update.
224 /// * `1`: Output registers not updated until MSB and LSB are read.
225 ///
226 /// Default value: `0`.
227 #[bits(1, default = 0)]
228 pub bdu: u8,
229
230 /// Disconnect CS pull-up.
231 ///
232 /// Configures the pull-up resistor on the CS pin:
233 /// * `0`: Pull-up connected to CS pin.
234 /// * `1`: Pull-up disconnected from CS pin.
235 ///
236 /// Default value: `0`.
237 #[bits(1, default = 0)]
238 pub cs_pu_disc: u8,
239
240 #[bits(1, access = RO, default = 0)]
241 not_used_01: u8,
242
243 /// Soft reset.
244 ///
245 /// Resets all control registers:
246 /// * `0`: Disabled.
247 /// * `1`: Enabled.
248 ///
249 /// Default value: `0`.
250 #[bits(1, default = 0)]
251 pub soft_reset: u8,
252
253 /// Boot.
254 ///
255 /// Retrieves the correct trimming parameters from nonvolatile memory:
256 /// * `0`: Disabled.
257 /// * `1`: Enabled.
258 ///
259 /// Default value: `0`.
260 #[bits(1, default = 0)]
261 pub boot: u8,
262}
263
264/// Control register 3 (R/W).
265///
266/// The `CTRL3` register is used to configure interrupt polarity, interrupt latching, push-pull/open-drain selection, self-test mode, and single data conversion on demand mode.
267///
268/// The bit order for this struct can be configured using the `bit_order_msb` feature:
269/// * `Msb`: Most significant bit first.
270/// * `Lsb`: Least significant bit first (default).
271#[register(address = Reg::Ctrl3, access_type = "Iis2dlpc<B, T, OnState>")]
272#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
273#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
274pub struct Ctrl3 {
275 /// Single data conversion on demand mode configuration.
276 ///
277 /// This field combines two subfields:
278 /// - `slp_mode_sel`: Determines the trigger source for single data conversion:
279 /// - `0`: External trigger on INT2.
280 /// - `1`: Triggered by writing `slp_mode_1` to `1` via I²C/SPI.
281 /// - `slp_mode_1`: Starts the single data conversion on demand mode when set to `1`.
282 /// This bit is automatically reset to `0` when the data is available, and the device is ready for another triggered session.
283 ///
284 /// Default value: `0`.
285 #[bits(2, default = 0)]
286 pub slp_mode: u8,
287
288 #[bits(1, access = RO, default = 0)]
289 not_used_01: u8,
290
291 /// Interrupt active level.
292 ///
293 /// Configures the active level of interrupts:
294 /// * `0`: Active high.
295 /// * `1`: Active low.
296 ///
297 /// Default value: `0`.
298 #[bits(1, default = 0)]
299 pub h_lactive: u8,
300
301 /// Latched interrupt.
302 ///
303 /// Configures the interrupt mode:
304 /// * `0`: Pulsed mode.
305 /// * `1`: Latched mode.
306 ///
307 /// Default value: `0`.
308 #[bits(1, default = 0)]
309 pub lir: u8,
310
311 /// Push-pull/open-drain selection.
312 ///
313 /// Configures the interrupt pad type:
314 /// * `0`: Push-pull.
315 /// * `1`: Open-drain.
316 #[bits(1, default = 0)]
317 pub pp_od: u8,
318
319 /// Self-test mode selection.
320 ///
321 /// Configures the self-test mode. Refer to the datasheet for the available self-test modes.
322 ///
323 /// Default value: `0`.
324 #[bits(2, default = 0)]
325 pub st: u8,
326}
327
328/// Control register 4 (R/W).
329///
330/// The `CTRL4_INT1_PAD_CTRL` register is used to configure the interrupt signals routed to the INT1 pad.
331///
332/// The bit order for this struct can be configured using the `bit_order_msb` feature:
333/// * `Msb`: Most significant bit first.
334/// * `Lsb`: Least significant bit first (default).
335#[register(address = Reg::Ctrl4Int1PadCtrl, access_type = "Iis2dlpc<B, T, OnState>")]
336#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
337#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
338pub struct Ctrl4Int1PadCtrl {
339 /// Data-ready interrupt routed to INT1 pad.
340 ///
341 /// Default value: `0`.
342 #[bits(1, default = 0)]
343 pub int1_drdy: u8,
344
345 /// FIFO threshold interrupt routed to INT1 pad.
346 ///
347 /// Default value: `0`.
348 #[bits(1, default = 0)]
349 pub int1_fth: u8,
350
351 /// FIFO full interrupt routed to INT1 pad.
352 ///
353 /// Default value: `0`.
354 #[bits(1, default = 0)]
355 pub int1_diff5: u8,
356
357 /// Double-tap interrupt routed to INT1 pad.
358 ///
359 /// Default value: `0`.
360 #[bits(1, default = 0)]
361 pub int1_tap: u8,
362
363 /// Free-fall interrupt routed to INT1 pad.
364 ///
365 /// Default value: `0`.
366 #[bits(1, default = 0)]
367 pub int1_ff: u8,
368
369 /// Wakeup interrupt routed to INT1 pad.
370 ///
371 /// Default value: `0`.
372 #[bits(1, default = 0)]
373 pub int1_wu: u8,
374
375 /// Single-tap interrupt routed to INT1 pad.
376 ///
377 /// Default value: `0`.
378 #[bits(1, default = 0)]
379 pub int1_single_tap: u8,
380
381 /// 6D recognition interrupt routed to INT1 pad.
382 ///
383 /// Default value: `0`.
384 #[bits(1, default = 0)]
385 pub int1_6d: u8,
386}
387
388/// Control register 5 (R/W).
389///
390/// The `CTRL5_INT2_PAD_CTRL` register is used to configure the interrupt signals routed to the INT2 pad.
391///
392/// The bit order for this struct can be configured using the `bit_order_msb` feature:
393/// * `Msb`: Most significant bit first.
394/// * `Lsb`: Least significant bit first (default).
395#[register(address = Reg::Ctrl5Int2PadCtrl, access_type = "Iis2dlpc<B, T, OnState>")]
396#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
397#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
398pub struct Ctrl5Int2PadCtrl {
399 /// Data-ready interrupt routed to INT2 pad.
400 ///
401 /// Default value: `0`.
402 #[bits(1, default = 0)]
403 pub int2_drdy: u8,
404
405 /// FIFO threshold interrupt routed to INT2 pad.
406 ///
407 /// Default value: `0`.
408 #[bits(1, default = 0)]
409 pub int2_fth: u8,
410
411 /// FIFO full interrupt routed to INT2 pad.
412 ///
413 /// Default value: `0`.
414 #[bits(1, default = 0)]
415 pub int2_diff5: u8,
416
417 /// FIFO overrun interrupt routed to INT2 pad.
418 ///
419 /// Default value: `0`.
420 #[bits(1, default = 0)]
421 pub int2_ovr: u8,
422
423 /// Temperature data-ready interrupt routed to INT2 pad.
424 ///
425 /// Default value: `0`.
426 #[bits(1, default = 0)]
427 pub int2_drdy_t: u8,
428
429 /// Boot status routed to INT2 pad.
430 ///
431 /// Default value: `0`.
432 #[bits(1, default = 0)]
433 pub int2_boot: u8,
434
435 /// Sleep change status routed to INT2 pad.
436 ///
437 /// Default value: `0`.
438 #[bits(1, default = 0)]
439 pub int2_sleep_chg: u8,
440
441 /// Sleep state status routed to INT2 pad.
442 ///
443 /// Default value: `0`.
444 #[bits(1, default = 0)]
445 pub int2_sleep_state: u8,
446}
447
448/// Control register 6 (R/W).
449///
450/// The `CTRL6` register is used to configure the low-noise mode, filter settings, full-scale selection, and bandwidth selection.
451///
452/// The bit order for this struct can be configured using the `bit_order_msb` feature:
453/// * `Msb`: Most significant bit first.
454/// * `Lsb`: Least significant bit first (default).
455#[register(address = Reg::Ctrl6, access_type = "Iis2dlpc<B, T, OnState>")]
456#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
457#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
458pub struct Ctrl6 {
459 #[bits(2, access = RO, default = 0)]
460 not_used_01: u8,
461
462 /// Low-noise mode enable.
463 ///
464 /// Configures the low-noise mode:
465 /// * `0`: Disabled.
466 /// * `1`: Enabled.
467 ///
468 /// Default value: `0`.
469 #[bits(1, default = 0)]
470 pub low_noise: u8,
471
472 /// Filtered data selection.
473 ///
474 /// Configures the data path:
475 /// * `0`: Low-pass filter path selected.
476 /// * `1`: High-pass filter path selected.
477 ///
478 /// Default value: `0`.
479 #[bits(1, default = 0)]
480 pub fds: u8,
481
482 /// Full-scale selection.
483 ///
484 /// Configures the measurement range:
485 /// * `00`: ±2 g.
486 /// * `01`: ±4 g.
487 /// * `10`: ±8 g.
488 /// * `11`: ±16 g.
489 ///
490 /// Default value: `0`.
491 #[bits(2, default = 0)]
492 pub fs: u8,
493
494 /// Bandwidth selection.
495 ///
496 /// Configures the bandwidth of the filter:
497 /// * `00`: ODR/2.
498 /// * `01`: ODR/4.
499 /// * `10`: ODR/10.
500 /// * `11`: ODR/20.
501 ///
502 /// Default value: `0`.
503 #[bits(2, default = 0)]
504 pub bw_filt: u8,
505}
506
507/// Status register (R).
508///
509/// The `STATUS` register provides the status of various events detected by the IIS2DLPC sensor.
510///
511/// The bit order for this struct can be configured using the `bit_order_msb` feature:
512/// * `Msb`: Most significant bit first.
513/// * `Lsb`: Least significant bit first (default).
514#[register(address = Reg::Status, access_type = "Iis2dlpc<B, T, OnState>")]
515#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
516#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
517pub struct Status {
518 /// Data-ready status.
519 ///
520 /// Indicates whether new data is available:
521 /// * `0`: Not ready.
522 /// * `1`: X-, Y-, and Z-axis new data available.
523 ///
524 /// Default value: `0`.
525 #[bits(1, default = 0, access = RO)]
526 pub drdy: u8,
527
528 /// Free-fall event detection status.
529 ///
530 /// Indicates whether a free-fall event has been detected:
531 /// * `0`: Free-fall event not detected.
532 /// * `1`: Free-fall event detected.
533 ///
534 /// Default value: `0`.
535 #[bits(1, default = 0, access = RO)]
536 pub ff_ia: u8,
537
538 /// 6D recognition event status.
539 ///
540 /// Indicates whether a change in position (portrait/landscape/face-up/face-down) has been detected:
541 /// * `0`: No event detected.
542 /// * `1`: A change in position detected.
543 ///
544 /// Default value: `0`.
545 #[bits(1, default = 0, access = RO)]
546 pub six_d_ia: u8,
547
548 /// Single-tap event status.
549 ///
550 /// Indicates whether a single-tap event has been detected:
551 /// * `0`: Single-tap event not detected.
552 /// * `1`: Single-tap event detected.
553 ///
554 /// Default value: `0`.
555 #[bits(1, default = 0, access = RO)]
556 pub single_tap: u8,
557
558 /// Double-tap event status.
559 ///
560 /// Indicates whether a double-tap event has been detected:
561 /// * `0`: Double-tap event not detected.
562 /// * `1`: Double-tap event detected.
563 ///
564 /// Default value: `0`.
565 #[bits(1, default = 0, access = RO)]
566 pub double_tap: u8,
567
568 /// Sleep state status.
569 ///
570 /// Indicates whether the device is in a sleep state:
571 /// * `0`: Sleep event not detected.
572 /// * `1`: Sleep event detected.
573 ///
574 /// Default value: `0`.
575 #[bits(1, default = 0, access = RO)]
576 pub sleep_state: u8,
577
578 /// Wakeup event detection status.
579 ///
580 /// Indicates whether a wakeup event has been detected:
581 /// * `0`: Wakeup event not detected.
582 /// * `1`: Wakeup event detected.
583 ///
584 /// Default value: `0`.
585 #[bits(1, default = 0, access = RO)]
586 pub wu_ia: u8,
587
588 /// FIFO threshold status.
589 ///
590 /// Indicates whether the FIFO filling is equal to or higher than the threshold level:
591 /// * `0`: FIFO filling is lower than the threshold level.
592 /// * `1`: FIFO filling is equal to or higher than the threshold level.
593 ///
594 /// Default value: `0`.
595 #[bits(1, default = 0, access = RO)]
596 pub fifo_ths: u8,
597}
598
599/// X-axis accelerometer output register (14-bit resolution, read-only).
600///
601/// The `OutX` register contains the raw acceleration data for the X-axis as a 14-bit two's complement value.
602/// The data is left-justified within the 16-bit register, with 2 unused bits.
603///
604/// The bit order for this struct can be configured using the `bit_order_msb` feature:
605/// * `Msb`: Most significant bit first.
606/// * `Lsb`: Least significant bit first (default).
607#[register(address = Reg::OutXL, access_type = "Iis2dlpc<B, T, OnState>")]
608#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
609#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
610pub struct OutX {
611 #[bits(2, access = RO, default = 0)]
612 not_used: u8,
613 /// Raw acceleration data for the X-axis.
614 #[bits(14, access = RO, default = 0)]
615 pub x: i16,
616}
617
618/// Y-axis accelerometer output register (14-bit resolution, read-only).
619///
620/// The `OutY` register contains the raw acceleration data for the Y-axis as a 14-bit two's complement value.
621/// The data is left-justified within the 16-bit register, with 2 unused bits.
622///
623/// The bit order for this struct can be configured using the `bit_order_msb` feature:
624/// * `Msb`: Most significant bit first.
625/// * `Lsb`: Least significant bit first (default).
626#[register(address = Reg::OutYL, access_type = "Iis2dlpc<B, T, OnState>")]
627#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
628#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
629pub struct OutY {
630 #[bits(2, access = RO, default = 0)]
631 not_used: u8,
632 /// Raw acceleration data for the Y-axis.
633 #[bits(14, access = RO, default = 0)]
634 pub y: i16,
635}
636
637/// Z-axis accelerometer output register (14-bit resolution, read-only).
638///
639/// The `OutZ` register contains the raw acceleration data for the Z-axis as a 14-bit two's complement value.
640/// The data is left-justified within the 16-bit register, with 2 unused bits.
641///
642/// The bit order for this struct can be configured using the `bit_order_msb` feature:
643/// * `Msb`: Most significant bit first.
644/// * `Lsb`: Least significant bit first (default).
645#[register(address = Reg::OutZL, access_type = "Iis2dlpc<B, T, OnState>")]
646#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
647#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
648pub struct OutZ {
649 #[bits(2, access = RO, default = 0)]
650 not_used: u8,
651 /// Raw acceleration data for the Z-axis.
652 #[bits(14, access = RO, default = 0)]
653 pub z: i16,
654}
655
656/// FIFO control register (R/W).
657///
658/// The `FIFO_CTRL` register is used to configure the FIFO threshold level and mode.
659///
660/// The bit order for this struct can be configured using the `bit_order_msb` feature:
661/// * `Msb`: Most significant bit first.
662/// * `Lsb`: Least significant bit first (default).
663#[register(address = Reg::FifoCtrl, access_type = "Iis2dlpc<B, T, OnState>")]
664#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
665#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
666pub struct FifoCtrl {
667 /// FIFO threshold level.
668 ///
669 /// Configures the FIFO threshold level. The value is a 5-bit unsigned integer.
670 ///
671 /// Default value: `0`.
672 #[bits(5, default = 0)]
673 pub fth: u8,
674
675 /// FIFO mode selection.
676 ///
677 /// Configures the FIFO operating mode:
678 /// * `000`: Bypass mode.
679 /// * `001`: FIFO mode.
680 /// * `011`: Continuous-to-FIFO mode.
681 /// * `100`: Bypass-to-Continuous mode.
682 /// * `110`: Continuous mode.
683 ///
684 /// Default value: `0`.
685 #[bits(3, default = 0)]
686 pub fmode: u8,
687}
688
689/// FIFO samples register (R).
690///
691/// The `FIFO_SAMPLES` register provides the status of the FIFO, including the number of unread samples and overflow/threshold flags.
692///
693/// The bit order for this struct can be configured using the `bit_order_msb` feature:
694/// * `Msb`: Most significant bit first.
695/// * `Lsb`: Least significant bit first (default).
696#[register(address = Reg::FifoSamples, access_type = "Iis2dlpc<B, T, OnState>")]
697#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
698#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
699pub struct FifoSamples {
700 /// Number of unread samples in FIFO.
701 ///
702 /// Represents the number of unread samples stored in the FIFO. The value is a 6-bit unsigned integer.
703 ///
704 /// Default value: `0`.
705 #[bits(6, default = 0, access = RO)]
706 pub diff: u8,
707
708 /// FIFO overrun status.
709 ///
710 /// Indicates whether the FIFO is full and at least one sample has been overwritten:
711 /// * `0`: FIFO is not completely filled.
712 /// * `1`: FIFO is completely filled and at least one sample has been overwritten.
713 ///
714 /// Default value: `0`.
715 #[bits(1, default = 0, access = RO)]
716 pub fifo_ovr: u8,
717
718 /// FIFO threshold status.
719 ///
720 /// Indicates whether the FIFO filling is equal to or higher than the threshold level:
721 /// * `0`: FIFO filling is lower than the threshold level.
722 /// * `1`: FIFO filling is equal to or higher than the threshold level.
723 ///
724 /// Default value: `0`.
725 #[bits(1, default = 0, access = RO)]
726 pub fifo_fth: u8,
727}
728
729/// TAP threshold configuration for the X-axis (R/W).
730///
731/// The `TAP_THS_X` register is used to configure the tap threshold for the X-axis, 6D threshold, and 4D detection enable.
732///
733/// The bit order for this struct can be configured using the `bit_order_msb` feature:
734/// * `Msb`: Most significant bit first.
735/// * `Lsb`: Least significant bit first (default).
736#[register(address = Reg::TapThsX, access_type = "Iis2dlpc<B, T, OnState>")]
737#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
738#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
739pub struct TapThsX {
740 /// Tap threshold for the X-axis.
741 ///
742 /// Default value: `0`.
743 #[bits(5, default = 0)]
744 pub tap_thsx: u8,
745
746 /// 6D threshold.
747 ///
748 /// Configures the threshold for 6D detection.
749 ///
750 /// Default value: `0`.
751 #[bits(2, default = 0)]
752 pub six_d_ths: u8,
753
754 /// 4D detection enable.
755 ///
756 /// Enables 4D detection:
757 /// * `0`: Disabled.
758 /// * `1`: Enabled.
759 ///
760 /// Default value: `0`.
761 #[bits(1, default = 0)]
762 pub four_d_en: u8,
763}
764
765/// TAP threshold configuration for the Y-axis (R/W).
766///
767/// The `TAP_THS_Y` register is used to configure the tap threshold for the Y-axis and the axis priority for tap detection.
768///
769/// The bit order for this struct can be configured using the `bit_order_msb` feature:
770/// * `Msb`: Most significant bit first.
771/// * `Lsb`: Least significant bit first (default).
772#[register(address = Reg::TapThsY, access_type = "Iis2dlpc<B, T, OnState>")]
773#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
774#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
775pub struct TapThsY {
776 /// Tap threshold for the Y-axis.
777 ///
778 /// Default value: `0`.
779 #[bits(5, default = 0)]
780 pub tap_thsy: u8,
781
782 /// Axis priority for tap detection.
783 ///
784 /// Configures the priority of axes for tap detection.
785 ///
786 /// Default value: `0`.
787 #[bits(3, default = 0)]
788 pub tap_prior: u8,
789}
790
791/// TAP threshold configuration for the Z-axis (R/W).
792///
793/// The `TAP_THS_Z` register is used to configure the tap threshold for the Z-axis and enable tap detection on specific axes.
794///
795/// The bit order for this struct can be configured using the `bit_order_msb` feature:
796/// * `Msb`: Most significant bit first.
797/// * `Lsb`: Least significant bit first (default).
798#[register(address = Reg::TapThsZ, access_type = "Iis2dlpc<B, T, OnState>")]
799#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
800#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
801pub struct TapThsZ {
802 /// Tap threshold for the Z-axis.
803 ///
804 /// Default value: `0`.
805 #[bits(5, default = 0)]
806 pub tap_thsz: u8,
807
808 /// Enable tap detection on the Z-axis.
809 ///
810 /// Default value: `0`.
811 #[bits(1, default = 0)]
812 pub tap_z_en: u8,
813
814 /// Enable tap detection on the Y-axis.
815 ///
816 /// Default value: `0`.
817 #[bits(1, default = 0)]
818 pub tap_y_en: u8,
819
820 /// Enable tap detection on the X-axis.
821 ///
822 /// Default value: `0`.
823 #[bits(1, default = 0)]
824 pub tap_x_en: u8,
825}
826
827/// Interrupt duration configuration (R/W).
828///
829/// The `INT_DUR` register is used to configure the shock, quiet, and latency durations for tap detection.
830///
831/// The bit order for this struct can be configured using the `bit_order_msb` feature:
832/// * `Msb`: Most significant bit first.
833/// * `Lsb`: Least significant bit first (default).
834#[register(address = Reg::IntDur, access_type = "Iis2dlpc<B, T, OnState>")]
835#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
836#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
837pub struct IntDur {
838 /// Shock duration.
839 ///
840 /// Default value: `0`.
841 #[bits(2, default = 0)]
842 pub shock: u8,
843
844 /// Quiet duration.
845 ///
846 /// Default value: `0`.
847 #[bits(2, default = 0)]
848 pub quiet: u8,
849
850 /// Latency duration.
851 ///
852 /// Default value: `0`.
853 #[bits(4, default = 0)]
854 pub latency: u8,
855}
856
857/// Wakeup threshold configuration (R/W).
858///
859/// The `WAKE_UP_THS` register is used to configure the wakeup threshold, sleep enable, and single/double-tap enable.
860///
861/// The bit order for this struct can be configured using the `bit_order_msb` feature:
862/// * `Msb`: Most significant bit first.
863/// * `Lsb`: Least significant bit first (default).
864#[register(address = Reg::WakeUpThs, access_type = "Iis2dlpc<B, T, OnState>")]
865#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
866#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
867pub struct WakeUpThs {
868 /// Wakeup threshold.
869 ///
870 /// Default value: `0`.
871 #[bits(6, default = 0)]
872 pub wk_ths: u8,
873
874 /// Sleep enable.
875 ///
876 /// Default value: `0`.
877 #[bits(1, default = 0)]
878 pub sleep_on: u8,
879
880 /// Single/double-tap enable.
881 ///
882 /// Default value: `0`.
883 #[bits(1, default = 0)]
884 pub single_double_tap: u8,
885}
886
887/// Wakeup duration configuration (R/W).
888///
889/// The `WAKE_UP_DUR` register is used to configure the sleep duration, stationary detection, wakeup duration, and free-fall duration.
890///
891/// The bit order for this struct can be configured using the `bit_order_msb` feature:
892/// * `Msb`: Most significant bit first.
893/// * `Lsb`: Least significant bit first (default).
894#[register(address = Reg::WakeUpDur, access_type = "Iis2dlpc<B, T, OnState>")]
895#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
896#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
897pub struct WakeUpDur {
898 /// Sleep duration.
899 ///
900 /// Default value: `0`.
901 #[bits(4, default = 0)]
902 pub sleep_dur: u8,
903
904 /// Stationary detection enable.
905 ///
906 /// Default value: `0`.
907 #[bits(1, default = 0)]
908 pub stationary: u8,
909
910 /// Wakeup duration.
911 ///
912 /// Default value: `0`.
913 #[bits(2, default = 0)]
914 pub wake_dur: u8,
915
916 /// Free-fall duration.
917 ///
918 /// Default value: `0`.
919 #[bits(1, default = 0)]
920 pub ff_dur: u8,
921}
922
923/// Free-fall configuration (R/W).
924///
925/// The `FREE_FALL` register is used to configure the free-fall threshold and duration.
926///
927/// The bit order for this struct can be configured using the `bit_order_msb` feature:
928/// * `Msb`: Most significant bit first.
929/// * `Lsb`: Least significant bit first (default).
930#[register(address = Reg::FreeFall, access_type = "Iis2dlpc<B, T, OnState>")]
931#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
932#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
933pub struct FreeFall {
934 /// Free-fall threshold.
935 ///
936 /// Default value: `0`.
937 #[bits(3, default = 0)]
938 pub ff_ths: u8,
939
940 /// Free-fall duration.
941 ///
942 /// Default value: `0`.
943 #[bits(5, default = 0)]
944 pub ff_dur: u8,
945}
946
947/// Status duplicate register (R).
948///
949/// The `STATUS_DUP` register provides the status of various events detected by the IIS2DLPC sensor, including data-ready, free-fall, 6D recognition, and tap events.
950///
951/// The bit order for this struct can be configured using the `bit_order_msb` feature:
952/// * `Msb`: Most significant bit first.
953/// * `Lsb`: Least significant bit first (default).
954#[register(address = Reg::StatusDup, access_type = "Iis2dlpc<B, T, OnState>")]
955#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
956#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
957pub struct StatusDup {
958 /// Data-ready status.
959 ///
960 /// Indicates whether new data is available:
961 /// * `0`: Not ready.
962 /// * `1`: X-, Y-, and Z-axis new data available.
963 ///
964 /// Default value: `0`.
965 #[bits(1, default = 0, access = RO)]
966 pub drdy: u8,
967
968 /// Free-fall event detection status.
969 ///
970 /// Indicates whether a free-fall event has been detected:
971 /// * `0`: Free-fall event not detected.
972 /// * `1`: Free-fall event detected.
973 ///
974 /// Default value: `0`.
975 #[bits(1, default = 0, access = RO)]
976 pub ff_ia: u8,
977
978 /// 6D recognition event status.
979 ///
980 /// Indicates whether a change in position (portrait/landscape/face-up/face-down) has been detected:
981 /// * `0`: No event detected.
982 /// * `1`: A change in position detected.
983 ///
984 /// Default value: `0`.
985 #[bits(1, default = 0, access = RO)]
986 pub six_d_ia: u8,
987
988 /// Single-tap event status.
989 ///
990 /// Indicates whether a single-tap event has been detected:
991 /// * `0`: Single-tap event not detected.
992 /// * `1`: Single-tap event detected.
993 ///
994 /// Default value: `0`.
995 #[bits(1, default = 0, access = RO)]
996 pub single_tap: u8,
997
998 /// Double-tap event status.
999 ///
1000 /// Indicates whether a double-tap event has been detected:
1001 /// * `0`: Double-tap event not detected.
1002 /// * `1`: Double-tap event detected.
1003 ///
1004 /// Default value: `0`.
1005 #[bits(1, default = 0, access = RO)]
1006 pub double_tap: u8,
1007
1008 /// Sleep state status.
1009 ///
1010 /// Indicates whether the device is in a sleep state:
1011 /// * `0`: Sleep event not detected.
1012 /// * `1`: Sleep event detected.
1013 ///
1014 /// Default value: `0`.
1015 #[bits(1, default = 0, access = RO)]
1016 pub sleep_state_ia: u8,
1017
1018 /// Temperature data-ready status.
1019 ///
1020 /// Indicates whether new temperature data is available:
1021 /// * `0`: Data not available.
1022 /// * `1`: A new set of data is available.
1023 ///
1024 /// Default value: `0`.
1025 #[bits(1, default = 0, access = RO)]
1026 pub drdy_t: u8,
1027
1028 /// FIFO overrun status.
1029 ///
1030 /// Indicates whether the FIFO is full and at least one sample has been overwritten:
1031 /// * `0`: FIFO is not completely filled.
1032 /// * `1`: FIFO is completely filled and at least one sample has been overwritten.
1033 ///
1034 /// Default value: `0`.
1035 #[bits(1, default = 0, access = RO)]
1036 pub ovr: u8,
1037}
1038
1039/// Wakeup source register (R).
1040///
1041/// The `WAKE_UP_SRC` register provides the status of wakeup events, including axis-specific wakeup detection and free-fall events.
1042///
1043/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1044/// * `Msb`: Most significant bit first.
1045/// * `Lsb`: Least significant bit first (default).
1046#[register(address = Reg::WakeUpSrc, access_type = "Iis2dlpc<B, T, OnState>")]
1047#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1048#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1049pub struct WakeUpSrc {
1050 /// Wakeup event detection status on the Z-axis.
1051 ///
1052 /// Default value: `0`.
1053 #[bits(1, default = 0, access = RO)]
1054 pub z_wu: u8,
1055
1056 /// Wakeup event detection status on the Y-axis.
1057 ///
1058 /// Default value: `0`.
1059 #[bits(1, default = 0, access = RO)]
1060 pub y_wu: u8,
1061
1062 /// Wakeup event detection status on the X-axis.
1063 ///
1064 /// Default value: `0`.
1065 #[bits(1, default = 0, access = RO)]
1066 pub x_wu: u8,
1067
1068 /// Wakeup event detection status.
1069 ///
1070 /// Indicates whether a wakeup event has been detected:
1071 /// * `0`: Wakeup event not detected.
1072 /// * `1`: Wakeup event detected.
1073 ///
1074 /// Default value: `0`.
1075 #[bits(1, default = 0, access = RO)]
1076 pub wu_ia: u8,
1077
1078 /// Sleep state status.
1079 ///
1080 /// Indicates whether the device is in a sleep state:
1081 /// * `0`: Sleep event not detected.
1082 /// * `1`: Sleep event detected.
1083 ///
1084 /// Default value: `0`.
1085 #[bits(1, default = 0, access = RO)]
1086 pub sleep_state_ia: u8,
1087
1088 /// Free-fall event detection status.
1089 ///
1090 /// Indicates whether a free-fall event has been detected:
1091 /// * `0`: Free-fall event not detected.
1092 /// * `1`: Free-fall event detected.
1093 ///
1094 /// Default value: `0`.
1095 #[bits(1, default = 0, access = RO)]
1096 pub ff_ia: u8,
1097
1098 #[bits(2, access = RO, default = 0)]
1099 not_used_01: u8,
1100}
1101
1102/// Tap source register (R).
1103///
1104/// The `TAP_SRC` register provides the status of tap events, including axis-specific tap detection and tap sign.
1105///
1106/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1107/// * `Msb`: Most significant bit first.
1108/// * `Lsb`: Least significant bit first (default).
1109#[register(address = Reg::TapSrc, access_type = "Iis2dlpc<B, T, OnState>")]
1110#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1111#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1112pub struct TapSrc {
1113 /// Tap event detection status on the Z-axis.
1114 ///
1115 /// Default value: `0`.
1116 #[bits(1, default = 0, access = RO)]
1117 pub z_tap: u8,
1118
1119 /// Tap event detection status on the Y-axis.
1120 ///
1121 /// Default value: `0`.
1122 #[bits(1, default = 0, access = RO)]
1123 pub y_tap: u8,
1124
1125 /// Tap event detection status on the X-axis.
1126 ///
1127 /// Default value: `0`.
1128 #[bits(1, default = 0, access = RO)]
1129 pub x_tap: u8,
1130
1131 /// Sign of acceleration detected by the tap event.
1132 ///
1133 /// Default value: `0`.
1134 #[bits(1, default = 0, access = RO)]
1135 pub tap_sign: u8,
1136
1137 /// Double-tap event status.
1138 ///
1139 /// Indicates whether a double-tap event has been detected:
1140 /// * `0`: Double-tap event not detected.
1141 /// * `1`: Double-tap event detected.
1142 ///
1143 /// Default value: `0`.
1144 #[bits(1, default = 0, access = RO)]
1145 pub double_tap: u8,
1146
1147 /// Single-tap event status.
1148 ///
1149 /// Indicates whether a single-tap event has been detected:
1150 /// * `0`: Single-tap event not detected.
1151 /// * `1`: Single-tap event detected.
1152 ///
1153 /// Default value: `0`.
1154 #[bits(1, default = 0, access = RO)]
1155 pub single_tap: u8,
1156
1157 /// Tap event status.
1158 ///
1159 /// Indicates whether a tap event has been detected:
1160 /// * `0`: Tap event not detected.
1161 /// * `1`: Tap event detected.
1162 ///
1163 /// Default value: `0`.
1164 #[bits(1, default = 0, access = RO)]
1165 pub tap_ia: u8,
1166
1167 #[bits(1, access = RO, default = 0)]
1168 not_used_01: u8,
1169}
1170
1171/// 6D source register (R).
1172///
1173/// The `SIXD_SRC` register provides the status of 6D orientation detection, including axis-specific thresholds and 6D event detection.
1174///
1175/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1176/// * `Msb`: Most significant bit first.
1177/// * `Lsb`: Least significant bit first (default).
1178#[register(address = Reg::SixdSrc, access_type = "Iis2dlpc<B, T, OnState>")]
1179#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1180#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1181pub struct SixdSrc {
1182 /// X-axis low threshold status.
1183 ///
1184 /// Default value: `0`.
1185 #[bits(1, default = 0, access = RO)]
1186 pub xl: u8,
1187
1188 /// X-axis high threshold status.
1189 ///
1190 /// Default value: `0`.
1191 #[bits(1, default = 0, access = RO)]
1192 pub xh: u8,
1193
1194 /// Y-axis low threshold status.
1195 ///
1196 /// Default value: `0`.
1197 #[bits(1, default = 0, access = RO)]
1198 pub yl: u8,
1199
1200 /// Y-axis high threshold status.
1201 ///
1202 /// Default value: `0`.
1203 #[bits(1, default = 0, access = RO)]
1204 pub yh: u8,
1205
1206 /// Z-axis low threshold status.
1207 ///
1208 /// Default value: `0`.
1209 #[bits(1, default = 0, access = RO)]
1210 pub zl: u8,
1211
1212 /// Z-axis high threshold status.
1213 ///
1214 /// Default value: `0`.
1215 #[bits(1, default = 0, access = RO)]
1216 pub zh: u8,
1217
1218 /// 6D event detection status.
1219 ///
1220 /// Indicates whether a 6D orientation event has been detected:
1221 /// * `0`: No event detected.
1222 /// * `1`: 6D event detected.
1223 ///
1224 /// Default value: `0`.
1225 #[bits(1, default = 0, access = RO)]
1226 pub six_d_ia: u8,
1227
1228 #[bits(1, access = RO, default = 0)]
1229 not_used_01: u8,
1230}
1231
1232/// All interrupt source register (R).
1233///
1234/// The `ALL_INT_SRC` register provides the status of all interrupt events, including free-fall, wakeup, tap, and 6D events.
1235///
1236/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1237/// * `Msb`: Most significant bit first.
1238/// * `Lsb`: Least significant bit first (default).
1239#[register(address = Reg::AllIntSrc, access_type = "Iis2dlpc<B, T, OnState>")]
1240#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1241#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1242pub struct AllIntSrc {
1243 /// Free-fall event detection status.
1244 ///
1245 /// Indicates whether a free-fall event has been detected:
1246 /// * `0`: Free-fall event not detected.
1247 /// * `1`: Free-fall event detected.
1248 ///
1249 /// Default value: `0`.
1250 #[bits(1, default = 0, access = RO)]
1251 pub ff_ia: u8,
1252
1253 /// Wakeup event detection status.
1254 ///
1255 /// Indicates whether a wakeup event has been detected:
1256 /// * `0`: Wakeup event not detected.
1257 /// * `1`: Wakeup event detected.
1258 ///
1259 /// Default value: `0`.
1260 #[bits(1, default = 0, access = RO)]
1261 pub wu_ia: u8,
1262
1263 /// Single-tap event detection status.
1264 ///
1265 /// Indicates whether a single-tap event has been detected:
1266 /// * `0`: Single-tap event not detected.
1267 /// * `1`: Single-tap event detected.
1268 ///
1269 /// Default value: `0`.
1270 #[bits(1, default = 0, access = RO)]
1271 pub single_tap: u8,
1272
1273 /// Double-tap event detection status.
1274 ///
1275 /// Indicates whether a double-tap event has been detected:
1276 /// * `0`: Double-tap event not detected.
1277 /// * `1`: Double-tap event detected.
1278 ///
1279 /// Default value: `0`.
1280 #[bits(1, default = 0, access = RO)]
1281 pub double_tap: u8,
1282
1283 /// 6D event detection status.
1284 ///
1285 /// Indicates whether a 6D orientation event has been detected:
1286 /// * `0`: No event detected.
1287 /// * `1`: 6D event detected.
1288 ///
1289 /// Default value: `0`.
1290 #[bits(1, default = 0, access = RO)]
1291 pub six_d_ia: u8,
1292
1293 /// Sleep change event detection status.
1294 ///
1295 /// Indicates whether a sleep change event has been detected:
1296 /// * `0`: Sleep change event not detected.
1297 /// * `1`: Sleep change event detected.
1298 ///
1299 /// Default value: `0`.
1300 #[bits(1, default = 0, access = RO)]
1301 pub sleep_change_ia: u8,
1302
1303 #[bits(2, access = RO, default = 0)]
1304 not_used_01: u8,
1305}
1306
1307/// User offset register for the X-axis (read/write).
1308///
1309/// The `XOfsUsr` register allows the user to apply a signed offset correction to the X-axis acceleration data.
1310/// The offset value is an 8-bit two's complement number.
1311///
1312/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1313/// * `Msb`: Most significant bit first.
1314/// * `Lsb`: Least significant bit first (default).
1315#[register(address = Reg::XOfsUsr, access_type = "Iis2dlpc<B, T, OnState>")]
1316#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1317#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1318pub struct XOfsUsr {
1319 /// User offset value for the X-axis.
1320 #[bits(8, default = 0)]
1321 pub x_ofs_usr: i8,
1322}
1323
1324/// User offset register for the Y-axis (read/write).
1325///
1326/// The `YOfsUsr` register allows the user to apply a signed offset correction to the Y-axis acceleration data.
1327/// The offset value is an 8-bit two's complement number.
1328///
1329/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1330/// * `Msb`: Most significant bit first.
1331/// * `Lsb`: Least significant bit first (default).
1332#[register(address = Reg::YOfsUsr, access_type = "Iis2dlpc<B, T, OnState>")]
1333#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1334#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1335pub struct YOfsUsr {
1336 /// User offset value for the Y-axis.
1337 #[bits(8, default = 0)]
1338 pub y_ofs_usr: i8,
1339}
1340
1341/// User offset register for the Z-axis (read/write).
1342///
1343/// The `ZOfsUsr` register allows the user to apply a signed offset correction to the Z-axis acceleration data.
1344/// The offset value is an 8-bit two's complement number.
1345///
1346/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1347/// * `Msb`: Most significant bit first.
1348/// * `Lsb`: Least significant bit first (default).
1349#[register(address = Reg::ZOfsUsr, access_type = "Iis2dlpc<B, T, OnState>")]
1350#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1351#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1352pub struct ZOfsUsr {
1353 /// User offset value for the Z-axis.
1354 #[bits(8, default = 0)]
1355 pub z_ofs_usr: i8,
1356}
1357
1358/// Control register 7 (R/W).
1359///
1360/// The `CTRL7` register is used to configure various features, including high-pass filter reference mode, user offset application, and interrupt routing.
1361///
1362/// The bit order for this struct can be configured using the `bit_order_msb` feature:
1363/// * `Msb`: Most significant bit first.
1364/// * `Lsb`: Least significant bit first (default).
1365#[register(address = Reg::Ctrl7, access_type = "Iis2dlpc<B, T, OnState>")]
1366#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
1367#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
1368pub struct Ctrl7 {
1369 /// Low-pass filter data sent to 6D function.
1370 ///
1371 /// Configures the data sent to the 6D interrupt function:
1372 /// * `0`: ODR/2 low-pass filtered data.
1373 /// * `1`: LPF2 output data.
1374 ///
1375 /// Default value: `0`.
1376 #[bits(1, default = 0)]
1377 pub lpass_on6d: u8,
1378
1379 /// High-pass filter reference mode enable.
1380 ///
1381 /// Configures the high-pass filter reference mode:
1382 /// * `0`: Disabled.
1383 /// * `1`: Enabled.
1384 ///
1385 /// Default value: `0`.
1386 #[bits(1, default = 0)]
1387 pub hp_ref_mode: u8,
1388
1389 /// User offset weight selection.
1390 ///
1391 /// Configures the weight of the user offset:
1392 /// * `0`: 977 μg/LSB.
1393 /// * `1`: 15.6 mg/LSB.
1394 ///
1395 /// Default value: `0`.
1396 #[bits(1, default = 0)]
1397 pub usr_off_w: u8,
1398
1399 /// User offset application for wakeup function.
1400 ///
1401 /// Enables the application of user offset for wakeup detection:
1402 /// * `0`: Disabled.
1403 /// * `1`: Enabled.
1404 ///
1405 /// Default value: `0`.
1406 #[bits(1, default = 0)]
1407 pub usr_off_on_wu: u8,
1408
1409 /// User offset application for output data.
1410 ///
1411 /// Enables the application of user offset for output data:
1412 /// * `0`: Disabled.
1413 /// * `1`: Enabled.
1414 ///
1415 /// Default value: `0`.
1416 #[bits(1, default = 0)]
1417 pub usr_off_on_out: u8,
1418
1419 /// Interrupts enable.
1420 ///
1421 /// Enables interrupts:
1422 /// * `0`: Disabled.
1423 /// * `1`: Enabled.
1424 ///
1425 /// Default value: `0`.
1426 #[bits(1, default = 0)]
1427 pub interrupts_enable: u8,
1428
1429 /// INT2 signal routing to INT1.
1430 ///
1431 /// Routes all signals available on INT2 to INT1:
1432 /// * `0`: Disabled.
1433 /// * `1`: Enabled.
1434 ///
1435 /// Default value: `0`.
1436 #[bits(1, default = 0)]
1437 pub int2_on_int1: u8,
1438
1439 /// Data-ready interrupt mode.
1440 ///
1441 /// Configures the data-ready interrupt mode:
1442 /// * `0`: Latched mode.
1443 /// * `1`: Pulsed mode.
1444 ///
1445 /// Default value: `0`.
1446 #[bits(1, default = 0)]
1447 pub drdy_pulsed: u8,
1448}
1449
1450/// All interrupt and status sources.
1451///
1452/// This struct aggregates the status and interrupt source registers of the IIS2DLPC sensor.
1453/// It provides a comprehensive view of the device's current status and interrupt events.
1454pub struct AllSources {
1455 /// Status duplicate register.
1456 ///
1457 /// Contains information about various events such as data-ready, free-fall detection, and tap detection.
1458 pub status_dup: StatusDup,
1459
1460 /// Wake-up source register.
1461 ///
1462 /// Contains information about wake-up events, including axis-specific wake-up detection.
1463 pub wake_up_src: WakeUpSrc,
1464
1465 /// Tap source register.
1466 ///
1467 /// Contains information about tap events, including axis-specific tap detection and tap type (single or double).
1468 pub tap_src: TapSrc,
1469
1470 /// 6D source register.
1471 ///
1472 /// Contains information about 6D orientation events, including axis-specific thresholds and event detection.
1473 pub sixd_src: SixdSrc,
1474
1475 /// All interrupt source register.
1476 ///
1477 /// Contains a summary of all interrupt events routed to the INT pads.
1478 pub all_int_src: AllIntSrc,
1479}
1480
1481/// Accelerometer operating modes.
1482///
1483/// This enum represents the various operating modes of the IIS2DLPC accelerometer. Each mode is associated with specific configurations for:
1484/// - `mode`: Operating mode.
1485/// - `lp_mode`: Low-power mode configuration.
1486/// - `low_noise`: Low-noise mode configuration.
1487#[repr(u8)]
1488#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1489#[try_from(repr)]
1490pub enum Mode {
1491 /// High-performance mode.
1492 HighPerformance = 0x04,
1493
1494 /// Continuous low-power mode 4.
1495 ContLowPwr4 = 0x03,
1496
1497 /// Continuous low-power mode 3.
1498 ContLowPwr3 = 0x02,
1499
1500 /// Continuous low-power mode 2.
1501 ContLowPwr2 = 0x01,
1502
1503 /// Continuous low-power mode with 12-bit resolution (default).
1504 #[default]
1505 ContLowPwr12bit = 0x00,
1506 /// Single low-power mode 4.
1507 SingleLowPwr4 = 0x0B,
1508 /// Single low-power mode 3.
1509 SingleLowPwr3 = 0x0A,
1510 /// Single low-power mode 2.
1511 SingleLowPwr2 = 0x09,
1512 /// Single low-power mode with 12-bit resolution.
1513 SingleLowPwr12bit = 0x08,
1514 /// High-performance mode with low noise.
1515 HighPerformanceLowNoise = 0x14,
1516 /// Continuous low-power mode 4 with low noise.
1517 ContLowPwrLowNoise4 = 0x13,
1518 /// Continuous low-power mode 3 with low noise.
1519 ContLowPwrLowNoise3 = 0x12,
1520 /// Continuous low-power mode 2 with low noise.
1521 ContLowPwrLowNoise2 = 0x11,
1522 /// Continuous low-power mode with 12-bit resolution and low noise.
1523 ContLowPwrLowNoise12bit = 0x10,
1524 /// Single low-power mode 4 with low noise.
1525 SingleLowPwrLowNoise4 = 0x1B,
1526 /// Single low-power mode 3 with low noise.
1527 SingleLowPwrLowNoise3 = 0x1A,
1528 /// Single low-power mode 2 with low noise.
1529 SingleLowPwrLowNoise2 = 0x19,
1530 /// Single low-power mode with 12-bit resolution and low noise.
1531 SingleLowLowNoisePwr12bit = 0x18,
1532}
1533
1534impl Mode {
1535 /// Create a new `Mode` instance.
1536 ///
1537 /// This function constructs a `Mode` instance from the given `mode`, `lp_mode`, and `low_noise` values.
1538 ///
1539 /// ### Arguments
1540 /// - `mode`: The operating mode value.
1541 /// - `lp_mode`: The low-power mode configuration value.
1542 /// - `low_noise`: The low-noise mode configuration value.
1543 ///
1544 /// ### Returns
1545 /// - A `Mode` instance corresponding to the provided values.
1546 /// - Defaults to `ContLowPwr12bit` if the provided values do not match a valid mode.
1547 pub fn new(mode: u8, lp_mode: u8, low_noise: u8) -> Self {
1548 // low_noise | mode1 | mode2 | lp_mode1 | lp_mode2 |
1549 Self::try_from((low_noise << 4) + (mode << 2) + lp_mode).unwrap_or_default()
1550 }
1551
1552 /// Get the `mode` value.
1553 ///
1554 /// Extracts the `mode` field from the `Mode` instance.
1555 ///
1556 /// ### Returns
1557 /// - The `mode` value as a `u8`.
1558 pub fn mode(&self) -> u8 {
1559 (*self as u8 & 0x0C) >> 2
1560 }
1561
1562 /// Get the `lp_mode` value.
1563 ///
1564 /// Extracts the `lp_mode` field from the `Mode` instance.
1565 ///
1566 /// ### Returns
1567 /// - The `lp_mode` value as a `u8`.
1568 pub fn lp_mode(&self) -> u8 {
1569 *self as u8 & 0x3
1570 }
1571
1572 /// Get the `low_noise` value.
1573 ///
1574 /// Extracts the `low_noise` field from the `Mode` instance.
1575 ///
1576 /// ### Returns
1577 /// - The `low_noise` value as a `u8`.
1578 pub fn low_noise(&self) -> u8 {
1579 (*self as u8 & 0x10) >> 4
1580 }
1581}
1582
1583/// Accelerometer output data rates (ODR).
1584///
1585/// This enum represents the various output data rates supported by the IIS2DLPC accelerometer. Each variant corresponds to a specific ODR configuration.
1586#[repr(u8)]
1587#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1588#[try_from(repr)]
1589pub enum Odr {
1590 /// Accelerometer off (default).
1591 #[default]
1592 Off = 0x00,
1593
1594 /// Accelerometer ODR: 1.6 Hz (low-power only).
1595 _1_6hzLpOnly = 0x01,
1596
1597 /// Accelerometer ODR: 12.5 Hz.
1598 _12_5hz = 0x02,
1599
1600 /// Accelerometer ODR: 25 Hz.
1601 _25hz = 0x03,
1602
1603 /// Accelerometer ODR: 50 Hz.
1604 _50hz = 0x04,
1605
1606 /// Accelerometer ODR: 100 Hz.
1607 _100hz = 0x05,
1608
1609 /// Accelerometer ODR: 200 Hz.
1610 _200hz = 0x06,
1611
1612 /// Accelerometer ODR: 400 Hz.
1613 _400hz = 0x07,
1614
1615 /// Accelerometer ODR: 800 Hz.
1616 _800hz = 0x08,
1617
1618 /// Accelerometer ODR: 1.6 kHz.
1619 _1_6khz = 0x09,
1620
1621 /// Accelerometer ODR: Software trigger.
1622 SetSwTrig = 0x12,
1623
1624 /// Accelerometer ODR: Pin trigger.
1625 SetPinTrig = 0x22,
1626}
1627
1628impl Odr {
1629 /// Create a new `Odr` instance.
1630 ///
1631 /// This function constructs an `Odr` instance from the given `odr` and `slp_mode` values.
1632 ///
1633 /// ### Arguments
1634 /// - `odr`: The output data rate value.
1635 /// - `slp_mode`: The sleep mode configuration value.
1636 ///
1637 /// ### Returns
1638 /// - An `Odr` instance corresponding to the provided values.
1639 /// - Defaults to `XlOdrOff` if the provided values do not match a valid ODR.
1640 pub fn new(odr: u8, slp_mode: u8) -> Self {
1641 Self::try_from((slp_mode << 4) + odr).unwrap_or_default()
1642 }
1643
1644 /// Get the `odr` value.
1645 ///
1646 /// Extracts the `odr` field from the `Odr` instance.
1647 ///
1648 /// ### Returns
1649 /// - The `odr` value as a `u8`.
1650 pub fn odr(&self) -> u8 {
1651 *self as u8 & 0xF
1652 }
1653
1654 /// Get the `slp_mode` value.
1655 ///
1656 /// Extracts the `slp_mode` field from the `Odr` instance.
1657 ///
1658 /// ### Returns
1659 /// - The `slp_mode` value as a `u8`.
1660 pub fn slp_mode(&self) -> u8 {
1661 (*self as u8 & 0x30) >> 4
1662 }
1663}
1664
1665/// Accelerometer full-scale selection.
1666///
1667/// This enum represents the full-scale range of the accelerometer, which determines the maximum measurable acceleration.
1668/// The full-scale range is configured in the `CTRL6` register.
1669#[repr(u8)]
1670#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1671#[try_from(repr)]
1672pub enum Fs {
1673 /// ±2g full-scale range (default).
1674 #[default]
1675 _2g = 0,
1676
1677 /// ±4g full-scale range.
1678 _4g = 1,
1679
1680 /// ±8g full-scale range.
1681 _8g = 2,
1682
1683 /// ±16g full-scale range.
1684 _16g = 3,
1685}
1686
1687/// User offset weight configuration.
1688///
1689/// This enum represents the weight of the user offset bits in the `X_OFS_USR`, `Y_OFS_USR`, and `Z_OFS_USR` registers.
1690/// The weight determines the scaling factor applied to the user offset values.
1691#[repr(u8)]
1692#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1693#[try_from(repr)]
1694pub enum UsrOffW {
1695 /// 977 μg/LSB (default).
1696 #[default]
1697 _977ugLsb = 0,
1698
1699 /// 15.6 mg/LSB.
1700 _15_6mgLsb = 1,
1701}
1702
1703/// Sensor self-test configuration.
1704///
1705/// This enum represents the self-test modes for the IIS2DLPC sensor.
1706/// The self-test mode is configured in the `CTRL3` register.
1707#[repr(u8)]
1708#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1709#[try_from(repr)]
1710pub enum St {
1711 /// Self-test disabled (default).
1712 #[default]
1713 Disable = 0,
1714
1715 /// Positive sign self-test.
1716 Positive = 1,
1717
1718 /// Negative sign self-test.
1719 Negative = 2,
1720}
1721
1722/// Data-ready interrupt mode configuration.
1723///
1724/// This enum represents the data-ready interrupt mode for the IIS2DLPC sensor.
1725/// The mode is configured in the `CTRL7` register.
1726#[repr(u8)]
1727#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1728#[try_from(repr)]
1729pub enum DrdyPulsed {
1730 /// Latched mode (default).
1731 #[default]
1732 Latched = 0,
1733
1734 /// Pulsed mode.
1735 Pulsed = 1,
1736}
1737
1738/// Accelerometer filtering path configuration.
1739///
1740/// This enum represents the filtering path options for accelerometer outputs.
1741/// The filtering path is configured in the `CTRL6` and `CTRL7` registers.
1742#[repr(u8)]
1743#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1744#[try_from(repr)]
1745pub enum Fds {
1746 /// Low-pass filter on output (default).
1747 #[default]
1748 LpfOnOut = 0x00,
1749
1750 /// User offset on output.
1751 UserOffsetOnOut = 0x01,
1752
1753 /// High-pass filter on output.
1754 HighPassOnOut = 0x10,
1755}
1756
1757impl Fds {
1758 /// Create a new `Fds` instance.
1759 ///
1760 /// This function constructs an `Fds` instance from the given `fds` and `usr_off_on_out` values.
1761 ///
1762 /// ### Arguments
1763 /// - `fds`: The filtering path configuration value.
1764 /// - `usr_off_on_out`: The user offset application value.
1765 ///
1766 /// ### Returns
1767 /// - An `Fds` instance corresponding to the provided values.
1768 /// - Defaults to `LpfOnOut` if the provided values do not match a valid configuration.
1769 pub fn new(fds: u8, usr_off_on_out: u8) -> Self {
1770 Self::try_from((fds << 4) + usr_off_on_out).unwrap_or_default()
1771 }
1772
1773 /// Get the `fds` value.
1774 ///
1775 /// Extracts the `fds` field from the `Fds` instance.
1776 ///
1777 /// ### Returns
1778 /// - The `fds` value as a `u8`.
1779 pub fn fds(&self) -> u8 {
1780 ((*self as u8) & 0x10) >> 4
1781 }
1782
1783 /// Get the `usr_off_on_out` value.
1784 ///
1785 /// Extracts the `usr_off_on_out` field from the `Fds` instance.
1786 ///
1787 /// ### Returns
1788 /// - The `usr_off_on_out` value as a `u8`.
1789 pub fn usr_off_on_out(&self) -> u8 {
1790 *self as u8 & 0x01
1791 }
1792}
1793
1794/// Accelerometer cutoff filter frequency configuration.
1795///
1796/// This enum represents the cutoff frequency options for the accelerometer's low-pass or high-pass filter.
1797/// The cutoff frequency is configured in the `CTRL6` register.
1798#[repr(u8)]
1799#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1800#[try_from(repr)]
1801pub enum BwFilt {
1802 /// ODR/2 (default).
1803 #[default]
1804 OdrDiv2 = 0,
1805
1806 /// ODR/4.
1807 OdrDiv4 = 1,
1808
1809 /// ODR/10.
1810 OdrDiv10 = 2,
1811
1812 /// ODR/20.
1813 OdrDiv20 = 3,
1814}
1815
1816/// SPI serial interface mode configuration.
1817///
1818/// This enum represents the SPI serial interface modes for the IIS2DLPC sensor.
1819/// The mode is configured in the `CTRL2` register.
1820#[repr(u8)]
1821#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1822#[try_from(repr)]
1823pub enum Sim {
1824 /// 4-wire SPI mode (default).
1825 #[default]
1826 Spi4Wire = 0,
1827
1828 /// 3-wire SPI mode.
1829 Spi3Wire = 1,
1830}
1831
1832/// I²C interface configuration.
1833///
1834/// This enum represents the enable/disable states of the I²C interface for the IIS2DLPC sensor.
1835/// The state is configured in the `CTRL2` register.
1836#[repr(u8)]
1837#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1838#[try_from(repr)]
1839pub enum I2cDisable {
1840 /// Enable the I²C interface (default).
1841 #[default]
1842 I2cEnable = 0,
1843
1844 /// Disable the I²C interface.
1845 I2cDisable = 1,
1846}
1847
1848/// CS pull-up resistor configuration.
1849///
1850/// This enum represents the configuration of the CS pull-up resistor for the IIS2DLPC sensor.
1851/// The configuration is set in the `CTRL2` register.
1852#[repr(u8)]
1853#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1854#[try_from(repr)]
1855pub enum CsPuDisc {
1856 /// Connect the pull-up resistor (default).
1857 #[default]
1858 PullUpConnect = 0,
1859
1860 /// Disconnect the pull-up resistor.
1861 PullUpDisconnect = 1,
1862}
1863
1864/// Interrupt active level configuration.
1865///
1866/// This enum represents the active level configuration for interrupts.
1867/// The configuration is set in the `CTRL3` register.
1868#[repr(u8)]
1869#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1870#[try_from(repr)]
1871pub enum HLactive {
1872 /// Active high (default).
1873 #[default]
1874 ActiveHigh = 0,
1875
1876 /// Active low.
1877 ActiveLow = 1,
1878}
1879
1880/// Interrupt latching configuration.
1881///
1882/// This enum represents the latching behavior of interrupts.
1883/// The configuration is set in the `CTRL3` register.
1884#[repr(u8)]
1885#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1886#[try_from(repr)]
1887pub enum Lir {
1888 /// Pulsed interrupt mode (default).
1889 #[default]
1890 Pulsed = 0,
1891
1892 /// Latched interrupt mode.
1893 Latched = 1,
1894}
1895
1896/// Interrupt pad type configuration.
1897///
1898/// This enum represents the type of interrupt pad configuration.
1899/// The configuration is set in the `CTRL3` register.
1900#[repr(u8)]
1901#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1902#[try_from(repr)]
1903pub enum PpOd {
1904 /// Push-pull configuration (default).
1905 #[default]
1906 PushPull = 0,
1907
1908 /// Open-drain configuration.
1909 OpenDrain = 1,
1910}
1911
1912/// Data source for the wake-up interrupt function.
1913///
1914/// This enum represents the data source options for the wake-up interrupt function.
1915/// The data source is configured in the `CTRL7` register.
1916#[repr(u8)]
1917#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1918#[try_from(repr)]
1919pub enum UsrOffOnWu {
1920 /// High-pass filtered data (default).
1921 #[default]
1922 HpFeed = 0,
1923
1924 /// User offset data.
1925 UserOffsetFeed = 1,
1926}
1927
1928/// Activity/inactivity or stationary/motion detection configuration.
1929///
1930/// This enum represents the detection modes for activity/inactivity or stationary/motion.
1931/// The configuration is set in the `WAKE_UP_THS` and `WAKE_UP_DUR` registers.
1932#[repr(u8)]
1933#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1934#[try_from(repr)]
1935pub enum SleepOn {
1936 /// No detection (default).
1937 #[default]
1938 NoDetection = 0,
1939
1940 /// Detect activity/inactivity.
1941 ActInact = 1,
1942
1943 /// Detect stationary/motion.
1944 StatMotion = 3,
1945}
1946
1947impl SleepOn {
1948 /// Create a new `SleepOn` instance.
1949 ///
1950 /// This function constructs a `SleepOn` instance from the given `sleep_on` and `stationary` values.
1951 ///
1952 /// ### Arguments
1953 /// - `sleep_on`: The activity/inactivity detection configuration value.
1954 /// - `stationary`: The stationary/motion detection configuration value.
1955 ///
1956 /// ### Returns
1957 /// - A `SleepOn` instance corresponding to the provided values.
1958 /// - Defaults to `NoDetection` if the provided values do not match a valid configuration.
1959 pub fn new(sleep_on: u8, stationary: u8) -> Self {
1960 Self::try_from((stationary << 1) + sleep_on).unwrap_or_default()
1961 }
1962
1963 /// Get the `sleep_on` value.
1964 ///
1965 /// Extracts the `sleep_on` field from the `SleepOn` instance.
1966 ///
1967 /// ### Returns
1968 /// - The `sleep_on` value as a `u8`.
1969 pub fn sleep_on(&self) -> u8 {
1970 (*self as u8) & 0x01
1971 }
1972
1973 /// Get the `stationary` value.
1974 ///
1975 /// Extracts the `stationary` field from the `SleepOn` instance.
1976 ///
1977 /// ### Returns
1978 /// - The `stationary` value as a `u8`.
1979 pub fn stationary(&self) -> u8 {
1980 ((*self as u8) & 0x02) >> 1
1981 }
1982}
1983
1984/// Axis priority for tap detection.
1985///
1986/// This enum represents the axis priority for tap detection.
1987/// The priority is configured in the `TAP_THS_Y` register.
1988#[repr(u8)]
1989#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
1990#[try_from(repr)]
1991pub enum TapPrior {
1992 /// X > Y > Z (default).
1993 #[default]
1994 Xyz = 0,
1995
1996 /// Y > X > Z.
1997 Yxz = 1,
1998
1999 /// X > Z > Y.
2000 Xzy = 2,
2001
2002 /// Z > Y > X.
2003 Zyx = 3,
2004
2005 /// Y > Z > X.
2006 Yzx = 5,
2007
2008 /// Z > X > Y.
2009 Zxy = 6,
2010}
2011
2012/// Single/double-tap event detection mode.
2013///
2014/// This enum represents the detection mode for single- and double-tap events.
2015/// The mode is configured in the `WAKE_UP_THS` register.
2016#[repr(u8)]
2017#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
2018#[try_from(repr)]
2019pub enum SingleDoubleTap {
2020 /// Detect only single-tap events (default).
2021 #[default]
2022 OnlySingle = 0,
2023
2024 /// Detect both single- and double-tap events.
2025 BothSingleDouble = 1,
2026}
2027
2028/// Data source for the 6D interrupt function.
2029///
2030/// This enum represents the data source options for the 6D interrupt function.
2031/// The data source is configured in the `CTRL7` register.
2032#[repr(u8)]
2033#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
2034#[try_from(repr)]
2035pub enum LpassOn6d {
2036 /// ODR/2 low-pass filtered data (default).
2037 #[default]
2038 OdrDiv2Feed = 0,
2039
2040 /// LPF2 output data.
2041 Lpf2Feed = 1,
2042}
2043
2044/// Free-fall threshold configuration.
2045///
2046/// This enum represents the free-fall threshold options for the IIS2DLPC sensor.
2047/// The threshold is configured in the `FREE_FALL` register.
2048#[repr(u8)]
2049#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
2050#[try_from(repr)]
2051pub enum FfThs {
2052 /// 5 LSB @ ±2g (default).
2053 #[default]
2054 _5Lsb = 0,
2055
2056 /// 7 LSB @ ±2g.
2057 _7Lsb = 1,
2058
2059 /// 8 LSB @ ±2g.
2060 _8Lsb = 2,
2061
2062 /// 10 LSB @ ±2g.
2063 _10Lsb = 3,
2064
2065 /// 11 LSB @ ±2g.
2066 _11Lsb = 4,
2067
2068 /// 13 LSB @ ±2g.
2069 _13Lsb = 5,
2070
2071 /// 15 LSB @ ±2g.
2072 _15Lsb = 6,
2073
2074 /// 16 LSB @ ±2g.
2075 _16Lsb = 7,
2076}
2077
2078/// FIFO mode configuration.
2079///
2080/// This enum represents the FIFO operating modes for the IIS2DLPC sensor.
2081/// The mode is configured in the `FIFO_CTRL` register.
2082#[repr(u8)]
2083#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
2084#[try_from(repr)]
2085pub enum Fmode {
2086 /// Bypass mode (default).
2087 #[default]
2088 BypassMode = 0,
2089
2090 /// FIFO mode: Stops collecting data when FIFO is full.
2091 FifoMode = 1,
2092
2093 /// Stream-to-FIFO mode: Stream mode until a trigger event, then FIFO mode.
2094 StreamToFifoMode = 3,
2095
2096 /// Bypass-to-Stream mode: Bypass mode until a trigger event, then stream mode.
2097 BypassToStreamMode = 4,
2098
2099 /// Stream mode: Continuously updates FIFO, overwriting old data when full.
2100 StreamMode = 6,
2101}