lis2dux12-rs 2.0.0

Platform-agnostic driver for the LIS2DUX12 ultra-low-power 3-axis accelerometer with FSM, MLC, adaptive self-configuration, FIFO, and advanced motion detection.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
use super::super::{
    BusOperation, DelayNs, Error, Lis2dux12, PROPERTY_ENABLE, RegisterOperation, SensorOperation,
    bisync,
    register::{BankState, MainBank},
};

use bitfield_struct::bitfield;

use derive_more::TryFrom;
use st_mem_bank_macro::register;

/// Represents the register addresses of the device.
///
/// This enum is used to specify the addresses of various registers within the device, allowing for
/// read and write operations as specified.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq)]
pub enum Reg {
    /// Address for the `EXT_CLK_CFG` register (R/W).
    ExtClkCfg = 0x08,
    /// Address for the `PIN_CTRL` register (R/W).
    PinCtrl = 0x0C,
    /// Address for the `WAKE_UP_DUR_EXT` register (R/W).
    WakeUpDurExt = 0x0E,
    /// Address for the `WHO_AM_I` register (R).
    WhoAmI = 0x0F,
    /// Address for the `CTRL1` register (R/W).
    Ctrl1 = 0x10,
    /// Address for the `CTRL2` register (R/W).
    Ctrl2 = 0x11,
    /// Address for the `CTRL3` register (R/W).
    Ctrl3 = 0x12,
    /// Address for the `CTRL4` register (R/W).
    Ctrl4 = 0x13,
    /// Address for the `CTRL5` register (R/W).
    Ctrl5 = 0x14,
    /// Address for the `FIFO_CTRL` register (R/W).
    FifoCtrl = 0x15,
    /// Address for the `FIFO_WTM` register (R/W).
    FifoWtm = 0x16,
    /// Address for the `INTERRUPT_CFG` register (R/W).
    InterruptCfg = 0x17,
    /// Address for the `SIXD` register (R/W).
    Sixd = 0x18,
    /// Address for the `WAKE_UP_THS` register (R/W).
    WakeUpThs = 0x1C,
    /// Address for the `WAKE_UP_DUR` register (R/W).
    WakeUpDur = 0x1D,
    /// Address for the `FREE_FALL` register (R/W).
    FreeFall = 0x1E,
    /// Address for the `MD1_CFG` register (R/W).
    Md1Cfg = 0x1F,
    /// Address for the `MD1_CFG` register (R/W).
    Md2Cfg = 0x20,
    /// Address for the `WAKE_UP_SRC` register (R).
    WakeUpSrc = 0x21,
    /// Address for the `TAP_SRC` register (R).
    TapSrc = 0x22,
    /// Address for the `SIXD_SRC` register (R).
    SixdSrc = 0x23,
    /// Address for the `ALL_INT_SRC` register (R).
    AllIntSrc = 0x24,
    /// Address for the `STATUS` register (R).
    Status = 0x25,
    /// Address for the `FIFO_STATUS1` register (R).
    FifoStatus1 = 0x26,
    /// Address for the `FIFO_STATUS2` register (R).
    FifoStatus2 = 0x27,
    /// Address for the `OUT_X_L` register (R).
    OutXL = 0x28,
    /// Address for the `OUT_X_H` register (R).
    OutXH = 0x29,
    /// Address for the `OUT_Y_L` register (R).
    OutYL = 0x2A,
    /// Address for the `OUT_Y_H` register (R).
    OutYH = 0x2B,
    /// Address for the `OUT_Z_L` register (R).
    OutZL = 0x2C,
    /// Address for the `OUT_Z_H` register (R).
    OutZH = 0x2D,
    /// Address for the `OUT_T_L` register (R).
    OutTL = 0x2E,
    /// Address for the `OUT_T_H` register (R).
    OutTH = 0x2F,
    /// Address for the `SELF_TEST` register (R/W).
    SelfTest = 0x32,
    /// Address for the `I3C_IF_CTRL` register (R/W).
    I3cIfCtrl = 0x33,
    /// Address for the `EMB_FUNC_STATUS_MAINPAGE` register (R).
    EmbFuncStatusMainpage = 0x34,
    /// Address for the `FSM_STATUS_MAINPAGE` register (R).
    FsmStatusMainpage = 0x35,
    /// Address for the `MLC_STATUS_MAINPAGE` register (R).
    MlcStatusMainpage = 0x36,
    /// Address for the `SLEEP` register (R/W).
    Sleep = 0x3D,
    /// Address for the `EN_DEVICE_CONFIG` register (W).
    EnDeviceConfig = 0x3E,
    /// Address for the `FUNC_CFG_ACCESS` register (R/W).
    FuncCfgAccess = 0x3F,
    /// Address for the `FIFO_DATA_OUT_TAG` register (R).
    FifoDataOutTag = 0x40,
    /// Address for the `FIFO_DATA_OUT_X_L` register (R).
    FifoDataOutXL = 0x41,
    /// Address for the `FIFO_DATA_OUT_X_H` register (R).
    FifoDataOutXH = 0x42,
    /// Address for the `FIFO_DATA_OUT_Y_L` register (R).
    FifoDataOutYL = 0x43,
    /// Address for the `FIFO_DATA_OUT_Y_H` register (R).
    FifoDataOutYH = 0x44,
    /// Address for the `FIFO_DATA_OUT_Z_L` register (R).
    FifoDataOutZL = 0x45,
    /// Address for the `FIFO_DATA_OUT_Z_H` register (R).
    FifoDataOutZH = 0x46,
    /// Address for the `FIFO_BATCH_DEC` register (R/W).
    FifoBatchDec = 0x47,
    /// Address for the `TAP_CFG0` register (R/W).
    TapCfg0 = 0x6F,
    /// Address for the `TAP_CFG1` register (R/W).
    TapCfg1 = 0x70,
    /// Address for the `TAP_CFG2` register (R/W).
    TapCfg2 = 0x71,
    /// Address for the `TAP_CFG3` register (R/W).
    TapCfg3 = 0x72,
    /// Address for the `TAP_CFG4` register (R/W).
    TapCfg4 = 0x73,
    /// Address for the `TAP_CFG5` register (R/W).
    TapCfg5 = 0x74,
    /// Address for the `TAP_CFG6` register (R/W).
    TapCfg6 = 0x75,
    /// Address for the `TIMESTAMP0` register (R).
    Timestamp0 = 0x7A,
    /// Address for the `TIMESTAMP1` register (R).
    Timestamp1 = 0x7B,
    /// Address for the `TIMESTAMP2` register (R).
    Timestamp2 = 0x7C,
    /// Address for the `TIMESTAMP3` register (R).
    Timestamp3 = 0x7D,
}

/// Who Am I (R).
///
/// This register is a read-only register. Its value is fixed at 47h.
/// Return the id of the device.
#[register(address = Reg::WhoAmI, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WhoAmI {
    /// Id.
    #[bits(8, default = 0x47, access = RO)]
    pub id: u8,
}

/// External Clock Configuration Register (R/W).
///
/// The `EXT_CLK_CFG` register is used to configure the external clock settings. It allows the external clock to replace the internal oscillator when enabled.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::ExtClkCfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct ExtClkCfg {
    #[bits(7, access = RO, default = 0)]
    not_used0: u8,

    /// External Clock Enable.
    ///
    /// When set to 1, the external clock replaces the internal oscillator.
    #[bits(1)]
    pub ext_clk_en: u8,
}

/// Pin Control Register (R/W).
///
/// The `PIN_CTRL` register configures the pin settings, including pull-up/pull-down resistors and SPI mode.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::PinCtrl, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct PinCtrl {
    /// SPI Mode Selection.
    ///
    /// 0: 4-wire SPI (default); 1: 3-wire SPI.
    #[bits(1)]
    pub sim: u8,

    /// Push-Pull/Open-Drain Mode for INT Pins.
    ///
    /// 0: Push-pull mode (default); 1: Open-drain mode.
    #[bits(1)]
    pub pp_od: u8,

    /// CS Pin Pull-Up Disable.
    ///
    /// If 1, disables the internal pull-up of the CS pin.
    #[bits(1)]
    pub cs_pu_dis: u8,

    /// Interrupt Active Level.
    ///
    /// 0: Interrupts active-high (default); 1: Interrupts active-low.
    #[bits(1)]
    pub h_lactive: u8,

    /// INT1 Pin Pull-Down Disable.
    ///
    /// If 1, disables the internal pull-down of the INT1 pin.
    #[bits(1)]
    pub pd_dis_int1: u8,

    /// INT2 Pin Pull-Down Disable.
    ///
    /// If 1, disables the internal pull-down of the INT2 pin.
    #[bits(1)]
    pub pd_dis_int2: u8,

    /// SDA/SDI/SDO Pin Pull-Up Enable.
    ///
    /// If 1, enables the internal pull-up of the SDA/SDI/SDO pin.
    #[bits(1)]
    pub sda_pu_en: u8,

    /// SDO/TA0 Pin Pull-Up Enable.
    ///
    /// If 1, enables the internal pull-up of the SDO/TA0 pin.
    #[bits(1)]
    pub sdo_pu_en: u8,
}

/// Wake-Up Duration Extended Register (R/W).
///
/// The `WAKE_UP_DUR_EXT` register is used to select the resolution of the wake-up duration bits.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::WakeUpDurExt, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpDurExt {
    #[bits(4, access = RO, default = 0)]
    not_used0: u8,

    /// Wake-Up Duration Extended.
    ///
    /// This bit is used to select the resolution of WAKE_DUR[1:0] bits in the WAKE_UP_DUR register.
    #[bits(1)]
    pub wu_dur_extended: u8,

    #[bits(3, access = RO, default = 0)]
    not_used1: u8,
}

