forked from hd-zero/hdzero-goggle
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmi2_defs.h
2654 lines (2149 loc) · 103 KB
/
bmi2_defs.h
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
/**
* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi2_defs.h
* @date 2021-09-30
* @version v2.71.8
*
*/
#pragma once
/******************************************************************************/
/*! @name Header includes */
/******************************************************************************/
#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/kernel.h>
#else
#include <stdint.h>
#include <stddef.h>
#endif
/******************************************************************************/
/*! @name Common macros */
/******************************************************************************/
#ifdef __KERNEL__
#if !defined(UINT8_C) && !defined(INT8_C)
#define INT8_C(x) S8_C(x)
#define UINT8_C(x) U8_C(x)
#endif
#if !defined(UINT16_C) && !defined(INT16_C)
#define INT16_C(x) S16_C(x)
#define UINT16_C(x) U16_C(x)
#endif
#if !defined(INT32_C) && !defined(UINT32_C)
#define INT32_C(x) S32_C(x)
#define UINT32_C(x) U32_C(x)
#endif
#if !defined(INT64_C) && !defined(UINT64_C)
#define INT64_C(x) S64_C(x)
#define UINT64_C(x) U64_C(x)
#endif
#endif
/*! @name C standard macros */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *) 0)
#endif
#endif
/******************************************************************************/
/*! @name General Macro Definitions */
/******************************************************************************/
/*! @name Utility macros */
#define BMI2_SET_BITS(reg_data, bitname, data) \
((reg_data & ~(bitname##_MASK)) | \
((data << bitname##_POS) & bitname##_MASK))
#define BMI2_GET_BITS(reg_data, bitname) \
((reg_data & (bitname##_MASK)) >> \
(bitname##_POS))
#define BMI2_SET_BIT_POS0(reg_data, bitname, data) \
((reg_data & ~(bitname##_MASK)) | \
(data & bitname##_MASK))
#define BMI2_GET_BIT_POS0(reg_data, bitname) (reg_data & (bitname##_MASK))
#define BMI2_SET_BIT_VAL0(reg_data, bitname) (reg_data & ~(bitname##_MASK))
/*! @name For getting LSB and MSB */
#define BMI2_GET_LSB(var) (uint8_t)(var & BMI2_SET_LOW_BYTE)
#define BMI2_GET_MSB(var) (uint8_t)((var & BMI2_SET_HIGH_BYTE) >> 8)
#ifndef BMI2_INTF_RETURN_TYPE
#define BMI2_INTF_RETURN_TYPE int8_t
#endif
/*! @name For defining absolute values */
#define BMI2_ABS(a) ((a) > 0 ? (a) : -(a))
/*! @name LSB and MSB mask definitions */
#define BMI2_SET_LOW_BYTE UINT16_C(0x00FF)
#define BMI2_SET_HIGH_BYTE UINT16_C(0xFF00)
#define BMI2_SET_LOW_NIBBLE UINT8_C(0x0F)
/*! @name For enable and disable */
#define BMI2_ENABLE UINT8_C(1)
#define BMI2_DISABLE UINT8_C(0)
/*! @name To define TRUE or FALSE */
#define BMI2_TRUE UINT8_C(1)
#define BMI2_FALSE UINT8_C(0)
/*! @name Macro to define maximum length of read */
#define BMI2_MAX_LEN UINT8_C(128)
/*! @name To define sensor interface success code */
#define BMI2_INTF_RET_SUCCESS INT8_C(0)
/*! @name To define success code */
#define BMI2_OK INT8_C(0)
/*! @name To define error codes */
#define BMI2_E_NULL_PTR INT8_C(-1)
#define BMI2_E_COM_FAIL INT8_C(-2)
#define BMI2_E_DEV_NOT_FOUND INT8_C(-3)
#define BMI2_E_OUT_OF_RANGE INT8_C(-4)
#define BMI2_E_ACC_INVALID_CFG INT8_C(-5)
#define BMI2_E_GYRO_INVALID_CFG INT8_C(-6)
#define BMI2_E_ACC_GYR_INVALID_CFG INT8_C(-7)
#define BMI2_E_INVALID_SENSOR INT8_C(-8)
#define BMI2_E_CONFIG_LOAD INT8_C(-9)
#define BMI2_E_INVALID_PAGE INT8_C(-10)
#define BMI2_E_INVALID_FEAT_BIT INT8_C(-11)
#define BMI2_E_INVALID_INT_PIN INT8_C(-12)
#define BMI2_E_SET_APS_FAIL INT8_C(-13)
#define BMI2_E_AUX_INVALID_CFG INT8_C(-14)
#define BMI2_E_AUX_BUSY INT8_C(-15)
#define BMI2_E_SELF_TEST_FAIL INT8_C(-16)
#define BMI2_E_REMAP_ERROR INT8_C(-17)
#define BMI2_E_GYR_USER_GAIN_UPD_FAIL INT8_C(-18)
#define BMI2_E_SELF_TEST_NOT_DONE INT8_C(-19)
#define BMI2_E_INVALID_INPUT INT8_C(-20)
#define BMI2_E_INVALID_STATUS INT8_C(-21)
#define BMI2_E_CRT_ERROR INT8_C(-22)
#define BMI2_E_ST_ALREADY_RUNNING INT8_C(-23)
#define BMI2_E_CRT_READY_FOR_DL_FAIL_ABORT INT8_C(-24)
#define BMI2_E_DL_ERROR INT8_C(-25)
#define BMI2_E_PRECON_ERROR INT8_C(-26)
#define BMI2_E_ABORT_ERROR INT8_C(-27)
#define BMI2_E_GYRO_SELF_TEST_ERROR INT8_C(-28)
#define BMI2_E_GYRO_SELF_TEST_TIMEOUT INT8_C(-29)
#define BMI2_E_WRITE_CYCLE_ONGOING INT8_C(-30)
#define BMI2_E_WRITE_CYCLE_TIMEOUT INT8_C(-31)
#define BMI2_E_ST_NOT_RUNING INT8_C(-32)
#define BMI2_E_DATA_RDY_INT_FAILED INT8_C(-33)
#define BMI2_E_INVALID_FOC_POSITION INT8_C(-34)
/*! @name To define warnings for FIFO activity */
#define BMI2_W_FIFO_EMPTY INT8_C(1)
#define BMI2_W_PARTIAL_READ INT8_C(2)
#define BMI2_W_DUMMY_BYTE INT8_C(3)
/*! @name Macros to define dummy frame header FIFO headerless mode */
#define BMI2_FIFO_HEADERLESS_DUMMY_ACC UINT8_C(0x01)
#define BMI2_FIFO_HEADERLESS_DUMMY_GYR UINT8_C(0x02)
#define BMI2_FIFO_HEADERLESS_DUMMY_AUX UINT8_C(0x03)
#define BMI2_FIFO_HEADERLESS_DUMMY_BYTE_1 UINT8_C(0x7F)
#define BMI2_FIFO_HEADERLESS_DUMMY_BYTE_2 UINT8_C(0x00)
#define BMI2_FIFO_HEADERLESS_DUMMY_BYTE_3 UINT8_C(0x80)
/*! @name Bit wise to define information */
#define BMI2_I_MIN_VALUE UINT8_C(1)
#define BMI2_I_MAX_VALUE UINT8_C(2)
/*! @name BMI2 register addresses */
#define BMI2_CHIP_ID_ADDR UINT8_C(0x00)
#define BMI2_STATUS_ADDR UINT8_C(0x03)
#define BMI2_AUX_X_LSB_ADDR UINT8_C(0x04)
#define BMI2_ACC_X_LSB_ADDR UINT8_C(0x0C)
#define BMI2_GYR_X_LSB_ADDR UINT8_C(0x12)
#define BMI2_SENSORTIME_ADDR UINT8_C(0x18)
#define BMI2_EVENT_ADDR UINT8_C(0x1B)
#define BMI2_INT_STATUS_0_ADDR UINT8_C(0x1C)
#define BMI2_INT_STATUS_1_ADDR UINT8_C(0x1D)
#define BMI2_SC_OUT_0_ADDR UINT8_C(0x1E)
#define BMI2_SYNC_COMMAND_ADDR UINT8_C(0x1E)
#define BMI2_GYR_CAS_GPIO0_ADDR UINT8_C(0x1E)
#define BMI2_INTERNAL_STATUS_ADDR UINT8_C(0x21)
#define BMI2_FIFO_LENGTH_0_ADDR UINT8_C(0x24)
#define BMI2_FIFO_DATA_ADDR UINT8_C(0x26)
#define BMI2_FEAT_PAGE_ADDR UINT8_C(0x2F)
#define BMI2_FEATURES_REG_ADDR UINT8_C(0x30)
#define BMI2_ACC_CONF_ADDR UINT8_C(0x40)
#define BMI2_GYR_CONF_ADDR UINT8_C(0x42)
#define BMI2_AUX_CONF_ADDR UINT8_C(0x44)
#define BMI2_FIFO_DOWNS_ADDR UINT8_C(0x45)
#define BMI2_FIFO_WTM_0_ADDR UINT8_C(0x46)
#define BMI2_FIFO_WTM_1_ADDR UINT8_C(0x47)
#define BMI2_FIFO_CONFIG_0_ADDR UINT8_C(0x48)
#define BMI2_FIFO_CONFIG_1_ADDR UINT8_C(0x49)
#define BMI2_AUX_DEV_ID_ADDR UINT8_C(0x4B)
#define BMI2_AUX_IF_CONF_ADDR UINT8_C(0x4C)
#define BMI2_AUX_RD_ADDR UINT8_C(0x4D)
#define BMI2_AUX_WR_ADDR UINT8_C(0x4E)
#define BMI2_AUX_WR_DATA_ADDR UINT8_C(0x4F)
#define BMI2_INT1_IO_CTRL_ADDR UINT8_C(0x53)
#define BMI2_INT2_IO_CTRL_ADDR UINT8_C(0x54)
#define BMI2_INT_LATCH_ADDR UINT8_C(0x55)
#define BMI2_INT1_MAP_FEAT_ADDR UINT8_C(0x56)
#define BMI2_INT2_MAP_FEAT_ADDR UINT8_C(0x57)
#define BMI2_INT_MAP_DATA_ADDR UINT8_C(0x58)
#define BMI2_INIT_CTRL_ADDR UINT8_C(0x59)
#define BMI2_INIT_ADDR_0 UINT8_C(0x5B)
#define BMI2_INIT_ADDR_1 UINT8_C(0x5C)
#define BMI2_INIT_DATA_ADDR UINT8_C(0x5E)
#define BMI2_AUX_IF_TRIM UINT8_C(0x68)
#define BMI2_GYR_CRT_CONF_ADDR UINT8_C(0x69)
#define BMI2_NVM_CONF_ADDR UINT8_C(0x6A)
#define BMI2_IF_CONF_ADDR UINT8_C(0x6B)
#define BMI2_ACC_SELF_TEST_ADDR UINT8_C(0x6D)
#define BMI2_GYR_SELF_TEST_AXES_ADDR UINT8_C(0x6E)
#define BMI2_SELF_TEST_MEMS_ADDR UINT8_C(0x6F)
#define BMI2_NV_CONF_ADDR UINT8_C(0x70)
#define BMI2_ACC_OFF_COMP_0_ADDR UINT8_C(0x71)
#define BMI2_GYR_OFF_COMP_3_ADDR UINT8_C(0x74)
#define BMI2_GYR_OFF_COMP_6_ADDR UINT8_C(0x77)
#define BMI2_GYR_USR_GAIN_0_ADDR UINT8_C(0x78)
#define BMI2_PWR_CONF_ADDR UINT8_C(0x7C)
#define BMI2_PWR_CTRL_ADDR UINT8_C(0x7D)
#define BMI2_CMD_REG_ADDR UINT8_C(0x7E)
/*! @name BMI2 I2C address */
#define BMI2_I2C_PRIM_ADDR UINT8_C(0x68)
#define BMI2_I2C_SEC_ADDR UINT8_C(0x69)
/*! @name BMI2 Commands */
#define BMI2_G_TRIGGER_CMD UINT8_C(0x02)
#define BMI2_USR_GAIN_CMD UINT8_C(0x03)
#define BMI2_NVM_PROG_CMD UINT8_C(0xA0)
#define BMI2_SOFT_RESET_CMD UINT8_C(0xB6)
#define BMI2_FIFO_FLUSH_CMD UINT8_C(0xB0)
/*! @name BMI2 sensor data bytes */
#define BMI2_AUX_NUM_BYTES UINT8_C(8)
#define BMI2_ACC_NUM_BYTES UINT8_C(6)
#define BMI2_GYR_NUM_BYTES UINT8_C(6)
#define BMI2_ACC_GYR_NUM_BYTES UINT8_C(12)
#define BMI2_AUX_ACC_NUM_BYTES UINT8_C(14)
#define BMI2_ACC_GYR_AUX_NUM_BYTES UINT8_C(20)
#define BMI2_CRT_CONFIG_FILE_SIZE UINT16_C(2048)
#define BMI2_FEAT_SIZE_IN_BYTES UINT8_C(16)
#define BMI2_ACC_CONFIG_LENGTH UINT8_C(2)
/*! @name BMI2 configuration load status */
#define BMI2_CONFIG_LOAD_SUCCESS UINT8_C(1)
/*! @name To define BMI2 pages */
#define BMI2_PAGE_0 UINT8_C(0)
#define BMI2_PAGE_1 UINT8_C(1)
#define BMI2_PAGE_2 UINT8_C(2)
#define BMI2_PAGE_3 UINT8_C(3)
#define BMI2_PAGE_4 UINT8_C(4)
#define BMI2_PAGE_5 UINT8_C(5)
#define BMI2_PAGE_6 UINT8_C(6)
#define BMI2_PAGE_7 UINT8_C(7)
/*! @name Array Parameter DefinItions */
#define BMI2_SENSOR_TIME_LSB_BYTE UINT8_C(0)
#define BMI2_SENSOR_TIME_XLSB_BYTE UINT8_C(1)
#define BMI2_SENSOR_TIME_MSB_BYTE UINT8_C(2)
/*! @name Mask definitions for Gyro CRT */
#define BMI2_GYR_RDY_FOR_DL_MASK UINT8_C(0x08)
#define BMI2_GYR_CRT_RUNNING_MASK UINT8_C(0x04)
/*! @name mask definition for status register */
#define BMI2_AUX_BUSY_MASK UINT8_C(0x04)
#define BMI2_CMD_RDY_MASK UINT8_C(0x10)
#define BMI2_DRDY_AUX_MASK UINT8_C(0x20)
#define BMI2_DRDY_GYR_MASK UINT8_C(0x40)
#define BMI2_DRDY_ACC_MASK UINT8_C(0x80)
/*! @name Mask definitions for SPI read/write address */
#define BMI2_SPI_RD_MASK UINT8_C(0x80)
#define BMI2_SPI_WR_MASK UINT8_C(0x7F)
/*! @name Mask definitions for power configuration register */
#define BMI2_ADV_POW_EN_MASK UINT8_C(0x01)
/*! @name Mask definitions for initialization control register */
#define BMI2_CONF_LOAD_EN_MASK UINT8_C(0x01)
/*! @name Mask definitions for power control register */
#define BMI2_AUX_EN_MASK UINT8_C(0x01)
#define BMI2_GYR_EN_MASK UINT8_C(0x02)
#define BMI2_ACC_EN_MASK UINT8_C(0x04)
#define BMI2_TEMP_EN_MASK UINT8_C(0x08)
/*! @name Mask definitions for sensor event flags */
#define BMI2_EVENT_FLAG_MASK UINT8_C(0x1C)
/*! @name Mask definitions to switch page */
#define BMI2_SWITCH_PAGE_EN_MASK UINT8_C(0x07)
/*! @name Mask definitions of NVM register */
#define BMI2_NV_ACC_OFFSET_MASK UINT8_C(0x08)
/*! @name Mask definition for config version */
#define BMI2_CONFIG_MAJOR_MASK UINT16_C(0x3C0)
#define BMI2_CONFIG_MINOR_MASK UINT8_C(0x3F)
/*! @name mask and bit position for activity recognition settings */
#define BMI2_ACT_RECG_POST_PROS_EN_DIS_MASK UINT8_C(0x01)
#define BMI2_ACT_RECG_BUFF_SIZE_MASK UINT8_C(0x0F)
#define BMI2_ACT_RECG_MIN_SEG_CONF_MASK UINT8_C(0x0F)
/*! @name mask and bit position for activity recognition hc settings */
#define BMI2_HC_ACT_RECG_SEGMENT_SIZE_MASK UINT8_C(0x03)
#define BMI2_HC_ACT_RECG_PP_EN_MASK UINT8_C(0x01)
#define BMI2_HC_ACT_RECG_MIN_GDI_THRES_MASK UINT16_C(0xFFFF)
#define BMI2_HC_ACT_RECG_MAX_GDI_THRES_MASK UINT16_C(0xFFFF)
#define BMI2_HC_ACT_RECG_BUF_SIZE_MASK UINT16_C(0xFFFF)
#define BMI2_HC_ACT_RECG_MIN_SEG_CONF_MASK UINT16_C(0xFFFF)
#define BMI2_GYRO_CROSS_AXES_SENSE_MASK UINT8_C(0x7F)
#define BMI2_GYRO_CROSS_AXES_SENSE_SIGN_BIT_MASK UINT8_C(0x40)
/*! @name Bit position definitions for Gyro CRT */
#define BMI2_GYR_RDY_FOR_DL_POS UINT8_C(0x03)
#define BMI2_GYR_CRT_RUNNING_POS UINT8_C(0x02)
/*! @name Bit position for status register*/
#define BMI2_AUX_BUSY_POS UINT8_C(0x02)
#define BMI2_CMD_RDY_POS UINT8_C(0x04)
#define BMI2_DRDY_AUX_POS UINT8_C(0x05)
#define BMI2_DRDY_GYR_POS UINT8_C(0x06)
#define BMI2_DRDY_ACC_POS UINT8_C(0x07)
/*! @name Bit position definitions for power control register */
#define BMI2_GYR_EN_POS UINT8_C(0x01)
#define BMI2_ACC_EN_POS UINT8_C(0x02)
#define BMI2_TEMP_EN_POS UINT8_C(0x03)
/*! @name Bit position definitions for sensor event flags */
#define BMI2_EVENT_FLAG_POS UINT8_C(0x02)
/*! @name Bit position definitions of NVM register */
#define BMI2_NV_ACC_OFFSET_POS UINT8_C(0x03)
/*! @name Bit position for major version from config */
#define BMI2_CONFIG_MAJOR_POS UINT8_C(0x06)
/*! @name Accelerometer and Gyroscope Filter/Noise performance modes */
/* Power optimized mode */
#define BMI2_POWER_OPT_MODE UINT8_C(0)
/* Performance optimized */
#define BMI2_PERF_OPT_MODE UINT8_C(1)
/*! @name index for config major minor information */
#define BMI2_CONFIG_INFO_LOWER UINT8_C(52)
#define BMI2_CONFIG_INFO_HIGHER UINT8_C(53)
/*! @name Sensor status */
#define BMI2_DRDY_ACC UINT8_C(0x80)
#define BMI2_DRDY_GYR UINT8_C(0x40)
#define BMI2_DRDY_AUX UINT8_C(0x20)
#define BMI2_CMD_RDY UINT8_C(0x10)
#define BMI2_AUX_BUSY UINT8_C(0x04)
/*! @name Macro to define accelerometer configuration value for FOC */
#define BMI2_FOC_ACC_CONF_VAL UINT8_C(0xB7)
/*! @name Macro to define gyroscope configuration value for FOC */
#define BMI2_FOC_GYR_CONF_VAL UINT8_C(0xB6)
/*! @name Macro to define X Y and Z axis for an array */
#define BMI2_X_AXIS UINT8_C(0)
#define BMI2_Y_AXIS UINT8_C(1)
#define BMI2_Z_AXIS UINT8_C(2)
/*! @name Macro for delay to read internal status */
#define BMI2_INTERNAL_STATUS_READ_DELAY_MS UINT32_C(140000)
/******************************************************************************/
/*! @name Sensor Macro Definitions */
/******************************************************************************/
/*! @name Macros to define BMI2 sensor/feature types */
#define BMI2_ACCEL UINT8_C(0)
#define BMI2_GYRO UINT8_C(1)
#define BMI2_AUX UINT8_C(2)
#define BMI2_SIG_MOTION UINT8_C(3)
#define BMI2_ANY_MOTION UINT8_C(4)
#define BMI2_NO_MOTION UINT8_C(5)
#define BMI2_STEP_DETECTOR UINT8_C(6)
#define BMI2_STEP_COUNTER UINT8_C(7)
#define BMI2_STEP_ACTIVITY UINT8_C(8)
#define BMI2_GYRO_GAIN_UPDATE UINT8_C(9)
#define BMI2_TILT UINT8_C(10)
#define BMI2_UP_HOLD_TO_WAKE UINT8_C(11)
#define BMI2_GLANCE_DETECTOR UINT8_C(12)
#define BMI2_WAKE_UP UINT8_C(13)
#define BMI2_ORIENTATION UINT8_C(14)
#define BMI2_HIGH_G UINT8_C(15)
#define BMI2_LOW_G UINT8_C(16)
#define BMI2_FLAT UINT8_C(17)
#define BMI2_EXT_SENS_SYNC UINT8_C(18)
#define BMI2_WRIST_GESTURE UINT8_C(19)
#define BMI2_WRIST_WEAR_WAKE_UP UINT8_C(20)
#define BMI2_WRIST_WEAR_WAKE_UP_WH UINT8_C(21)
#define BMI2_WRIST_GESTURE_WH UINT8_C(22)
#define BMI2_PRIMARY_OIS UINT8_C(23)
#define BMI2_FREE_FALL_DET UINT8_C(24)
#define BMI2_SINGLE_TAP UINT8_C(25)
#define BMI2_DOUBLE_TAP UINT8_C(26)
#define BMI2_TRIPLE_TAP UINT8_C(27)
#define BMI2_TAP UINT8_C(28)
/* Non virtual sensor features */
#define BMI2_STEP_COUNTER_PARAMS UINT8_C(29)
#define BMI2_TAP_DETECTOR_1 UINT8_C(30)
#define BMI2_TAP_DETECTOR_2 UINT8_C(31)
#define BMI2_TEMP UINT8_C(32)
#define BMI2_ACCEL_SELF_TEST UINT8_C(33)
#define BMI2_GYRO_SELF_OFF UINT8_C(34)
#define BMI2_ACTIVITY_RECOGNITION UINT8_C(35)
#define BMI2_MAX_BURST_LEN UINT8_C(36)
#define BMI2_SENS_MAX_NUM UINT8_C(37)
#define BMI2_AXIS_MAP UINT8_C(38)
#define BMI2_NVM_STATUS UINT8_C(39)
#define BMI2_VFRM_STATUS UINT8_C(40)
#define BMI2_GYRO_CROSS_SENSE UINT8_C(41)
#define BMI2_CRT_GYRO_SELF_TEST UINT8_C(42)
#define BMI2_ABORT_CRT_GYRO_SELF_TEST UINT8_C(43)
#define BMI2_NVM_PROG_PREP UINT8_C(44)
#define BMI2_ACTIVITY_RECOGNITION_SETTINGS UINT8_C(45)
#define BMI2_OIS_OUTPUT UINT8_C(46)
#define BMI2_CONFIG_ID UINT8_C(47)
#define BMI2_EXT_TCO UINT8_C(48)
#define BMI2_LPD UINT8_C(49)
#define BMI2_LAPTOP_POSITION_DETECTOR_1 UINT8_C(50)
#define BMI2_LAPTOP_POSITION_DETECTOR_2 UINT8_C(51)
#define BMI2_LAPTOP_POSITION_DETECTOR_3 UINT8_C(52)
#define BMI2_LAPTOP_POSITION_DETECTOR_4 UINT8_C(53)
#define BMI2_WRIST_GESTURE_WH_1 UINT8_C(54)
#define BMI2_WRIST_GESTURE_WH_2 UINT8_C(55)
/*! @name Bit wise for selecting BMI2 sensors/features */
#define BMI2_ACCEL_SENS_SEL (1)
#define BMI2_GYRO_SENS_SEL (1 << BMI2_GYRO)
#define BMI2_AUX_SENS_SEL (1 << BMI2_AUX)
#define BMI2_TEMP_SENS_SEL ((uint64_t)1 << BMI2_TEMP)
#define BMI2_ANY_MOT_SEL (1 << BMI2_ANY_MOTION)
#define BMI2_NO_MOT_SEL (1 << BMI2_NO_MOTION)
#define BMI2_TILT_SEL (1 << BMI2_TILT)
#define BMI2_ORIENT_SEL (1 << BMI2_ORIENTATION)
#define BMI2_SIG_MOTION_SEL (1 << BMI2_SIG_MOTION)
#define BMI2_STEP_DETECT_SEL (1 << BMI2_STEP_DETECTOR)
#define BMI2_STEP_COUNT_SEL (1 << BMI2_STEP_COUNTER)
#define BMI2_STEP_ACT_SEL (1 << BMI2_STEP_ACTIVITY)
#define BMI2_GYRO_GAIN_UPDATE_SEL (1 << BMI2_GYRO_GAIN_UPDATE)
#define BMI2_UP_HOLD_TO_WAKE_SEL (1 << BMI2_UP_HOLD_TO_WAKE)
#define BMI2_GLANCE_DET_SEL (1 << BMI2_GLANCE_DETECTOR)
#define BMI2_WAKE_UP_SEL (1 << BMI2_WAKE_UP)
#define BMI2_TAP_SEL (1 << BMI2_TAP)
#define BMI2_HIGH_G_SEL (1 << BMI2_HIGH_G)
#define BMI2_LOW_G_SEL (1 << BMI2_LOW_G)
#define BMI2_FLAT_SEL (1 << BMI2_FLAT)
#define BMI2_EXT_SENS_SEL (1 << BMI2_EXT_SENS_SYNC)
#define BMI2_SINGLE_TAP_SEL (1 << BMI2_SINGLE_TAP)
#define BMI2_DOUBLE_TAP_SEL (1 << BMI2_DOUBLE_TAP)
#define BMI2_TRIPLE_TAP_SEL (1 << BMI2_TRIPLE_TAP)
#define BMI2_GYRO_SELF_OFF_SEL ((uint64_t)1 << BMI2_GYRO_SELF_OFF)
#define BMI2_WRIST_GEST_SEL (1 << BMI2_WRIST_GESTURE)
#define BMI2_WRIST_WEAR_WAKE_UP_SEL (1 << BMI2_WRIST_WEAR_WAKE_UP)
#define BMI2_ACTIVITY_RECOGNITION_SEL ((uint64_t)1 << BMI2_ACTIVITY_RECOGNITION)
#define BMI2_ACCEL_SELF_TEST_SEL ((uint64_t)1 << BMI2_ACCEL_SELF_TEST)
#define BMI2_WRIST_GEST_W_SEL (1 << BMI2_WRIST_GESTURE_WH)
#define BMI2_WRIST_WEAR_WAKE_UP_WH_SEL (1 << BMI2_WRIST_WEAR_WAKE_UP_WH)
#define BMI2_PRIMARY_OIS_SEL (1 << BMI2_PRIMARY_OIS)
#define BMI2_FREE_FALL_DET_SEL (1 << BMI2_FREE_FALL_DET)
#define BMI2_EXT_TCO_SEL ((uint64_t)1 << BMI2_EXT_TCO)
#define BMI2_LPD_SEL ((uint64_t)1 << BMI2_LPD)
/*! @name Mask definitions for BMI2 wake-up feature configuration for bmi260 */
#define BMI2_WAKEUP_SENSITIVITY_MASK UINT8_C(0x0E)
#define BMI2_WAKEUP_SINGLE_TAP_EN_MASK UINT8_C(0x01)
#define BMI2_WAKEUP_DOUBLE_TAP_EN_MASK UINT8_C(0x02)
#define BMI2_WAKEUP_TRIPLE_TAP_EN_MASK UINT8_C(0x04)
#define BMI2_WAKEUP_DATA_REG_EN_MASK UINT8_C(0x08)
#define BMI2_WAKEUP_AXIS_SEL_MASK UINT8_C(0x03)
/*! @name Bit position definitions for BMI2 wake-up feature configuration for bmi260 */
#define BMI2_WAKEUP_SENSITIVITY_POS UINT8_C(0x01)
#define BMI2_WAKEUP_DOUBLE_TAP_EN_POS UINT8_C(0x01)
#define BMI2_WAKEUP_TRIPLE_TAP_EN_POS UINT8_C(0x02)
#define BMI2_WAKEUP_DATA_REG_EN_POS UINT8_C(0x03)
/*! @name Mask definitions for BMI2 tap feature configuration for bmi260t */
#define BMI2_TAP_SENSITIVITY_MASK UINT8_C(0x0E)
#define BMI2_TAP_SINGLE_TAP_EN_MASK UINT8_C(0x01)
#define BMI2_TAP_DOUBLE_TAP_EN_MASK UINT8_C(0x02)
#define BMI2_TAP_TRIPLE_TAP_EN_MASK UINT8_C(0x04)
#define BMI2_TAP_DATA_REG_EN_MASK UINT8_C(0x08)
#define BMI2_TAP_AXIS_SEL_MASK UINT8_C(0x03)
/*! @name Bit position definitions for BMI2 tap feature configuration for bmi260t */
#define BMI2_TAP_SENSITIVITY_POS UINT8_C(0x01)
#define BMI2_TAP_DOUBLE_TAP_EN_POS UINT8_C(0x01)
#define BMI2_TAP_TRIPLE_TAP_EN_POS UINT8_C(0x02)
#define BMI2_TAP_DATA_REG_EN_POS UINT8_C(0x03)
/*! @name Mask definitions for BMI2 wake-up feature configuration for other than bmi261 */
#define BMI2_WAKE_UP_SENSITIVITY_MASK UINT16_C(0x000E)
#define BMI2_WAKE_UP_SINGLE_TAP_EN_MASK UINT16_C(0x0010)
/*! @name Bit position definitions for BMI2 wake-up feature configuration for other than bmi261 */
#define BMI2_WAKE_UP_SENSITIVITY_POS UINT8_C(0x01)
#define BMI2_WAKE_UP_SINGLE_TAP_EN_POS UINT8_C(0x04)
/*! @name Offsets from feature start address for BMI2 feature enable/disable */
#define BMI2_ANY_MOT_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_NO_MOT_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_SIG_MOT_FEAT_EN_OFFSET UINT8_C(0x0A)
#define BMI2_STEP_COUNT_FEAT_EN_OFFSET UINT8_C(0x01)
#define BMI2_GYR_USER_GAIN_FEAT_EN_OFFSET UINT8_C(0x05)
#define BMI2_HIGH_G_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_LOW_G_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_TILT_FEAT_EN_OFFSET UINT8_C(0x00)
/*! @name Mask definitions for BMI2 feature enable/disable */
#define BMI2_ANY_NO_MOT_EN_MASK UINT8_C(0x80)
#define BMI2_TILT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_ORIENT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_SIG_MOT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_STEP_DET_FEAT_EN_MASK UINT8_C(0x08)
#define BMI2_STEP_COUNT_FEAT_EN_MASK UINT8_C(0x10)
#define BMI2_STEP_ACT_FEAT_EN_MASK UINT8_C(0x20)
#define BMI2_GYR_USER_GAIN_FEAT_EN_MASK UINT8_C(0x08)
#define BMI2_UP_HOLD_TO_WAKE_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_GLANCE_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_WAKE_UP_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_TAP_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_HIGH_G_FEAT_EN_MASK UINT8_C(0x80)
#define BMI2_LOW_G_FEAT_EN_MASK UINT8_C(0x10)
#define BMI2_FLAT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_EXT_SENS_SYNC_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_GYR_SELF_OFF_CORR_FEAT_EN_MASK UINT8_C(0x02)
#define BMI2_WRIST_GEST_FEAT_EN_MASK UINT8_C(0x20)
#define BMI2_WRIST_WEAR_WAKE_UP_FEAT_EN_MASK UINT8_C(0x10)
#define BMI2_ACTIVITY_RECOG_EN_MASK UINT8_C(0x01)
#define BMI2_ACC_SELF_TEST_FEAT_EN_MASK UINT8_C(0x02)
#define BMI2_GYRO_SELF_TEST_CRT_EN_MASK UINT8_C(0x01)
#define BMI2_ABORT_FEATURE_EN_MASK UINT8_C(0x02)
#define BMI2_NVM_PREP_FEATURE_EN_MASK UINT8_C(0x04)
#define BMI2_FREE_FALL_DET_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_WRIST_GEST_WH_FEAT_EN_MASK UINT8_C(0x02)
/*! @name Bit position definitions for BMI2 feature enable/disable */
#define BMI2_ANY_NO_MOT_EN_POS UINT8_C(0x07)
#define BMI2_STEP_DET_FEAT_EN_POS UINT8_C(0x03)
#define BMI2_STEP_COUNT_FEAT_EN_POS UINT8_C(0x04)
#define BMI2_STEP_ACT_FEAT_EN_POS UINT8_C(0x05)
#define BMI2_GYR_USER_GAIN_FEAT_EN_POS UINT8_C(0x03)
#define BMI2_HIGH_G_FEAT_EN_POS UINT8_C(0x07)
#define BMI2_LOW_G_FEAT_EN_POS UINT8_C(0x04)
#define BMI2_GYR_SELF_OFF_CORR_FEAT_EN_POS UINT8_C(0x01)
#define BMI2_WRIST_GEST_FEAT_EN_POS UINT8_C(0x05)
#define BMI2_WRIST_WEAR_WAKE_UP_FEAT_EN_POS UINT8_C(0x04)
#define BMI2_ACC_SELF_TEST_FEAT_EN_POS UINT8_C(0x01)
#define BMI2_ABORT_FEATURE_EN_POS UINT8_C(0x1)
#define BMI2_NVM_PREP_FEATURE_EN_POS UINT8_C(0x02)
#define BMI2_WRIST_GEST_WH_FEAT_EN_POS UINT8_C(0x01)
/*! Primary OIS low pass filter configuration position and mask */
#define BMI2_LP_FILTER_EN_MASK UINT8_C(0x01)
#define BMI2_LP_FILTER_CONFIG_POS UINT8_C(0x01)
#define BMI2_LP_FILTER_CONFIG_MASK UINT8_C(0x06)
#define BMI2_PRIMARY_OIS_GYR_EN_POS UINT8_C(0x06)
#define BMI2_PRIMARY_OIS_GYR_EN_MASK UINT8_C(0x40)
#define BMI2_PRIMARY_OIS_ACC_EN_POS UINT8_C(0x07)
#define BMI2_PRIMARY_OIS_ACC_EN_MASK UINT8_C(0x80)
/*! @name Mask definitions for BMI2 any and no-motion feature configuration */
#define BMI2_ANY_NO_MOT_DUR_MASK UINT16_C(0x1FFF)
#define BMI2_ANY_NO_MOT_X_SEL_MASK UINT16_C(0x2000)
#define BMI2_ANY_NO_MOT_Y_SEL_MASK UINT16_C(0x4000)
#define BMI2_ANY_NO_MOT_Z_SEL_MASK UINT16_C(0x8000)
#define BMI2_ANY_NO_MOT_THRES_MASK UINT16_C(0x07FF)
#define BMI2_ANY_MOT_INT_MASK UINT8_C(0x40)
/*! @name Mask definitions for BMI2 no-motion interrupt mapping */
#define BMI2_NO_MOT_INT_MASK UINT8_C(0x20)
/*! @name Bit position definitions for BMI2 any and no-motion feature
* configuration
*/
#define BMI2_ANY_NO_MOT_X_SEL_POS UINT8_C(0x0D)
#define BMI2_ANY_NO_MOT_Y_SEL_POS UINT8_C(0x0E)
#define BMI2_ANY_NO_MOT_Z_SEL_POS UINT8_C(0x0F)
/*! @name Mask definitions for BMI2 orientation feature configuration */
#define BMI2_ORIENT_UP_DOWN_MASK UINT16_C(0x0002)
#define BMI2_ORIENT_SYMM_MODE_MASK UINT16_C(0x000C)
#define BMI2_ORIENT_BLOCK_MODE_MASK UINT16_C(0x0030)
#define BMI2_ORIENT_THETA_MASK UINT16_C(0x0FC0)
#define BMI2_ORIENT_HYST_MASK UINT16_C(0x07FF)
/*! @name Bit position definitions for BMI2 orientation feature configuration */
#define BMI2_ORIENT_UP_DOWN_POS UINT8_C(0x01)
#define BMI2_ORIENT_SYMM_MODE_POS UINT8_C(0x02)
#define BMI2_ORIENT_BLOCK_MODE_POS UINT8_C(0x04)
#define BMI2_ORIENT_THETA_POS UINT8_C(0x06)
/*! @name Mask definitions for BMI2 sig-motion feature configuration */
#define BMI2_SIG_MOT_PARAM_1_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_2_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_3_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_4_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_5_MASK UINT16_C(0xFFFF)
/*! @name Mask definitions for BMI2 parameter configurations */
#define BMI2_STEP_COUNT_PARAMS_MASK UINT16_C(0xFFFF)
/*! @name Mask definitions for BMI2 step-counter/detector feature configuration */
#define BMI2_STEP_COUNT_WM_LEVEL_MASK UINT16_C(0x03FF)
#define BMI2_STEP_COUNT_RST_CNT_MASK UINT16_C(0x0400)
#define BMI2_STEP_BUFFER_SIZE_MASK UINT16_C(0xFF00)
#define BMI2_STEP_COUNT_INT_MASK UINT8_C(0x02)
#define BMI2_STEP_ACT_INT_MASK UINT8_C(0x04)
/*! @name Bit position definitions for BMI2 step-counter/detector feature
* configuration
*/
#define BMI2_STEP_COUNT_RST_CNT_POS UINT8_C(0x0A)
#define BMI2_STEP_BUFFER_SIZE_POS UINT8_C(0x08)
/*! @name Mask definitions for BMI2 gyroscope user gain feature
* configuration
*/
#define BMI2_GYR_USER_GAIN_RATIO_X_MASK UINT16_C(0x07FF)
#define BMI2_GYR_USER_GAIN_RATIO_Y_MASK UINT16_C(0x07FF)
#define BMI2_GYR_USER_GAIN_RATIO_Z_MASK UINT16_C(0x07FF)
/*! @name Mask definitions for BMI2 gyroscope user gain saturation status */
#define BMI2_GYR_USER_GAIN_SAT_STAT_X_MASK UINT8_C(0x01)
#define BMI2_GYR_USER_GAIN_SAT_STAT_Y_MASK UINT8_C(0x02)
#define BMI2_GYR_USER_GAIN_SAT_STAT_Z_MASK UINT8_C(0x04)
#define BMI2_G_TRIGGER_STAT_MASK UINT8_C(0x38)
/*! @name Bit position definitions for BMI2 gyroscope user gain saturation status */
#define BMI2_GYR_USER_GAIN_SAT_STAT_Y_POS UINT8_C(0x01)
#define BMI2_GYR_USER_GAIN_SAT_STAT_Z_POS UINT8_C(0x02)
#define BMI2_G_TRIGGER_STAT_POS UINT8_C(0x03)
/*! @name Mask definitions for MSB values of BMI2 gyroscope compensation */
#define BMI2_GYR_OFF_COMP_MSB_X_MASK UINT8_C(0x03)
#define BMI2_GYR_OFF_COMP_MSB_Y_MASK UINT8_C(0x0C)
#define BMI2_GYR_OFF_COMP_MSB_Z_MASK UINT8_C(0x30)
/*! @name Bit positions for MSB values of BMI2 gyroscope compensation */
#define BMI2_GYR_OFF_COMP_MSB_Y_POS UINT8_C(0x02)
#define BMI2_GYR_OFF_COMP_MSB_Z_POS UINT8_C(0x04)
/*! @name Mask definitions for MSB values of BMI2 gyroscope compensation from user input */
#define BMI2_GYR_OFF_COMP_MSB_MASK UINT16_C(0x0300)
#define BMI2_GYR_OFF_COMP_LSB_MASK UINT16_C(0x00FF)
/*! @name Mask definitions for BMI2 orientation status */
#define BMI2_ORIENT_DETECT_MASK UINT8_C(0x03)
#define BMI2_ORIENT_FACE_UP_DWN_MASK UINT8_C(0x04)
/*! @name Bit position definitions for BMI2 orientation status */
#define BMI2_ORIENT_FACE_UP_DWN_POS UINT8_C(0x02)
/*! @name Mask definitions for NVM-VFRM error status */
#define BMI2_NVM_LOAD_ERR_STATUS_MASK UINT8_C(0x01)
#define BMI2_NVM_PROG_ERR_STATUS_MASK UINT8_C(0x02)
#define BMI2_NVM_ERASE_ERR_STATUS_MASK UINT8_C(0x04)
#define BMI2_NVM_END_EXCEED_STATUS_MASK UINT8_C(0x08)
#define BMI2_NVM_PRIV_ERR_STATUS_MASK UINT8_C(0x10)
#define BMI2_VFRM_LOCK_ERR_STATUS_MASK UINT8_C(0x20)
#define BMI2_VFRM_WRITE_ERR_STATUS_MASK UINT8_C(0x40)
#define BMI2_VFRM_FATAL_ERR_STATUS_MASK UINT8_C(0x80)
/*! @name Bit positions for NVM-VFRM error status */
#define BMI2_NVM_PROG_ERR_STATUS_POS UINT8_C(0x01)
#define BMI2_NVM_ERASE_ERR_STATUS_POS UINT8_C(0x02)
#define BMI2_NVM_END_EXCEED_STATUS_POS UINT8_C(0x03)
#define BMI2_NVM_PRIV_ERR_STATUS_POS UINT8_C(0x04)
#define BMI2_VFRM_LOCK_ERR_STATUS_POS UINT8_C(0x05)
#define BMI2_VFRM_WRITE_ERR_STATUS_POS UINT8_C(0x06)
#define BMI2_VFRM_FATAL_ERR_STATUS_POS UINT8_C(0x07)
/*! @name Mask definitions for accelerometer self-test status */
#define BMI2_ACC_SELF_TEST_DONE_MASK UINT8_C(0x01)
#define BMI2_ACC_X_OK_MASK UINT8_C(0x02)
#define BMI2_ACC_Y_OK_MASK UINT8_C(0x04)
#define BMI2_ACC_Z_OK_MASK UINT8_C(0x08)
/*! @name Bit Positions for accelerometer self-test status */
#define BMI2_ACC_X_OK_POS UINT8_C(0x01)
#define BMI2_ACC_Y_OK_POS UINT8_C(0x02)
#define BMI2_ACC_Z_OK_POS UINT8_C(0x03)
/*! @name Mask definitions for BMI2 high-g feature configuration */
#define BMI2_HIGH_G_THRES_MASK UINT16_C(0x7FFF)
#define BMI2_HIGH_G_HYST_MASK UINT16_C(0x0FFF)
#define BMI2_HIGH_G_X_SEL_MASK UINT16_C(0x1000)
#define BMI2_HIGH_G_Y_SEL_MASK UINT16_C(0x2000)
#define BMI2_HIGH_G_Z_SEL_MASK UINT16_C(0x4000)
#define BMI2_HIGH_G_DUR_MASK UINT16_C(0x0FFF)
/*! @name Bit position definitions for BMI2 high-g feature configuration */
#define BMI2_HIGH_G_X_SEL_POS UINT8_C(0x0C)
#define BMI2_HIGH_G_Y_SEL_POS UINT8_C(0x0D)
#define BMI2_HIGH_G_Z_SEL_POS UINT8_C(0x0E)
/*! @name Mask definitions for BMI2 low-g feature configuration */
#define BMI2_LOW_G_THRES_MASK UINT16_C(0x7FFF)
#define BMI2_LOW_G_HYST_MASK UINT16_C(0x0FFF)
#define BMI2_LOW_G_DUR_MASK UINT16_C(0x0FFF)
/*! @name Mask definitions for BMI2 free-fall detection feature configuration */
#define BMI2_FREE_FALL_ACCEL_SETT_MASK UINT16_C(0xFFFF)
/*! @name Mask definitions for BMI2 flat feature configuration */
#define BMI2_FLAT_THETA_MASK UINT16_C(0x007E)
#define BMI2_FLAT_BLOCK_MASK UINT16_C(0x0180)
#define BMI2_FLAT_HYST_MASK UINT16_C(0x003F)
#define BMI2_FLAT_HOLD_TIME_MASK UINT16_C(0x3FC0)
/*! @name Bit position definitions for BMI2 flat feature configuration */
#define BMI2_FLAT_THETA_POS UINT8_C(0x01)
#define BMI2_FLAT_BLOCK_POS UINT8_C(0x07)
#define BMI2_FLAT_HOLD_TIME_POS UINT8_C(0x06)
/*! @name Mask definitions for BMI2 wrist gesture configuration */
#define BMI2_WRIST_GEST_WEAR_ARM_MASK UINT16_C(0x0010)
/*! @name Bit position definitions for wrist gesture configuration */
#define BMI2_WRIST_GEST_WEAR_ARM_POS UINT8_C(0x04)
/*! @name Mask definitions for BMI2 wrist gesture wh configuration */
#define BMI2_WRIST_GEST_WH_DEVICE_POS_MASK UINT16_C(0x0001)
#define BMI2_WRIST_GEST_WH_INT UINT8_C(0x10)
#define BMI2_WRIST_GEST_WH_START_ADD UINT8_C(0x08)
/*! @name Mask definitions for BMI2 wrist wear wake-up configuration */
#define BMI2_WRIST_WAKE_UP_WH_INT_MASK UINT8_C(0x08)
/*! @name Mask definition for BMI2 wrist wear wake-up configuration for wearable variant */
#define BMI2_WRIST_WAKE_UP_ANGLE_LR_MASK UINT16_C(0x00FF)
#define BMI2_WRIST_WAKE_UP_ANGLE_LL_MASK UINT16_C(0xFF00)
#define BMI2_WRIST_WAKE_UP_ANGLE_PD_MASK UINT16_C(0x00FF)
#define BMI2_WRIST_WAKE_UP_ANGLE_PU_MASK UINT16_C(0xFF00)
#define BMI2_WRIST_WAKE_UP_MIN_DUR_MOVED_MASK UINT16_C(0x00FF)
#define BMI2_WRIST_WAKE_UP_MIN_DUR_QUITE_MASK UINT16_C(0xFF00)
/*! @name Bit position definition for BMI2 wrist wear wake-up configuration for wearable variant */
#define BMI2_WRIST_WAKE_UP_ANGLE_LL_POS UINT16_C(0x0008)
#define BMI2_WRIST_WAKE_UP_ANGLE_PU_POS UINT16_C(0x0008)
#define BMI2_WRIST_WAKE_UP_MIN_DUR_QUITE_POS UINT16_C(0x0008)
/*! @name Mask definition for BMI2 EXT TCO configuration */
#define BMI2_EXT_TCO_MASK UINT8_C(0x01)
/*! @name Macros to define values of BMI2 axis and its sign for re-map
* settings
*/
#define BMI2_MAP_X_AXIS UINT8_C(0x00)
#define BMI2_MAP_Y_AXIS UINT8_C(0x01)
#define BMI2_MAP_Z_AXIS UINT8_C(0x02)
#define BMI2_MAP_POSITIVE UINT8_C(0x00)
#define BMI2_MAP_NEGATIVE UINT8_C(0x01)
/*! @name Mask definitions of BMI2 axis re-mapping */
#define BMI2_X_AXIS_MASK UINT8_C(0x03)
#define BMI2_X_AXIS_SIGN_MASK UINT8_C(0x04)
#define BMI2_Y_AXIS_MASK UINT8_C(0x18)
#define BMI2_Y_AXIS_SIGN_MASK UINT8_C(0x20)
#define BMI2_Z_AXIS_MASK UINT8_C(0xC0)
#define BMI2_Z_AXIS_SIGN_MASK UINT8_C(0x01)
/*! @name Bit position definitions of BMI2 axis re-mapping */
#define BMI2_X_AXIS_SIGN_POS UINT8_C(0x02)
#define BMI2_Y_AXIS_POS UINT8_C(0x03)
#define BMI2_Y_AXIS_SIGN_POS UINT8_C(0x05)
#define BMI2_Z_AXIS_POS UINT8_C(0x06)
/*! @name Macros to define polarity */
#define BMI2_NEG_SIGN UINT8_C(1)
#define BMI2_POS_SIGN UINT8_C(0)
/*! @name Macro to define related to CRT */
#define BMI2_CRT_READY_FOR_DOWNLOAD_US UINT16_C(2000)
#define BMI2_CRT_READY_FOR_DOWNLOAD_RETRY UINT8_C(100)
#define BMI2_CRT_WAIT_RUNNING_US UINT16_C(10000)
#define BMI2_CRT_WAIT_RUNNING_RETRY_EXECUTION UINT8_C(200)
#define BMI2_CRT_MIN_BURST_WORD_LENGTH UINT8_C(2)
#define BMI2_CRT_MAX_BURST_WORD_LENGTH UINT16_C(255)
/* Reference value with positive and negative noise range in lsb */
/*
* For Gyro FOC, axes values after FOC must be 0 +/- 1 dps
*
* In 2000 dps, 1 dps is 16.384 (~16)
* In 1000 dps, 1 dps is 32.768 (~33)
* In 500 dps, 1 dps is 65.536 (~66)
* In 250 dps, 1 dps is 131.072 (~131)
* In 125 dps, 1 dps is 262.144 (~262)
*/
#define BMI2_GYRO_FOC_2000_DPS_REF UINT16_C(16)
#define BMI2_GYRO_FOC_1000_DPS_REF UINT16_C(33)
#define BMI2_GYRO_FOC_500_DPS_REF UINT16_C(66)
#define BMI2_GYRO_FOC_250_DPS_REF UINT16_C(131)
#define BMI2_GYRO_FOC_125_DPS_REF UINT16_C(262)
/* Reference value with positive and negative noise range in lsb */
/*
* As per datasheet, Zero-g offset : +/- 20mg
*
* In range 2G, 1G is 16384. so, 16384 x 20 x (10 ^ -3) = 328
* In range 4G, 1G is 8192. so, 8192 x 20 x (10 ^ -3) = 164
* In range 8G, 1G is 4096. so, 4096 x 20 x (10 ^ -3) = 82
* In range 16G, 1G is 2048. so, 2048 x 20 x (10 ^ -3) = 41
*/
#define BMI2_ACC_FOC_2G_REF UINT16_C(16384)
#define BMI2_ACC_FOC_4G_REF UINT16_C(8192)
#define BMI2_ACC_FOC_8G_REF UINT16_C(4096)
#define BMI2_ACC_FOC_16G_REF UINT16_C(2048)
#define BMI2_ACC_FOC_2G_OFFSET UINT16_C(328)
#define BMI2_ACC_FOC_4G_OFFSET UINT16_C(164)
#define BMI2_ACC_FOC_8G_OFFSET UINT16_C(82)
#define BMI2_ACC_FOC_16G_OFFSET UINT16_C(41)
#define BMI2_ACC_2G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_2G_REF + BMI2_ACC_FOC_2G_OFFSET)
#define BMI2_ACC_2G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_2G_REF - BMI2_ACC_FOC_2G_OFFSET)
#define BMI2_ACC_4G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_4G_REF + BMI2_ACC_FOC_4G_OFFSET)
#define BMI2_ACC_4G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_4G_REF - BMI2_ACC_FOC_4G_OFFSET)
#define BMI2_ACC_8G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_8G_REF + BMI2_ACC_FOC_8G_OFFSET)
#define BMI2_ACC_8G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_8G_REF - BMI2_ACC_FOC_8G_OFFSET)
#define BMI2_ACC_16G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_16G_REF + BMI2_ACC_FOC_16G_OFFSET)
#define BMI2_ACC_16G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_16G_REF - BMI2_ACC_FOC_16G_OFFSET)
#define BMI2_FOC_SAMPLE_LIMIT UINT8_C(128)
/*! @name Bit wise selection of BMI2 sensors */
#define BMI2_MAIN_SENSORS \
(BMI2_ACCEL_SENS_SEL | BMI2_GYRO_SENS_SEL \
| BMI2_AUX_SENS_SEL | BMI2_TEMP_SENS_SEL)
/*! @name Maximum number of BMI2 main sensors */
#define BMI2_MAIN_SENS_MAX_NUM UINT8_C(4)
/*! @name Macro to specify the number of step counter parameters */
#define BMI2_STEP_CNT_N_PARAMS UINT8_C(25)
/*! @name Macro to specify the number of free-fall accel setting parameters */
#define BMI2_FREE_FALL_ACCEL_SET_PARAMS UINT8_C(7)
#define BMI2_SELECT_GYRO_SELF_TEST UINT8_C(0)
#define BMI2_SELECT_CRT UINT8_C(1)
/*! @name Macro for NVM enable */
#define BMI2_NVM_UNLOCK_ENABLE UINT8_C(0x02)
#define BMI2_NVM_UNLOCK_DISABLE UINT8_C(0x00)
/*! @name macro to select between gyro self test and CRT */
#define BMI2_GYRO_SELF_TEST_SEL UINT8_C(0)
#define BMI2_CRT_SEL UINT8_C(1)
/******************************************************************************/
/*! @name Accelerometer Macro Definitions */
/******************************************************************************/
/*! @name Accelerometer Bandwidth parameters */
#define BMI2_ACC_OSR4_AVG1 UINT8_C(0x00)
#define BMI2_ACC_OSR2_AVG2 UINT8_C(0x01)
#define BMI2_ACC_NORMAL_AVG4 UINT8_C(0x02)
#define BMI2_ACC_CIC_AVG8 UINT8_C(0x03)
#define BMI2_ACC_RES_AVG16 UINT8_C(0x04)
#define BMI2_ACC_RES_AVG32 UINT8_C(0x05)
#define BMI2_ACC_RES_AVG64 UINT8_C(0x06)
#define BMI2_ACC_RES_AVG128 UINT8_C(0x07)
/*! @name Accelerometer Output Data Rate */
#define BMI2_ACC_ODR_0_78HZ UINT8_C(0x01)
#define BMI2_ACC_ODR_1_56HZ UINT8_C(0x02)
#define BMI2_ACC_ODR_3_12HZ UINT8_C(0x03)
#define BMI2_ACC_ODR_6_25HZ UINT8_C(0x04)
#define BMI2_ACC_ODR_12_5HZ UINT8_C(0x05)
#define BMI2_ACC_ODR_25HZ UINT8_C(0x06)
#define BMI2_ACC_ODR_50HZ UINT8_C(0x07)
#define BMI2_ACC_ODR_100HZ UINT8_C(0x08)
#define BMI2_ACC_ODR_200HZ UINT8_C(0x09)
#define BMI2_ACC_ODR_400HZ UINT8_C(0x0A)
#define BMI2_ACC_ODR_800HZ UINT8_C(0x0B)
#define BMI2_ACC_ODR_1600HZ UINT8_C(0x0C)
/*! @name Accelerometer G Range */
#define BMI2_ACC_RANGE_2G UINT8_C(0x00)
#define BMI2_ACC_RANGE_4G UINT8_C(0x01)
#define BMI2_ACC_RANGE_8G UINT8_C(0x02)
#define BMI2_ACC_RANGE_16G UINT8_C(0x03)
/*! @name Mask definitions for accelerometer configuration register */
#define BMI2_ACC_RANGE_MASK UINT8_C(0x03)
#define BMI2_ACC_ODR_MASK UINT8_C(0x0F)
#define BMI2_ACC_BW_PARAM_MASK UINT8_C(0x70)
#define BMI2_ACC_FILTER_PERF_MODE_MASK UINT8_C(0x80)
/*! @name Bit position definitions for accelerometer configuration register */
#define BMI2_ACC_BW_PARAM_POS UINT8_C(0x04)
#define BMI2_ACC_FILTER_PERF_MODE_POS UINT8_C(0x07)
/*! @name Self test macro to define range */
#define BMI2_ACC_SELF_TEST_RANGE UINT8_C(16)
/*! @name Self test macro to show resulting minimum and maximum difference
* signal of the axes in mg
*/
#define BMI2_ST_ACC_X_SIG_MIN_DIFF INT16_C(16000)
#define BMI2_ST_ACC_Y_SIG_MIN_DIFF INT16_C(-15000)
#define BMI2_ST_ACC_Z_SIG_MIN_DIFF INT16_C(10000)
/*! @name Mask definitions for accelerometer self-test */
#define BMI2_ACC_SELF_TEST_EN_MASK UINT8_C(0x01)
#define BMI2_ACC_SELF_TEST_SIGN_MASK UINT8_C(0x04)
#define BMI2_ACC_SELF_TEST_AMP_MASK UINT8_C(0x08)
/*! @name Bit Positions for accelerometer self-test */
#define BMI2_ACC_SELF_TEST_SIGN_POS UINT8_C(0x02)
#define BMI2_ACC_SELF_TEST_AMP_POS UINT8_C(0x03)
/*! @name MASK definition for gyro self test status */
#define BMI2_GYR_ST_AXES_DONE_MASK UINT8_C(0x01)
#define BMI2_GYR_AXIS_X_OK_MASK UINT8_C(0x02)
#define BMI2_GYR_AXIS_Y_OK_MASK UINT8_C(0x04)
#define BMI2_GYR_AXIS_Z_OK_MASK UINT8_C(0x08)
/*! @name Bit position for gyro self test status */
#define BMI2_GYR_AXIS_X_OK_POS UINT8_C(0x01)
#define BMI2_GYR_AXIS_Y_OK_POS UINT8_C(0x02)
#define BMI2_GYR_AXIS_Z_OK_POS UINT8_C(0x03)
/******************************************************************************/
/*! @name Gyroscope Macro Definitions */
/******************************************************************************/
/*! @name Gyroscope Bandwidth parameters */
#define BMI2_GYR_OSR4_MODE UINT8_C(0x00)
#define BMI2_GYR_OSR2_MODE UINT8_C(0x01)
#define BMI2_GYR_NORMAL_MODE UINT8_C(0x02)
#define BMI2_GYR_CIC_MODE UINT8_C(0x03)
/*! @name Gyroscope Output Data Rate */
#define BMI2_GYR_ODR_25HZ UINT8_C(0x06)
#define BMI2_GYR_ODR_50HZ UINT8_C(0x07)
#define BMI2_GYR_ODR_100HZ UINT8_C(0x08)
#define BMI2_GYR_ODR_200HZ UINT8_C(0x09)
#define BMI2_GYR_ODR_400HZ UINT8_C(0x0A)
#define BMI2_GYR_ODR_800HZ UINT8_C(0x0B)
#define BMI2_GYR_ODR_1600HZ UINT8_C(0x0C)
#define BMI2_GYR_ODR_3200HZ UINT8_C(0x0D)
/*! @name Gyroscope OIS Range */
#define BMI2_GYR_OIS_250 UINT8_C(0x00)
#define BMI2_GYR_OIS_2000 UINT8_C(0x01)
/*! @name Gyroscope Angular Rate Measurement Range */
#define BMI2_GYR_RANGE_2000 UINT8_C(0x00)
#define BMI2_GYR_RANGE_1000 UINT8_C(0x01)
#define BMI2_GYR_RANGE_500 UINT8_C(0x02)
#define BMI2_GYR_RANGE_250 UINT8_C(0x03)
#define BMI2_GYR_RANGE_125 UINT8_C(0x04)
/*! @name Mask definitions for gyroscope configuration register */