/// Control Register 1 (R/W).
///
/// The `CTRL1` register configures various control settings, including wake-up event detection and data-ready mode.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Ctrl1, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl1 {
    /// Wake-Up Event Detection on Z-Axis.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub wu_z_en: u8,

    /// Wake-Up Event Detection on Y-Axis.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub wu_y_en: u8,

    /// Wake-Up Event Detection on X-Axis.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub wu_x_en: u8,

    /// Data-Ready Pulsed Mode.
    ///
    /// 0: Latched mode (default); 1: Pulsed mode.
    #[bits(1)]
    pub drdy_pulsed: u8,

    /// Register Address Auto-Increment.
    ///
    /// 0: Disabled; 1: Enabled (default).
    #[bits(1, default = 1)]
    pub if_add_inc: u8,

    /// Software Reset.
    ///
    /// 0: Disabled; 1: Enabled. Automatically resets to 0 after the procedure.
    #[bits(1)]
    pub sw_reset: u8,

    /// Interrupt Routing on RES/EXT_CLK Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int1_on_res: u8,

    /// Smart Power Management Enable.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub smart_power_en: u8,
}

/// Control Register 2 (R/W).
///
/// The `CTRL2` register configures interrupt settings for the INT1 pin.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Ctrl2, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl2 {
    #[bits(3, access = RO, default = 0)]
    not_used0: u8,

    /// Data-Ready Interrupt on INT1 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int1_drdy: u8,

    /// FIFO Overrun Interrupt on INT1 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int1_fifo_ovr: u8,

    /// FIFO Threshold Interrupt on INT1 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int1_fifo_th: u8,

    /// FIFO Full Interrupt on INT1 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int1_fifo_full: u8,

    /// Boot Status on INT1 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int1_boot: u8,
}

#[register(address = Reg::Ctrl3, access_type = "Lis2dux12<B, T, MainBank>")]
/// Control Register 3 (R/W).
///
/// The `CTRL3` register configures interrupt settings for the INT2 pin and self-test configurations.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl3 {
    /// Self-Test Sign for X-Axis.
    ///
    /// 1: Positive; 0: Negative.
    #[bits(1)]
    pub st_sign_x: u8,

    /// Self-Test Sign for Y-Axis.
    ///
    /// 1: Positive; 0: Negative.
    #[bits(1)]
    pub st_sign_y: u8,

    /// High-Performance Mode Enable.
    ///
    /// 0: Low-power mode; 1: High-performance mode.
    #[bits(1)]
    pub hp_en: u8,

    /// Data-Ready Interrupt on INT2 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int2_drdy: u8,

    /// FIFO Overrun Interrupt on INT2 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int2_fifo_ovr: u8,

    /// FIFO Threshold Interrupt on INT2 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int2_fifo_th: u8,

    /// FIFO Full Interrupt on INT2 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int2_fifo_full: u8,

    /// Boot Status on INT2 Pin.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub int2_boot: u8,
}

/// Control Register 4 (R/W).
///
/// The `CTRL4` register configures various control settings, including FIFO and embedded functions enable.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Ctrl4, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl4 {
    /// Reboot Memory Content.
    ///
    /// 0: Normal mode; 1: Reboot memory content.
    #[bits(1)]
    pub boot: u8,

    /// Start of Conversion.
    ///
    /// 0: Normal mode; 1: Start conversion.
    #[bits(1)]
    pub soc: u8,

    #[bits(1, access = RO, default = 0)]
    not_used0: u8,

    /// FIFO Enable.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub fifo_en: u8,

    /// Embedded Functions Enable.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub emb_func_en: u8,

    /// Block Data Update.
    ///
    /// 0: Continuous update (default); 1: Output registers not updated until both MSByte and LSByte are read.
    #[bits(1)]
    pub bdu: u8,

    /// Inactivity ODR Selection.
    ///
    /// Selects the accelerometer ODR during inactivity status.
    #[bits(2)]
    pub inact_odr: u8,
}

/// Control Register 5 (R/W).
///
/// The `CTRL5` register configures the output data rate, bandwidth, and full-scale settings.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Ctrl5, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Ctrl5 {
    /// Full Scale Selection.
    ///
    /// Sets the full scale of the accelerometer.
    #[bits(2)]
    pub fs: u8,

    /// Bandwidth Selection.
    ///
    /// Selects the bandwidth of the device.
    #[bits(2)]
    pub bw: u8,

    /// Output Data Rate Selection.
    ///
    /// Sets the output data rate of the device.
    #[bits(4)]
    pub odr: u8,
}

/// FIFO Control Register (R/W).
///
/// The `FIFO_CTRL` register configures the FIFO settings, including mode, depth, and configuration change enable.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FifoCtrl, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoCtrl {
    /// FIFO Mode Selection.
    ///
    /// Different FIFO modes are enabled as shown in the datasheet.
    #[bits(3)]
    pub fifo_mode: u8,

    /// Stop on FIFO Threshold.
    ///
    /// 0: FIFO depth is not limited (default); 1: FIFO depth is limited to threshold level.
    #[bits(1)]
    pub stop_on_fth: u8,

    #[bits(1, access = RO, default = 0)]
    not_used0: u8,

    /// Disable Hard Reset on CS Pin.
    ///
    /// If 0, resetting the CS pin is equivalent to performing a deep power-off command. If 1, resetting the CS pin has no effect.
    #[bits(1)]
    pub dis_hard_rst_cs: u8,

    /// FIFO Depth Mode.
    ///
    /// If 1, enables 2x depth mode for FIFO buffer.
    #[bits(1)]
    pub fifo_depth: u8,

    /// Configuration Change Enable.
    ///
    /// Enables batching in FIFO of the device configuration and timestamp value when the ODR or BDR changes.
    #[bits(1)]
    pub cfg_chg_en: u8,
}

/// FIFO Watermark Register (R/W).
///
/// The `FIFO_WTM` register sets the FIFO watermark threshold and data configuration.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FifoWtm, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoWtm {
    /// FIFO Watermark Threshold.
    ///
    /// Maximum value is 127.
    #[bits(7)]
    pub fth: u8,

    /// Accelerometer Only FIFO.
    ///
    /// 0: Accelerometer and temperature/AH/Qvar data are stored in FIFO (default); 1: Only accelerometer data are stored in FIFO.
    #[bits(1)]
    pub xl_only_fifo: u8,
}

/// Interrupt Configuration Register (R/W).
///
/// The `INTERRUPT_CFG` register configures interrupt settings, including enabling interrupts and timestamp counter.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::InterruptCfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct InterruptCfg {
    /// Interrupts Enable.
    ///
    /// Enables basic interrupts (6D/4D, free-fall, wake-up, single/double/triple-tap, activity/inactivity).
    #[bits(1)]
    pub interrupts_enable: u8,

    /// Latched Interrupt Mode.
    ///
    /// 0: Interrupt level mode; 1: Interrupt latched mode.
    #[bits(1)]
    pub lir: u8,

    /// Disable Reset of Interrupt Flags.
    ///
    /// If 1, disables the reset of the interrupt flags when ALL_INT_SRC is read.
    #[bits(1)]
    pub dis_rst_lir_all_int: u8,

    /// Sleep Status on INT Pins.
    ///
    /// Sends the sleep status instead of sleep change to INT pins.
    #[bits(1)]
    pub sleep_status_on_int: u8,

    #[bits(1, access = RO, default = 0)]
    not_used0: u8,

    /// Wake-Up Threshold Weight.
    ///
    /// 0: 1 LSB = FS_XL / (2^6); 1: 1 LSB = FS_XL / (2^8).
    #[bits(1)]
    pub wake_ths_w: u8,

    #[bits(1, access = RO, default = 0)]
    not_used1: u8,

    /// Timestamp Enable.
    ///
    /// Enables timestamp counter. The counter is readable in TIMESTAMP0, TIMESTAMP1, TIMESTAMP2, and TIMESTAMP3.
    #[bits(1)]
    pub timestamp_en: u8,
}

/// 6D/4D Configuration Register (R/W).
///
/// The `SIXD` register configures the thresholds and enables 4D orientation detection.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Sixd, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Sixd {
    #[bits(5, access = RO, default = 0)]
    not_used0: u8,

    /// 6D/4D Thresholds.
    ///
    /// Sets the thresholds for 4D/6D function.
    #[bits(2)]
    pub d6d_ths: u8,

    /// 4D Orientation Detection Enable.
    ///
    /// 0: Disabled; 1: Enabled.
    #[bits(1)]
    pub d4d_en: u8,
}

/// Wake-Up Threshold Register (R/W).
///
/// The `WAKE_UP_THS` register sets the threshold for wake-up detection and enables activity/inactivity function.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::WakeUpThs, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpThs {
    /// Wake-Up Threshold.
    ///
    /// Threshold for wake-up detection. 1 LSB weight depends on WAKE_THS_W in INTERRUPT_CFG.
    #[bits(6)]
    pub wk_ths: u8,

    /// Activity/Inactivity Function Enable.
    ///
    /// If 1, activity/inactivity function is enabled.
    #[bits(1)]
    pub sleep_on: u8,

    #[bits(1, access = RO, default = 0)]
    not_used0: u8,
}

/// Wake-Up Duration Register (R/W).
///
/// The `WAKE_UP_DUR` register configures the duration settings for sleep and wake-up events, as well as the self-test sign for the Z-axis.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::WakeUpDur, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpDur {
    /// Sleep Duration.
    ///
    /// Duration to go into sleep mode. Default value: 0000 which corresponds to 16 ODR_time.
    #[bits(4)]
    pub sleep_dur: u8,

    /// Self-Test Sign for Z-Axis.
    ///
    /// Configures the sign of the self-test for the Z-axis.
    #[bits(1)]
    pub st_sign_z: u8,

    /// Wake-Up Duration.
    ///
    /// Duration for wake-up event detection.
    #[bits(2)]
    pub wake_dur: u8,

    /// Free-Fall Duration.
    ///
    /// Duration for free-fall event detection.
    #[bits(1)]
    pub ff_dur: u8,
}

/// Free-Fall Register (R/W).
///
/// The `FREE_FALL` register configures the threshold and duration for free-fall event detection.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FreeFall, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FreeFall {
    /// Free-Fall Threshold.
    ///
    /// Sets the threshold for free-fall detection.
    #[bits(3)]
    pub ff_ths: u8,

    /// Free-Fall Duration.
    ///
    /// Sets the duration for free-fall detection.
    #[bits(5)]
    pub ff_dur: u8,
}

/// MD1 Configuration Register (R/W).
///
/// The `MD1_CFG` register configures the interrupt signals routed to the INT1 pin.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Md1Cfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Md1Cfg {
    /// Embedded Functions Interrupt on INT1.
    ///
    /// Enables routing embedded functions event to the INT1 pin.
    #[bits(1)]
    pub int1_emb_func: u8,

    /// Timestamp Interrupt on INT1.
    ///
    /// Enables routing the alert of timestamp overflow to the INT1 pin.
    #[bits(1)]
    pub int1_timestamp: u8,

    /// 6D Recognition Interrupt on INT1.
    ///
    /// Enables routing 6D recognition event to the INT1 pin.
    #[bits(1)]
    pub int1_6d: u8,

    /// Tap Interrupt on INT1.
    ///
    /// Enables routing tap event to the INT1 pin.
    #[bits(1)]
    pub int1_tap: u8,

    /// Free-Fall Interrupt on INT1.
    ///
    /// Enables routing free-fall event to the INT1 pin.
    #[bits(1)]
    pub int1_ff: u8,

    /// Wake-Up Interrupt on INT1.
    ///
    /// Enables routing wake-up event to the INT1 pin.
    #[bits(1)]
    pub int1_wu: u8,

    #[bits(1, access = RO, default = 0)]
    not_used0: u8,

    /// Sleep Change Interrupt on INT1.
    ///
    /// Enables sleep change (or sleep status) on INT1 pin.
    #[bits(1)]
    pub int1_sleep_change: u8,
}

/// MD2 Configuration Register (R/W).
///
/// The `MD2_CFG` register configures the interrupt signals routed to the INT2 pin.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Md2Cfg, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Md2Cfg {
    /// Embedded Functions Interrupt on INT2.
    ///
    /// Enables routing embedded functions event to the INT2 pin.
    #[bits(1)]
    pub int2_emb_func: u8,

    /// Timestamp Interrupt on INT2.
    ///
    /// Enables routing the alert of timestamp overflow to the INT2 pin.
    #[bits(1)]
    pub int2_timestamp: u8,

    /// 6D Recognition Interrupt on INT2.
    ///
    /// Enables routing 6D recognition event to the INT2 pin.
    #[bits(1)]
    pub int2_6d: u8,

    /// Tap Interrupt on INT2.
    ///
    /// Enables routing tap event to the INT2 pin.
    #[bits(1)]
    pub int2_tap: u8,

    /// Free-Fall Interrupt on INT2.
    ///
    /// Enables routing free-fall event to the INT2 pin.
    #[bits(1)]
    pub int2_ff: u8,

    /// Wake-Up Interrupt on INT2.
    ///
    /// Enables routing wake-up event to the INT2 pin.
    #[bits(1)]
    pub int2_wu: u8,

    #[bits(1, access = RO, default = 0)]
    not_used0: u8,

    /// Sleep Change Interrupt on INT2.
    ///
    /// Enables sleep change (or sleep status) on INT2 pin.
    #[bits(1)]
    pub int2_sleep_change: u8,
}

/// Wake-Up Source Register (R).
///
/// The `WAKE_UP_SRC` register provides the status of wake-up events detected by the sensor.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::WakeUpSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct WakeUpSrc {
    /// Z-Axis Wake-Up Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1)]
    pub z_wu: u8,

    /// Y-Axis Wake-Up Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1)]
    pub y_wu: u8,

    /// X-Axis Wake-Up Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1)]
    pub x_wu: u8,

    /// Wake-Up Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1)]
    pub wu_ia: u8,

    /// Sleep Status.
    ///
    /// 0: Activity status; 1: Inactivity status.
    #[bits(1)]
    pub sleep_state: u8,

    /// Free-Fall Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1)]
    pub ff_ia: u8,

    /// Sleep Change Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1)]
    pub sleep_change_ia: u8,

    #[bits(1, access = RO)]
    not_used0: u8,
}

/// Tap Source Register (R).
///
/// The `TAP_SRC` register provides the status of tap events detected by the sensor.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapSrc {
    #[bits(4, access = RO)]
    not_used0: u8,

    /// Triple-Tap Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub triple_tap_ia: u8,

    /// Double-Tap Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub double_tap_ia: u8,

    /// Single-Tap Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub single_tap_ia: u8,

    /// Tap Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub tap_ia: u8,
}

/// 6D Source Register (R).
///
/// The `SIXD_SRC` register provides the status of 6D/4D orientation events detected by the sensor.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::SixdSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct SixdSrc {
    /// X-Axis Low Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub xl: u8,

    /// X-Axis High Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub xh: u8,

    /// Y-Axis Low Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub yl: u8,

    /// Y-Axis High Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub yh: u8,

    /// Z-Axis Low Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub zl: u8,

    /// Z-Axis High Event.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub zh: u8,

    /// 6D/4D Orientation Change.
    ///
    /// 0: Not detected; 1: Detected.
    #[bits(1, access = RO)]
    pub d6d_ia: u8,

    #[bits(1, access = RO)]
    not_used0: u8,
}

/// All Interrupt Source Register (R).
///
/// The `ALL_INT_SRC` register provides the status of all interrupt events detected by the sensor.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::AllIntSrc, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct AllIntSrc {
    /// Free-Fall Interrupt Status.
    ///
    /// 0: Event not detected; 1: Event detected.
    #[bits(1, access = RO)]
    pub ff_ia_all: u8,

    /// Wake-Up Interrupt Status.
    ///
    /// 0: Event not detected; 1: Event detected.
    #[bits(1, access = RO)]
    pub wu_ia_all: u8,

    /// Single-Tap Interrupt Status.
    ///
    /// 0: Event not detected; 1: Event detected.
    #[bits(1, access = RO)]
    pub single_tap_all: u8,

    /// Double-Tap Interrupt Status.
    ///
    /// 0: Event not detected; 1: Event detected.
    #[bits(1, access = RO)]
    pub double_tap_all: u8,

    /// Triple-Tap Interrupt Status.
    ///
    /// 0: Event not detected; 1: Event detected.
    #[bits(1, access = RO)]
    pub triple_tap_all: u8,

    /// 6D/4D Orientation Change Interrupt Status.
    ///
    /// 0: Event not detected; 1: Event detected.
    #[bits(1, access = RO)]
    pub d6d_ia_all: u8,

    /// Sleep Change Interrupt Status.
    ///
    /// 0: Event not detected; 1: Event detected.
    #[bits(1, access = RO)]
    pub sleep_change_ia_all: u8,

    #[bits(1, access = RO)]
    not_used0: u8,
}

/// Status Register (R).
///
/// The `STATUS` register provides the status of data readiness and global interrupt events.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Status, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct StatusRegister {
    /// Data Ready Status.
    ///
    /// 0: No new data; 1: New accelerometer data is available.
    #[bits(1, access = RO)]
    pub drdy: u8,

    #[bits(4, access = RO)]
    not_used0: u8,

    /// Global Interrupt Status.
    ///
    /// 0: No interrupt; 1: One of the following events has occurred: activity/inactivity status change, 6D/4D orientation change, tap event, wake-up event, free-fall event, or sleep event.
    #[bits(1, access = RO)]
    pub int_global: u8,

    #[bits(2, access = RO)]
    not_used1: u8,
}

/// FIFO Status Register 1 (R).
///
/// The `FIFO_STATUS1` register provides the status of FIFO events, including overrun and watermark status.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FifoStatus1, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoStatus1 {
    #[bits(6, access = RO)]
    not_used0: u8,

    /// FIFO Overrun Status.
    ///
    /// 0: No overrun; 1: FIFO has overwritten data.
    #[bits(1, access = RO)]
    pub fifo_ovr_ia: u8,

    /// FIFO Watermark Status.
    ///
    /// 0: FIFO filling is lower than WTM; 1: FIFO filling is equal to or higher than WTM.
    #[bits(1, access = RO)]
    pub fifo_wtm_ia: u8,
}

/// FIFO Status Register 2 (R).
///
/// The `FIFO_STATUS2` register provides the number of unread data stored in the FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FifoStatus2, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoStatus2 {
    /// FIFO Sample Status.
    ///
    /// Number of unread data stored in FIFO.
    #[bits(8, access = RO)]
    pub fss: u8,
}

/// X-Axis Output Register (R).
///
/// The `OUT_X_L` and `OUT_X_H` registers provides the bits of the X-axis data output.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::OutXL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutX {
    /// X Data Output.
    #[bits(16, access = RO)]
    pub outx: u16,
}

/// Y-Axis Output Low Register (R).
///
/// The `OUT_Y_L` and `OUT_Y_H` registers provides the bits of the Y-axis data output.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::OutYL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutY {
    /// Y Data Output.
    #[bits(16, access = RO)]
    pub outy: u16,
}

/// Z-Axis Output Low Register (R).
///
/// The `OUT_Z_L` and `OUT_Z_H` registers provides the bits of the Z-axis data output.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::OutZL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutZ {
    /// Z Data Output.
    #[bits(16, access = RO)]
    pub outz: u16,
}

/// Temperature Output Low Register (R).
///
/// The `OUT_T_L` and `OUT_T_H` registers provides the bits of the temperature data output.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::OutTL, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u16, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u16, order = Lsb))]
pub struct OutT {
    /// Temperature Data Output.
    #[bits(16, access = RO)]
    pub outt: u16,
}

/// Self-Test Register (R/W).
///
/// The `SELF_TEST` register configures the self-test procedure and disables the temperature acquisition chain.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::SelfTest, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct SelfTest {
    /// Temperature Acquisition Chain Disable.
    ///
    /// 0: Acquisition chain enabled; 1: Acquisition chain disabled.
    #[bits(1)]
    pub t_dis: u8,

    #[bits(3, access = RO)]
    not_used0: u8,

    /// Self-Test Enable.
    ///
    /// Enables data acquisition during the self-test procedure.
    #[bits(2)]
    pub st: u8,

    #[bits(2, access = RO)]
    not_used1: u8,
}

/// I3C Interface Control Register (R/W).
///
/// The `I3C_IF_CTRL` register configures the I3C interface settings, including bus activity selection and antispike filter.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::I3cIfCtrl, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct I3cIfCtrl {
    /// Bus Activity Selection.
    ///
    /// Selects the bus available time for in-band interrupt (IBI).
    #[bits(2, default = 0b01)]
    pub bus_act_sel: u8,

    #[bits(3, access = RO)]
    not_used0: u8,

    /// Antispike Filter Enable.
    ///
    /// Enables the antispike filter even if the dynamic address is assigned.
    #[bits(1)]
    pub asf_on: u8,

    #[bits(1, access = RO)]
    not_used1: u8,

    /// Disable Direct RSTDAA.
    ///
    /// 0: Direct RSTDAA supported; 1: Direct RSTDAA disabled.
    #[bits(1)]
    pub dis_drstdaa: u8,
}

/// Embedded Function Status Main Page Register (R).
///
/// The `EMB_FUNC_STATUS_MAINPAGE` register provides the status of various embedded function events detected by the sensor.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::EmbFuncStatusMainpage, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct EmbFuncStatusMainpage {
    #[bits(3, access = RO)]
    not_used0: u8,

    /// Step Detection Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_step_det: u8,

    /// Tilt Detection Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_tilt: u8,

    /// Significant Motion Detection Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_sigmot: u8,

    #[bits(1, access = RO)]
    not_used1: u8,

    /// FSM Long Counter Timeout Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm_lc: u8,
}

/// FSM Status Main Page Register (R).
///
/// The `FSM_STATUS_MAINPAGE` register provides the status of FSM interrupt events detected by the sensor.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FsmStatusMainpage, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FsmStatusMainpage {
    /// FSM1 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm1: u8,

    /// FSM2 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm2: u8,

    /// FSM3 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm3: u8,

    /// FSM4 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm4: u8,

    /// FSM5 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm5: u8,

    /// FSM6 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm6: u8,

    /// FSM7 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm7: u8,

    /// FSM8 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_fsm8: u8,
}

/// MLC Status Main Page Register (R).
///
/// The `MLC_STATUS_MAINPAGE` register provides the status of MLC interrupt events detected by the sensor.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::MlcStatusMainpage, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct MlcStatusMainpage {
    /// MLC1 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_mlc1: u8,

    /// MLC2 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_mlc2: u8,

    /// MLC3 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_mlc3: u8,

    /// MLC4 Interrupt Status.
    ///
    /// 0: No interrupt; 1: Interrupt detected.
    #[bits(1, access = RO)]
    pub is_mlc4: u8,

    #[bits(4, access = RO)]
    not_used0: u8,
}

/// Sleep Register (R/W).
///
/// The `SLEEP` register configures the deep power-down state of the device.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Sleep, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct Sleep {
    /// Deep Power-Down.
    ///
    /// If set to 1, the device enters a deep power-down state.
    #[bits(1)]
    pub deep_pd: u8,

    #[bits(7, access = RO, default = 0)]
    not_used0: u8,
}

/// Enable Device Configuration Register (W).
///
/// The `EN_DEVICE_CONFIG` register allows the transition from deep power-down to soft power-down when the SPI interface is used.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::EnDeviceConfig, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct EnDeviceConfig {
    /// Soft Power-Down.
    ///
    /// This bit is write-only and allows the transition from deep power-down to soft power-down.
    #[bits(1, access = WO)]
    pub soft_pd: u8,

    #[bits(7, access = RO)]
    not_used0: u8,
}

/// Function Configuration Access Register (R/W).
///
/// The `FUNC_CFG_ACCESS` register enables access to embedded function registers and FSM control.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FuncCfgAccess, access_type = "Lis2dux12<B, T, S>", multi_state = true)]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FuncCfgAccess {
    /// FSM Write Control Enable.
    ///
    /// Enables the FSM to control the CTRL registers autonomously.
    #[bits(1)]
    pub fsm_wr_ctrl_en: u8,

    #[bits(6, access = RO)]
    not_used0: u8,

    /// Embedded Function Register Access.
    ///
    /// Enables access to the embedded functions registers.
    #[bits(1)]
    pub emb_func_reg_access: u8,
}

/// FIFO Data Output Tag Register (R).
///
/// The `FIFO_DATA_OUT_TAG` register contains the TAG values that distinguish the different kinds of data that can be batched in FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FifoDataOutTag, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutTag {
    #[bits(3, access = RO)]
    not_used0: u8,

    /// Sensor Tag.
    ///
    /// Identifies the sensor in FIFO data output.
    #[bits(5)]
    pub tag_sensor: u8,
}

/// FIFO Data Output X Low Register (R).
///
/// The `FIFO_DATA_OUT_X_L` register provides the least significant bits of the X-axis data output from the FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutXL {
    /// FIFO X-Axis Data Output (LSBs).
    #[bits(8)]
    pub fifo_data_out: u8,
}

/// FIFO Data Output X High Register (R).
///
/// The `FIFO_DATA_OUT_X_H` register provides the most significant bits of the X-axis data output from the FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutXH {
    /// FIFO X-Axis Data Output (MSBs).
    #[bits(8)]
    pub fifo_data_out: u8,
}

/// FIFO Data Output Y Low Register (R).
///
/// The `FIFO_DATA_OUT_Y_L` register provides the least significant bits of the Y-axis data output from the FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutYL {
    /// FIFO Y-Axis Data Output (LSBs).
    #[bits(8)]
    pub fifo_data_out: u8,
}

/// FIFO Data Output Y High Register (R).
///
/// The `FIFO_DATA_OUT_Y_H` register provides the most significant bits of the Y-axis data output from the FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutYH {
    /// FIFO Y-Axis Data Output (MSBs).
    #[bits(8)]
    pub fifo_data_out: u8,
}

/// FIFO Data Output Z Low Register (R).
///
/// The `FIFO_DATA_OUT_Z_L` register provides the least significant bits of the Z-axis data output from the FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutZL {
    /// FIFO Z-Axis Data Output (LSBs).
    #[bits(8)]
    pub fifo_data_out: u8,
}

/// FIFO Data Output Z High Register (R).
///
/// The `FIFO_DATA_OUT_Z_H` register provides the most significant bits of the Z-axis data output from the FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoDataOutZH {
    /// FIFO Z-Axis Data Output (MSBs).
    #[bits(8)]
    pub fifo_data_out: u8,
}

/// FIFO Batch Decimation Register (R/W).
///
/// The `FIFO_BATCH_DEC` register configures the batch data rate for accelerometer data and the decimation for timestamp batching in FIFO.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::FifoBatchDec, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct FifoBatchDec {
    /// Batch Data Rate for Accelerometer.
    ///
    /// Selects the batch data rate (write frequency in FIFO) for accelerometer data.
    #[bits(3)]
    pub bdr_xl: u8,

    /// Decimation for Timestamp Batching.
    ///
    /// Selects decimation for timestamp batching in FIFO.
    #[bits(2)]
    pub dec_ts_batch: u8,

    #[bits(3, access = RO)]
    not_used0: u8,
}

/// Tap Configuration 0 Register (R/W).
///
/// The `TAP_CFG0` register configures the axis selection and inverted peak search for tap event detection.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapCfg0, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg0 {
    #[bits(1, access = RO)]
    not_used0: u8,

    /// Inverted Peak Search.
    ///
    /// Enables the search of the inverted peak by selecting the maximum number of samples between the first and second (inverted) peak in tap detection.
    #[bits(5)]
    pub invert_t: u8,

    /// Axis Selection for Tap Event.
    ///
    /// Selection of axis for tap event research.
    #[bits(2)]
    pub axis: u8,
}

/// Tap Configuration 1 Register (R/W).
///
/// The `TAP_CFG1` register configures the thresholds and samples for stationary conditions before and after shock.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapCfg1, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg1 {
    /// Post-Shock Stationary Samples.
    ///
    /// Number of samples during stationary condition after shock and wait phases.
    #[bits(4)]
    pub post_still_t: u8,

    /// Pre-Shock Stationary Threshold.
    ///
    /// Threshold for stationary condition before shock.
    #[bits(4)]
    pub pre_still_ths: u8,
}

/// Tap Configuration 2 Register (R/W).
///
/// The `TAP_CFG2` register configures the wait time for shock completion and post-shock stationary samples.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapCfg2, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg2 {
    /// Wait Time for Shock Completion.
    ///
    /// Programs the number of samples to wait for the shock to finish.
    #[bits(6)]
    pub wait_t: u8,

    /// Post-Shock Stationary Samples.
    ///
    /// Number of samples during stationary condition after shock and wait phases.
    #[bits(2)]
    pub post_still_t: u8,
}

/// Tap Configuration 3 Register (R/W).
///
/// The `TAP_CFG3` register configures the latency and thresholds for stationary conditions after shock.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapCfg3, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg3 {
    /// Latency for Consecutive Taps.
    ///
    /// Maximum number of samples between consecutive taps event to detect double or triple tap.
    #[bits(4)]
    pub latency_t: u8,

    /// Post-Shock Stationary Threshold.
    ///
    /// Threshold for stationary condition after shock and wait phases.
    #[bits(4)]
    pub post_still_ths: u8,
}

/// Tap Configuration 4 Register (R/W).
///
/// The `TAP_CFG4` register configures the peak detection threshold and latency window for tap events.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapCfg4, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg4 {
    /// Peak Detection Threshold.
    ///
    /// Threshold for peak detection.
    #[bits(6)]
    pub peak_ths: u8,

    #[bits(1, access = RO)]
    not_used0: u8,

    /// Wait End of Latency.
    ///
    /// Enables the feature to wait for the end of the latency window to determine the tap event level.
    #[bits(1)]
    pub wait_end_latency: u8,
}

/// Tap Configuration 5 Register (R/W).
///
/// The `TAP_CFG5` register configures the rebound time and enables single, double, and triple tap events.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapCfg5, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg5 {
    /// Rebound Time.
    ///
    /// Programs the number of samples to wait for the rebound to finish.
    #[bits(5)]
    pub rebound_t: u8,

    /// Single Tap Enable.
    ///
    /// Enables the single-tap event.
    #[bits(1)]
    pub single_tap_en: u8,

    /// Double Tap Enable.
    ///
    /// Enables the double-tap event.
    #[bits(1)]
    pub double_tap_en: u8,

    /// Triple Tap Enable.
    ///
    /// Enables the triple-tap event.
    #[bits(1)]
    pub triple_tap_en: u8,
}

/// Tap Configuration 6 Register (R/W).
///
/// The `TAP_CFG6` register configures the starting sample and number of samples for stationary conditions before shock.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::TapCfg6, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u8, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u8, order = Lsb))]
pub struct TapCfg6 {
    /// Pre-Shock Stationary Samples.
    ///
    /// Selection of number of samples for stationary condition before shock.
    #[bits(4)]
    pub pre_still_n: u8,

    /// Pre-Shock Stationary Starting Sample.
    ///
    /// Selection of starting sample for stationary condition before shock.
    #[bits(4)]
    pub pre_still_st: u8,
}

/// Timestamp Output Register 0-3 (R).
///
/// The `TIMESTAMP0-3` register provides the bytes of the timestamp output.
///
/// The bit order for this struct can be configured using the `bit_order_msb` feature:
/// * `Msb`: Most significant bit first.
/// * `Lsb`: Least significant bit first (default).
#[register(address = Reg::Timestamp0, access_type = "Lis2dux12<B, T, MainBank>")]
#[cfg_attr(feature = "bit_order_msb", bitfield(u32, order = Msb))]
#[cfg_attr(not(feature = "bit_order_msb"), bitfield(u32, order = Lsb))]
pub struct Timestamp {
    #[bits(32, access = RO)]
    pub timestamp: u32,
}

/// Represents the status of the device.
///
/// # Fields
///
/// - `sw_reset: u8`: Indicates the status of the software reset.
/// - `boot: u8`: Indicates the status of the boot process.
/// - `drdy: u8`: Indicates the data-ready status.
///
/// # Description
///
/// This struct encapsulates various status indicators of the device, providing information about
/// the software reset, boot process, data readiness, and power-down state.
pub struct Status {
    pub sw_reset: u8,
    pub boot: u8,
    pub drdy: u8,
}

/// Represents the sensor mode configuration.
///
/// # Fields
///
/// - `odr: Odr`: Specifies the output data rate (ODR).
/// - `fs: Fs`: Specifies the full-scale (FS) range.
/// - `bw: Bw`: Specifies the bandwidth (BW).
///
/// # Description
///
/// This struct encapsulates the sensor mode configuration, including settings for ODR, FS, and BW.
/// It is used to configure and retrieve the sensor's operational mode.
#[derive(Default)]
pub struct Md {
    pub odr: Odr,
    pub fs: Fs,
    pub bw: Bw,
}

/// Represents various source information from the device.
///
/// # Fields
///
/// - `drdy: u8`: Data-ready status.
/// - `timestamp: u8`: Timestamp (assumed 0).
/// - `free_fall: u8`: Free-fall detection status.
/// - `wake_up: u8`: Wake-up detection status.
/// - `wake_up_z: u8`: Wake-up detection on Z-axis.
/// - `wake_up_y: u8`: Wake-up detection on Y-axis.
/// - `wake_up_x: u8`: Wake-up detection on X-axis.
/// - `single_tap: u8`: Single tap detection status.
/// - `double_tap: u8`: Double tap detection status.
/// - `triple_tap: u8`: Triple tap detection status.
/// - `six_d: u8`: 6D detection status.
/// - `six_d_xl: u8`: 6D detection on X-axis low.
/// - `six_d_xh: u8`: 6D detection on X-axis high.
/// - `six_d_yl: u8`: 6D detection on Y-axis low.
/// - `six_d_yh: u8`: 6D detection on Y-axis high.
/// - `six_d_zl: u8`: 6D detection on Z-axis low.
/// - `six_d_zh: u8`: 6D detection on Z-axis high.
/// - `sleep_change: u8`: Sleep change status.
/// - `sleep_state: u8`: Sleep state status.
///
/// # Description
///
/// This struct encapsulates various source information from the device, including detection and
/// status indicators for events such as free-fall, wake-up, tap detection, 6D orientation, and FIFO status.
pub struct AllSources {
    pub drdy: u8,
    pub free_fall: u8,
    pub wake_up: u8,
    pub wake_up_z: u8,
    pub wake_up_y: u8,
    pub wake_up_x: u8,
    pub single_tap: u8,
    pub double_tap: u8,
    pub triple_tap: u8,
    pub six_d: u8,
    pub six_d_xl: u8,
    pub six_d_xh: u8,
    pub six_d_yl: u8,
    pub six_d_yh: u8,
    pub six_d_zl: u8,
    pub six_d_zh: u8,
    pub sleep_change: u8,
    pub sleep_state: u8,
}

/// Represents accelerometer data.
///
/// # Fields
///
/// - `mg: [f32; 3]`: Converted acceleration values in milli-g.
/// - `raw: [i16; 3]`: Raw acceleration data.
///
/// # Description
///
/// This struct encapsulates accelerometer data, providing both raw and converted values for each axis.
pub struct XlData {
    pub mg: [f32; 3],
    pub raw: [i16; 3],
}

/// Represents the I3C configuration parameters.
///
/// # Fields
///
/// - `bus_act_sel: BusActSel`: Specifies the bus activity selection.
/// - `asf_on: u8`: Indicates if asynchronous frame support is enabled.
/// - `drstdaa_en: u8`: Indicates if dynamic address assignment is disabled.
///
/// # Description
///
/// This struct encapsulates the configuration parameters for the I3C bus, allowing customization of
/// bus activity, asynchronous frame support, and dynamic address assignment.
pub struct I3cCfg {
    pub bus_act_sel: BusActSel,
    pub asf_on: u8,
    pub drstdaa_dis: u8,
}

/// Represents the electrical configuration for configurable pins.
///
/// # Fields
///
/// - `sdo_pull_up: u8`: Indicates if the SDO pin pull-up is enabled.
/// - `sda_pull_up: u8`: Indicates if the SDA pin pull-up is enabled.
/// - `cs_pull_up: u8`: Indicates if the CS pin pull-up is enabled.
/// - `int1_int2_push_pull: u8`: Indicates if INT1 and INT2 pins are configured as push-pull.
/// - `int1_pull_down: u8`: Indicates if the INT1 pin pull-down is enabled.
/// - `int2_pull_down: u8`: Indicates if the INT2 pin pull-down is enabled.
///
/// # Description
///
/// This struct encapsulates the electrical configuration for configurable pins, allowing customization
/// of pull-up and pull-down settings.
pub struct PinConf {
    pub sdo_pull_up: u8,
    pub sda_pull_up: u8,
    pub cs_pull_up: u8,
    pub int1_int2_push_pull: u8,
    pub int1_pull_down: u8,
    pub int2_pull_down: u8,
}

/// Represents the interrupt signals routing configuration for the INT1 pin.
///
/// # Fields
///
/// - `int_on_res: u8`: Indicates if the interrupt is routed on the resolution.
/// - `drdy: u8`: Data-ready interrupt.
/// - `boot: u8`: Boot interrupt.
/// - `fifo_th: u8`: FIFO threshold interrupt.
/// - `fifo_ovr: u8`: FIFO overrun interrupt.
/// - `fifo_full: u8`: FIFO full interrupt.
/// - `free_fall: u8`: Free-fall interrupt.
/// - `six_d: u8`: 6D orientation interrupt.
/// - `tap: u8`: Tap interrupt.
/// - `wake_up: u8`: Wake-up interrupt.
/// - `sleep_change: u8`: Sleep change interrupt.
/// - `emb_function: u8`: Embedded function interrupt.
/// - `timestamp: u8`: Timestamp interrupt.
///
/// # Description
///
/// This struct encapsulates the interrupt signals routing configuration for the INT1 pin, allowing
/// customization of various interrupt sources.
#[derive(Default)]
pub struct PinInt1Route {
    pub int_on_res: u8,
    pub drdy: u8,
    pub boot: u8,
    pub fifo_th: u8,
    pub fifo_ovr: u8,
    pub fifo_full: u8,
    pub free_fall: u8,
    pub six_d: u8,
    pub tap: u8,
    pub wake_up: u8,
    pub sleep_change: u8,
    pub emb_function: u8,
    pub timestamp: u8,
}

/// Represents the interrupt signals routing configuration for the INT2 pin.
///
/// # Fields
///
/// - `drdy: u8`: Data-ready interrupt.
/// - `boot: u8`: Boot interrupt.
/// - `fifo_th: u8`: FIFO threshold interrupt.
/// - `fifo_ovr: u8`: FIFO overrun interrupt.
/// - `fifo_full: u8`: FIFO full interrupt.
/// - `free_fall: u8`: Free-fall interrupt.
/// - `six_d: u8`: 6D orientation interrupt.
/// - `tap: u8`: Tap interrupt.
/// - `wake_up: u8`: Wake-up interrupt.
/// - `sleep_change: u8`: Sleep change interrupt.
/// - `emb_function: u8`: Embedded function interrupt.
/// - `timestamp: u8`: Timestamp interrupt.
///
/// # Description
///
/// This struct encapsulates the interrupt signals routing configuration for the INT2 pin, allowing
/// customization of various interrupt sources.
#[derive(Default)]
pub struct PinInt2Route {
    pub drdy: u8,
    pub boot: u8,
    pub fifo_th: u8,
    pub fifo_ovr: u8,
    pub fifo_full: u8,
    pub free_fall: u8,
    pub six_d: u8,
    pub tap: u8,
    pub wake_up: u8,
    pub sleep_change: u8,
    pub emb_function: u8,
    pub timestamp: u8,
}

/// Represents the interrupt configuration settings.
///
/// # Fields
///
/// - `int_cfg: IntCfg`: Specifies the interrupt mode (disabled, level-sensitive, or latched).
/// - `sleep_status_on_int: u8`: Indicates if sleep status is reported on interrupt.
/// - `dis_rst_lir_all_int: u8`: Indicates if reset on latch interrupt is disabled.
///
/// # Description
///
/// This struct encapsulates the interrupt configuration settings, allowing customization of the
/// interrupt mode and additional settings.
#[derive(Default)]
pub struct IntConfig {
    pub int_cfg: IntCfg,
    pub sleep_status_on_int: u8,
    pub dis_rst_lir_all_int: u8,
}

/// Represents the configuration settings for the 4D/6D detection function.
///
/// # Fields
///
/// - `threshold: Threshold`: The threshold for 4D/6D detection.
/// - `mode: Mode`: The mode of detection (4D or 6D).
///
/// # Description
///
/// This struct encapsulates the configuration settings for the 4D/6D detection function, allowing customization
/// of the detection mode and threshold.
#[derive(Default, Clone)]
pub struct SixdConfig {
    pub threshold: Threshold,
    pub mode: Mode,
}

/// Represents the configuration settings for the wakeup function.
///
/// # Fields
///
/// - `wake_dur: WakeDur`: The wake duration setting.
/// - `sleep_dur: u8`: The sleep duration setting.
/// - `wake_ths: u8`: The wake threshold setting.
/// - `wake_ths_weight: u8`: The weight of the wake threshold.
/// - `wake_enable: WakeEnable`: Indicates if the wakeup function is enabled.
/// - `inact_odr: InactOdr`: The inactivity ODR setting.
///
/// # Description
///
/// This struct encapsulates the configuration settings for the wakeup function, allowing customization
/// of wake duration, sleep duration, wake threshold, and inactivity ODR.
#[derive(Default, Clone)]
pub struct WakeupConfig {
    pub wake_dur: WakeDur,
    pub sleep_dur: u8,
    pub wake_ths: u8,
    pub wake_ths_weight: u8,
    pub wake_enable: WakeEnable,
    pub inact_odr: InactOdr,
}

/// Represents the configuration settings for tap detection.
///
/// # Fields
///
/// - `axis: Axis`: Specifies the axis for tap detection (X, Y, Z, or none).
/// - `inverted_peak_time: u8`: Inverted peak time for tap detection.
/// - `pre_still_ths: u8`: Pre-still threshold.
/// - `post_still_ths: u8`: Post-still threshold.
/// - `post_still_time: u8`: Post-still time.
/// - `shock_wait_time: u8`: Shock wait time.
/// - `latency: u8`: Latency time.
/// - `wait_end_latency: u8`: Wait end latency.
/// - `peak_ths: u8`: Peak threshold.
/// - `rebound: u8`: Rebound time.
/// - `pre_still_start: u8`: Pre-still start time.
/// - `pre_still_n: u8`: Pre-still N value.
/// - `single_tap_on: u8`: Enables single tap detection.
/// - `double_tap_on: u8`: Enables double tap detection.
/// - `triple_tap_on: u8`: Enables triple tap detection.
///
/// # Description
///
/// This struct encapsulates the configuration settings for tap detection, allowing customization of
/// axis selection, thresholds, timings, and enabling single, double, or triple tap detection.
pub struct TapConfig {
    pub axis: Axis,
    pub inverted_peak_time: u8,
    pub pre_still_ths: u8,
    pub post_still_ths: u8,
    pub post_still_time: u8,
    pub shock_wait_time: u8,
    pub latency: u8,
    pub wait_end_latency: u8,
    pub peak_ths: u8,
    pub rebound: u8,
    pub pre_still_start: u8,
    pub pre_still_n: u8,
    pub single_tap_on: u8,
    pub double_tap_on: u8,
    pub triple_tap_on: u8,
}

/// Represents OUTT data.
///
/// # Fields
///
/// - `heat: Heat`: Contains temperature data.
///
/// # Description
///
/// This struct encapsulates OUTT data, providing temperature information through a `Heat` struct.
#[derive(Default)]
pub struct OuttData {
    pub heat: Heat,
}

/// Represents temperature data.
///
/// # Fields
///
/// - `deg_c: f32`: Temperature in degrees Celsius.
/// - `raw: i16`: Raw temperature data.
///
/// # Description
///
/// This struct encapsulates temperature data, providing both raw and converted values.
#[derive(Default)]
pub struct Heat {
    pub deg_c: f32,
    pub raw: i16,
}

/// Represents the FIFO mode configuration.
///
/// # Fields
///
/// - `operation: FifoOperation`: Specifies the FIFO operation mode.
/// - `store: Store`: Specifies the storage depth (1X or 2X).
/// - `xl_only: u8`: Indicates if only XL samples (16-bit) are stored in the FIFO.
/// - `watermark: u8`: The FIFO watermark level (0 to disable).
/// - `cfg_change_in_fifo: u8`: Indicates if configuration changes are stored in the FIFO.
/// - `fifo_event: FifoEvent`: Specifies the FIFO event type (watermark or full).
/// - `batch: Batch`: Contains batching information for timestamp and accelerometer data rate.
///
/// # Description
///
/// This struct encapsulates the FIFO mode configuration, allowing customization of operation mode,
/// storage depth, watermark, and batching settings.
#[derive(Default)]
pub struct FifoMode {
    pub operation: FifoOperation,
    pub store: Store,
    pub xl_only: u8,
    pub cfg_change_in_fifo: u8,
}

/// Represents batching information for the FIFO.
///
/// # Fields
///
/// - `dec_ts: DecTs`: Specifies the decimation for timestamp batching.
/// - `bdr_xl: BdrXl`: Specifies the accelerometer batch data rate.
///
/// # Description
///
/// This struct encapsulates batching information for the FIFO, allowing customization of timestamp
/// decimation and accelerometer data rate.
#[derive(Default)]
pub struct Batch {
    pub dec_ts: DecTs,
    pub bdr_xl: BdrXl,
}

/// Represents the processed FIFO data.
///
/// # Fields
///
/// - `tag: u8`: The sensor tag.
/// - `xl: [Xl; 2]`: Accelerometer data for two samples.
/// - `heat: Heat`: Temperature data.
/// - `pedo: Pedo`: Pedometer data.
/// - `cfg_chg: CfgChg`: Configuration change data.
///
/// # Description
///
/// This struct encapsulates the processed FIFO data, including accelerometer, AH_QVAR, temperature,
/// pedometer, and configuration change information.
#[derive(Default)]
pub struct FifoData {
    pub tag: u8,
    pub xl: [Xl; 2],
    pub heat: Heat,
    pub pedo: Pedo,
    pub cfg_chg: CfgChg,
}

/// Represents accelerometer data.
///
/// # Fields
///
/// - `mg: [f32; 3]`: Converted acceleration values in milli-g.
/// - `raw: [i16; 3]`: Raw acceleration data.
///
/// # Description
///
/// This struct encapsulates accelerometer data, providing both raw and converted values for each axis.
#[derive(Default)]
pub struct Xl {
    pub mg: [f32; 3],
    pub raw: [i16; 3],
}

/// Represents AH_QVAR data.
///
/// # Fields
///
/// - `mv: f32`: Converted voltage in millivolts.
/// - `raw: i16`: Raw AH_QVAR data.
///
/// # Description
///
/// This struct encapsulates AH_QVAR data, providing both raw and converted voltage values.
#[derive(Default)]
pub struct AhQvar {
    pub mv: f32,
    pub raw: i16,
}

/// Represents pedometer data.
///
/// # Fields
///
/// - `steps: u32`: The number of steps counted.
/// - `timestamp: u32`: The timestamp associated with the step count.
///
/// # Description
///
/// This struct encapsulates pedometer data, providing step count and timestamp information.
#[derive(Default)]
pub struct Pedo {
    pub steps: u32,
    pub timestamp: u32,
}

/// Represents configuration change data.
///
/// # Fields
///
/// - `cfg_change: u8`: Indicates if a configuration change occurred (1 bit).
/// - `odr: u8`: Output data rate (4 bits).
/// - `bw: u8`: Bandwidth (2 bits).
/// - `lp_hp: u8`: Low-power/high-performance mode (1 bit).
/// - `fs: u8`: Full-scale range (2 bits).
/// - `dec_ts: u8`: Decimation for timestamp batching (2 bits).
/// - `odr_xl_batch: u8`: Output data rate for accelerometer batching (1 bit).
/// - `timestamp: u32`: The timestamp associated with the configuration change.
///
/// # Description
///
/// This struct encapsulates configuration change data, providing detailed information about changes
/// in sensor settings and associated timestamps.
#[derive(Default)]
pub struct CfgChg {
    pub cfg_change: u8,
    pub odr: u8,
    pub bw: u8,
    pub lp_hp: u8,
    pub fs: u8,
    pub dec_ts: u8,
    pub odr_xl_batch: u8,
    pub timestamp: u32,
}

/// Represents the bus activity selection for the I3C interface.
///
/// # Variants
///
/// - `_20us`: Bus available time of 20 microseconds.
/// - `_50us`: Bus available time of 50 microseconds.
/// - `_1ms`: Bus available time of 1 millisecond.
/// - `_25ms`: Bus available time of 25 milliseconds.
///
/// # Description
///
/// This enum is used to specify the bus activity selection for the I3C interface, determining the
/// available time for bus operations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum BusActSel {
    _20us = 0x0,
    #[default]
    _50us = 0x1,
    _1ms = 0x2,
    _25ms = 0x3,
}

/// Represents the interrupt configuration modes.
///
/// # Variants
///
/// - `Disabled`: Interrupts are disabled.
/// - `Level`: Interrupts are level-sensitive.
/// - `Latched`: Interrupts are latched.
///
/// # Description
///
/// This enum is used to specify the interrupt configuration mode, allowing for disabled, level-sensitive,
/// or latched interrupt settings.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default)]
pub enum IntCfg {
    #[default]
    Disabled = 0x0,
    Level = 0x1,
    Latched = 0x2,
}

/// Represents the threshold options for 4D/6D detection.
///
/// # Variants
///
/// - `_80deg`: 80-degree threshold.
/// - `_70deg`: 70-degree threshold.
/// - `_60deg`: 60-degree threshold.
/// - `_50deg`: 50-degree threshold.
///
/// # Description
///
/// This enum is used to specify the threshold for 4D/6D detection, allowing for various sensitivity levels.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Threshold {
    #[default]
    _80deg = 0x0,
    _70deg = 0x1,
    _60deg = 0x2,
    _50deg = 0x3,
}

/// Represents the mode options for 4D/6D detection.
///
/// # Variants
///
/// - `_6d`: 6D detection mode.
/// - `_4d`: 4D detection mode.
///
/// # Description
///
/// This enum is used to specify the mode for 4D/6D detection, allowing for either 4D or 6D configurations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Mode {
    #[default]
    _6d = 0x0,
    _4d = 0x1,
}

/// Represents the wake duration options for the wakeup interrupt.
///
/// # Variants
///
/// - `_0Odr`: 0 ODR time.
/// - `_1Odr`: 1 ODR time.
/// - `_2Odr`: 2 ODR time.
/// - `_3Odr`: 3 ODR time (when `WU_DUR_EXTENDED` is set).
/// - `_7Odr`: 7 ODR time (when `WU_DUR_EXTENDED` is set).
/// - `_11Odr`: 11 ODR time (when `WU_DUR_EXTENDED` is set).
/// - `_15Odr`: 15 ODR time (when `WU_DUR_EXTENDED` is set).
///
/// # Description
///
/// This enum is used to specify the wake duration for the wakeup interrupt. The wake duration defines
/// the minimum time that the accelerometer data must exceed the configured threshold to generate a
/// wakeup interrupt. The duration is expressed in multiples of the accelerometer output data rate (ODR).
///
/// The duration can be extended by setting the `WU_DUR_EXTENDED` bit in the `WAKE_UP_DUR_EXT` register.
/// When extended, the durations are selectable as 3, 7, 11, or 15 ODR times.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default)]
pub enum WakeDur {
    #[default]
    _0Odr,
    _1Odr,
    _2Odr,
    _3Odr,
    _7Odr,
    _11Odr,
    _15Odr,
}

impl WakeDur {
    /// Retrieves the extended wake duration bit (`WU_DUR_EXTENDED`).
    ///
    /// # Returns
    ///
    /// - `u8`:
    ///   - `0`: Indicates that the wake duration is not extended.
    ///   - `1`: Indicates that the wake duration is extended.
    ///
    /// # Description
    ///
    /// This function determines whether the wake duration is extended by checking the `WU_DUR_EXTENDED` bit.
    /// Extended durations allow for longer wakeup times (3, 7, 11, or 15 ODR times).
    pub fn wake_up_dur_ext(&self) -> u8 {
        match self {
            WakeDur::_0Odr | WakeDur::_1Odr | WakeDur::_2Odr => 0x0,
            WakeDur::_3Odr | WakeDur::_7Odr | WakeDur::_11Odr | WakeDur::_15Odr => 0x1,
        }
    }

    /// Retrieves the wake duration value (`WAKE_DUR`).
    ///
    /// # Returns
    ///
    /// - `u8`: The wake duration value corresponding to the selected duration.
    ///
    /// # Description
    ///
    /// This function retrieves the wake duration value based on the selected duration. The value is used
    /// to configure the `WAKE_DUR` bits in the `WAKE_UP_DUR` register.
    pub fn wake_dur(&self) -> u8 {
        match self {
            WakeDur::_0Odr | WakeDur::_3Odr => 0x00,
            WakeDur::_1Odr | WakeDur::_7Odr => 0x01,
            WakeDur::_2Odr | WakeDur::_11Odr => 0x02,
            WakeDur::_15Odr => 0x03,
        }
    }

    /// Creates a new `WakeDur` instance based on the `WU_DUR_EXTENDED` bit and the `WAKE_DUR` value.
    ///
    /// # Arguments
    ///
    /// - `wup_dur_ext: u8`: The value of the `WU_DUR_EXTENDED` bit (0 or 1).
    /// - `wake_dur: u8`: The value of the `WAKE_DUR` bits.
    ///
    /// # Returns
    ///
    /// - `WakeDur`: The corresponding `WakeDur` variant.
    ///
    /// # Description
    ///
    /// This function creates a new `WakeDur` instance by interpreting the `WU_DUR_EXTENDED` bit and the
    /// `WAKE_DUR` value. It maps the combination of these values to the appropriate wake duration.
    pub fn new(wup_dur_ext: u8, wake_dur: u8) -> Self {
        match wake_dur {
            0x0 => {
                if wup_dur_ext == 1 {
                    WakeDur::_3Odr
                } else {
                    WakeDur::_0Odr
                }
            }
            0x1 => {
                if wup_dur_ext == 1 {
                    WakeDur::_7Odr
                } else {
                    WakeDur::_1Odr
                }
            }
            0x2 => {
                if wup_dur_ext == 1 {
                    WakeDur::_11Odr
                } else {
                    WakeDur::_2Odr
                }
            }
            _ => WakeDur::_15Odr,
        }
    }
}

/// Represents the wake enable options.
///
/// # Variants
///
/// - `SleepOff`: Wakeup function is disabled.
/// - `SleepOn`: Wakeup function is enabled.
///
/// # Description
///
/// This enum is used to specify whether the wakeup function is enabled or disabled.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum WakeEnable {
    #[default]
    SleepOff = 0,
    SleepOn = 1,
}

/// Represents the inactivity ODR options.
///
/// # Variants
///
/// - `NoChange`: No change in ODR.
/// - `_1_6hz`: 1.6 Hz ODR.
/// - `_3hz`: 3 Hz ODR.
/// - `_25hz`: 25 Hz ODR.
///
/// # Description
///
/// This enum is used to specify the inactivity ODR for the wakeup function.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum InactOdr {
    #[default]
    NoChange = 0,
    _1_6hz = 1,
    _3hz = 2,
    _25hz = 3,
}

/// Represents the axis selection for tap detection.
///
/// # Variants
///
/// - `TapNone`: No axis is selected for tap detection.
/// - `TapOnX`: Tap detection is enabled on the X-axis.
/// - `TapOnY`: Tap detection is enabled on the Y-axis.
/// - `TapOnZ`: Tap detection is enabled on the Z-axis.
///
/// # Description
///
/// This enum is used to specify the axis for tap detection, allowing for detection on the X, Y, or Z axis,
/// or disabling tap detection entirely.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Axis {
    #[default]
    TapNone = 0x0,
    TapOnX = 0x1,
    TapOnY = 0x2,
    TapOnZ = 0x3,
}

/// Represents the FIFO operation modes.
///
/// # Variants
///
/// - `BypassMode`: Bypass mode.
/// - `FifoMode`: FIFO mode.
/// - `StreamToFifoMode`: Stream-to-FIFO mo
/// - `BypassToStreamMode`: Bypass-to-stream mode.
/// - `StreamMode`: Stream mode.
/// - `BypassToFifoMode`: Bypass-to-FIFO mode.
/// - `FifoOff`: FIFO is off.
///
/// # Description
///
/// This enum is used to specify the FIFO operation mode, allowing for various configurations such
/// as bypass, FIFO, and stream modes.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FifoOperation {
    #[default]
    BypassMode = 0x0,
    FifoMode = 0x1,
    StreamToFifoMode = 0x3,
    BypassToStreamMode = 0x4,
    StreamMode = 0x6,
    BypassToFifoMode = 0x7,
    FifoOff = 0x8,
}

/// Represents the storage depth options for the FIFO.
///
/// # Variants
///
/// - `Fifo1x`: 1X storage depth.
/// - `Fifo2x`: 2X storage depth.
///
/// # Description
///
/// This enum is used to specify the storage depth for the FIFO, allowing for 1X or 2X configurations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Store {
    #[default]
    Fifo1x = 0,
    Fifo2x = 1,
}

/// Represents the decimation options for timestamp batching.
///
/// # Variants
///
/// - `Off`: Timestamp batching is off.
/// - `_1`: Decimation of 1.
/// - `_8`: Decimation of 8.
/// - `_32`: Decimation of 32.
///
/// # Description
///
/// This enum is used to specify the decimation for timestamp batching in the FIFO.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum DecTs {
    #[default]
    Off = 0x0,
    _1 = 0x1,
    _8 = 0x2,
    _32 = 0x3,
}

/// Represents the accelerometer batch data rate options.
///
/// # Variants
///
/// - `Odr`: Output data rate.
/// - `OdrDiv2`: Output data rate divided by 2.
/// - `OdrDiv4`: Output data rate divided by 4.
/// - `OdrDiv8`: Output data rate divided by 8.
/// - `OdrDiv16`: Output data rate divided by 16.
/// - `OdrDiv32`: Output data rate divided by 32.
/// - `OdrDiv64`: Output data rate divided by 64.
/// - `OdrOff`: Output data rate is off.
///
/// # Description
///
/// This enum is used to specify the accelerometer batch data rate for the FIFO.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum BdrXl {
    #[default]
    Odr = 0x0,
    OdrDiv2 = 0x1,
    OdrDiv4 = 0x2,
    OdrDiv8 = 0x3,
    OdrDiv16 = 0x4,
    OdrDiv32 = 0x5,
    OdrDiv64 = 0x6,
    OdrOff = 0x7,
}

/// Represents the FIFO event types.
///
/// # Variants
///
/// - `FifoEvWtm`: FIFO watermark event.
/// - `FifoEvFull`: FIFO full event.
///
/// # Description
///
/// This enum is used to specify the FIFO event type, allowing for watermark or full event configurations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FifoEvent {
    #[default]
    Wtm = 0x1,
    Full = 0x0,
}

/// Represents the initialization modes for the device.
///
/// # Variants
///
/// - `SensorOnlyOn`: Activates sensor-only mode without embedded functions.
/// - `Boot`: Initiates the boot procedure.
/// - `Reset`: Performs a software reset.
/// - `SensorEmbFuncOn`: Activates sensor mode with embedded functions.
///
/// # Description
///
/// This enum is used to specify the initialization mode for the device. It is used in functions
/// that configure the bus operating mode based on the initialization value.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq)]
pub enum Init {
    SensorOnlyOn = 0x00,
    Boot = 0x01,
    Reset = 0x02,
    SensorEmbFuncOn = 0x03,
}

/// Represents the data-ready mode options.
///
/// # Variants
///
/// - `DrdyLatched`: Represents the latched data-ready mode.
/// - `DrdyPulsed`: Represents the pulsed data-ready mode.
///
/// # Description
///
/// This enum is used to specify the data-ready mode for operations involving data-ready signals.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, Debug, TryFrom)]
#[try_from(repr)]
pub enum DataReadyMode {
    #[default]
    Latched = 0x0,
    Pulsed = 0x1,
}

/// Represents the output data rate (ODR) options.
///
/// # Variants
///
/// - `Off`: ODR is off.
/// - `_1_6hzUlp`: Ultra-low power mode at 1.6 Hz.
/// - `_3hzUlp`: Ultra-low power mode at 3 Hz.
/// - `_25hzUlp`: Ultra-low power mode at 25 Hz.
/// - `_6hzLp`: Low-power mode at 6 Hz.
/// - `_12_5hzLp`: Low-power mode at 12.5 Hz.
/// - `_25hzLp`: Low-power mode at 25 Hz.
/// - `_50hzLp`: Low-power mode at 50 Hz.
/// - `_100hzLp`: Low-power mode at 100 Hz.
/// - `_200hzLp`: Low-power mode at 200 Hz.
/// - `_400hzLp`: Low-power mode at 400 Hz.
/// - `_800hzLp`: Low-power mode at 800 Hz.
/// - `_6hzHp`: High-performance mode at 6 Hz.
/// - `_12_5hzHp`: High-performance mode at 12.5 Hz.
/// - `_25hzHp`: High-performance mode at 25 Hz.
/// - `_50hzHp`: High-performance mode at 50 Hz.
/// - `_100hzHp`: High-performance mode at 100 Hz.
/// - `_200hzHp`: High-performance mode at 200 Hz.
/// - `_400hzHp`: High-performance mode at 400 Hz.
/// - `_800hzHp`: High-performance mode at 800 Hz.
/// - `OdrTrigPin`: Triggered by pin.
/// - `OdrTrigSw`: Triggered by software.
///
/// # Description
///
/// This enum is used to specify the ODR for sensor operations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default)]
pub enum Odr {
    #[default]
    Off = 0x00,
    _1_6hzUlp = 0x01,
    _3hzUlp = 0x02,
    _25hzUlp = 0x03,
    _6hzLp = 0x04,
    _12_5hzLp = 0x05,
    _25hzLp = 0x06,
    _50hzLp = 0x07,
    _100hzLp = 0x08,
    _200hzLp = 0x09,
    _400hzLp = 0x0A,
    _800hzLp = 0x0B,
    _6hzHp = 0x14,
    _12_5hzHp = 0x15,
    _25hzHp = 0x16,
    _50hzHp = 0x17,
    _100hzHp = 0x18,
    _200hzHp = 0x19,
    _400hzHp = 0x1A,
    _800hzHp = 0x1B,
    TrigPin = 0x2E,
    TrigSw = 0x2F,
}

impl Odr {
    pub fn new(odr: u8, hp_en: u8) -> Self {
        match odr {
            0x00 => Odr::Off,
            0x01 => Odr::_1_6hzUlp,
            0x02 => Odr::_3hzUlp,
            0x03 => Odr::_25hzUlp,
            0x04 => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_6hzHp
                } else {
                    Odr::_6hzLp
                }
            }
            0x05 => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_12_5hzHp
                } else {
                    Odr::_12_5hzLp
                }
            }
            0x06 => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_25hzHp
                } else {
                    Odr::_25hzLp
                }
            }
            0x07 => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_50hzHp
                } else {
                    Odr::_50hzLp
                }
            }
            0x08 => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_100hzHp
                } else {
                    Odr::_100hzLp
                }
            }
            0x09 => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_200hzHp
                } else {
                    Odr::_200hzLp
                }
            }
            0x0A => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_400hzHp
                } else {
                    Odr::_400hzLp
                }
            }
            0x0B => {
                if hp_en == PROPERTY_ENABLE {
                    Odr::_800hzHp
                } else {
                    Odr::_800hzLp
                }
            }
            0x0E => Odr::TrigPin,
            0x0F => Odr::TrigSw,
            _ => Odr::Off,
        }
    }
}

/// Represents the full-scale (FS) options.
///
/// # Variants
///
/// - `_2g`: Full-scale range of ±2g.
/// - `_4g`: Full-scale range of ±4g.
/// - `_8g`: Full-scale range of ±8g.
/// - `_16g`: Full-scale range of ±16g.
///
/// # Description
///
/// This enum is used to specify the FS for sensor operations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Fs {
    #[default]
    _2g = 0,
    _4g = 1,
    _8g = 2,
    _16g = 3,
}

/// Represents the bandwidth (BW) options.
///
/// # Variants
///
/// - `Div2`: Bandwidth is ODR divided by 2.
/// - `Div4`: Bandwidth is ODR divided by 4.
/// - `Div8`: Bandwidth is ODR divided by 8.
/// - `Div16`: Bandwidth is ODR divided by 16.
///
/// # Description
///
/// This enum is used to specify the bandwidth for sensor operations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum Bw {
    #[default]
    OdrDiv2 = 0,
    OdrDiv4 = 1,
    OdrDiv8 = 2,
    OdrDiv16 = 3,
}

/// Represents the self-test modes for the accelerometer.
///
/// # Variants
///
/// - `Disable`: Disables the self-test.
/// - `Positive`: Enables positive self-test.
/// - `Negative`: Enables negative self-test.
///
/// # Description
///
/// This enum is used to specify the self-test mode for the accelerometer, allowing for positive or
/// negative self-test configurations.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq)]
pub enum XlSelfTest {
    Disable = 0x0,
    Positive = 0x1,
    Negative = 0x2,
}

/// Represents the interrupt activation level.
///
/// # Variants
///
/// - `ActiveHigh`: Interrupt is active high.
/// - `ActiveLow`: Interrupt is active low.
///
/// # Description
///
/// This enum is used to specify the activation level of the interrupt pin. It is used in functions
/// that configure or retrieve the interrupt activation level.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, Debug, TryFrom)]
#[try_from(repr)]
pub enum IntPinPolarity {
    #[default]
    ActiveHigh = 0x0,
    ActiveLow = 0x1,
}

/// Represents the SPI communication mode.
///
/// # Variants
///
/// - `Spi4Wire`: 4-wire SPI mode.
/// - `Spi3Wire`: 3-wire SPI mode.
///
/// # Description
///
/// This enum is used to specify the SPI communication mode for the device. It allows for configuration
/// of either 4-wire or 3-wire SPI communication, depending on the hardware setup and requirements.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum SpiMode {
    #[default]
    Spi4Wire = 0x0,
    Spi3Wire = 0x1,
}

/// Represents the tags used in the FIFO sensor data.
///
/// # Variants
///
/// - `FifoEmpty`: Indicates that the FIFO is empty.
/// - `XlTempTag`: Accelerometer and temperature data.
/// - `XlOnly2xTag`: Accelerometer data only, 2x mode.
/// - `TimestampTag`: Timestamp data.
/// - `StepCounterTag`: Step counter data.
/// - `MlcResultTag`: Machine Learning Core (MLC) result data.
/// - `MlcFilterTag`: MLC filter data.
/// - `MlcFeature`: MLC feature data.
/// - `FsmResultTag`: Finite State Machine (FSM) result data.
///
/// # Description
///
/// This enum is used to identify the type of data stored in the FIFO. Each tag corresponds to a specific
/// type of data, such as accelerometer, temperature, timestamp, or results from the Machine Learning Core
/// (MLC) or Finite State Machine (FSM). The tags help in interpreting the data retrieved from the FIFO.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FifoSensorTag {
    #[default]
    FifoEmpty = 0x0,
    XlTempTag = 0x2,
    XlOnly2xTag = 0x3,
    TimestampTag = 0x4,
    StepCounterTag = 0x12,
    MlcResultTag = 0x1A,
    MlcFilterTag = 0x1B,
    MlcFeature = 0x1C,
    FsmResultTag = 0x1D,
}

/// Represents the Free Fall threshold options.
///
/// # Variants
///
/// - `_156mg`: 156 mg threshold.
/// - `_219mg`: 219 mg threshold.
/// - `_250mg`: 250 mg threshold.
/// - `_312mg`: 312 mg threshold.
/// - `_344mg`: 344 mg threshold.
/// - `_406mg`: 406 mg threshold.
/// - `_469mg`: 469 mg threshold.
/// - `_500mg`: 500 mg threshold.
///
/// # Description
///
/// This enum is used to specify the threshold value for Free Fall detection, allowing for various
/// sensitivity levels.
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Default, TryFrom)]
#[try_from(repr)]
pub enum FfThreshold {
    #[default]
    _156mg = 0x0,
    _219mg = 0x1,
    _250mg = 0x2,
    _312mg = 0x3,
    _344mg = 0x4,
    _406mg = 0x5,
    _469mg = 0x6,
    _500mg = 0x7,
}