-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfxas21002.h
855 lines (642 loc) · 37.6 KB
/
fxas21002.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
/*
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @file fxas21002.h
* @brief The fxas21002.h contains the fxas21002 sensor register definitions and its bit mask.
*/
#ifndef FXAS21002_H_
#define FXAS21002_H_
/**
** FXAS21002 I2C Address
*/
#define FXAS21002_I2C_ADDRESS 0x20
/**
**
** @brief The FXAS21002 Sensor Register Map.
*/
enum {
FXAS21002_STATUS = 0x00,
FXAS21002_OUT_X_MSB = 0x01,
FXAS21002_OUT_X_LSB = 0x02,
FXAS21002_OUT_Y_MSB = 0x03,
FXAS21002_OUT_Y_LSB = 0x04,
FXAS21002_OUT_Z_MSB = 0x05,
FXAS21002_OUT_Z_LSB = 0x06,
FXAS21002_DR_STATUS = 0x07,
FXAS21002_F_STATUS = 0x08,
FXAS21002_F_SETUP = 0x09,
FXAS21002_F_EVENT = 0x0A,
FXAS21002_INT_SRC_FLAG = 0x0B,
FXAS21002_WHO_AM_I = 0x0C,
FXAS21002_CTRL_REG0 = 0x0D,
FXAS21002_RT_CFG = 0x0E,
FXAS21002_RT_SRC = 0x0F,
FXAS21002_RT_THS = 0x10,
FXAS21002_RT_COUNT = 0x11,
FXAS21002_TEMP = 0x12,
FXAS21002_CTRL_REG1 = 0x13,
FXAS21002_CTRL_REG2 = 0x14,
FXAS21002_CTRL_REG3 = 0x15,
};
/*--------------------------------
** Register: STATUS
** Enum: FXAS21002_STATUS
** --
** Offset : 0x00 - Alias for DR_STATUS or F_STATUS.
** ------------------------------*/
typedef uint8_t FXAS21002_STATUS_t;
/*--------------------------------
** Register: OUT_X_MSB
** Enum: FXAS21002_OUT_X_MSB
** --
** Offset : 0x01 - 8 MSBs of 16 bit X-axis data sample
** ------------------------------*/
typedef uint8_t FXAS21002_OUT_X_MSB_t;
/*--------------------------------
** Register: OUT_X_LSB
** Enum: FXAS21002_OUT_X_LSB
** --
** Offset : 0x02 - 8 LSBs of 16 bit X-axis data sample
** ------------------------------*/
typedef uint8_t FXAS21002_OUT_X_LSB_t;
/*--------------------------------
** Register: OUT_Y_MSB
** Enum: FXAS21002_OUT_Y_MSB
** --
** Offset : 0x03 - 8 MSBs of 16 bit Y-axis data sample
** ------------------------------*/
typedef uint8_t FXAS21002_OUT_Y_MSB_t;
/*--------------------------------
** Register: OUT_Y_LSB
** Enum: FXAS21002_OUT_Y_LSB
** --
** Offset : 0x04 - 8 LSBs of 16 bit Y-axis data sample
** ------------------------------*/
typedef uint8_t FXAS21002_OUT_Y_LSB_t;
/*--------------------------------
** Register: OUT_Z_MSB
** Enum: FXAS21002_OUT_Z_MSB
** --
** Offset : 0x05 - 8 MSBs of 16 bit Z-axis data sample
** ------------------------------*/
typedef uint8_t FXAS21002_OUT_Z_MSB_t;
/*--------------------------------
** Register: OUT_Z_LSB
** Enum: FXAS21002_OUT_Z_LSB
** --
** Offset : 0x06 - 8 LSBs of 16 bit Z-axis data sample
** ------------------------------*/
typedef uint8_t FXAS21002_OUT_Z_LSB_t;
/*--------------------------------
** Register: DR_STATUS
** Enum: FXAS21002_DR_STATUS
** --
** Offset : 0x07 - Data-ready status information (FIFO disabled by setting F_SETUP :: F_MODE = 0)
** ------------------------------*/
typedef union {
struct {
uint8_t xdr : 1; /* X-axis new data available. */
uint8_t ydr : 1; /* Y-axis new data available. */
uint8_t zdr : 1; /* Z-axis new data available. */
uint8_t zyxdr : 1; /* X-, Y-, and Z-axis data available. */
uint8_t xow : 1; /* X-axis data overwrite. */
uint8_t yow : 1; /* Y-axis data overwrite. */
uint8_t zow : 1; /* Z-axis data overwrite. */
uint8_t zyxow : 1; /* X-, Y-, Z-axis data overwrite. */
} b;
uint8_t w;
} FXAS21002_DR_STATUS_t;
/*
** DR_STATUS - Bit field mask definitions
*/
#define FXAS21002_DR_STATUS_XDR_MASK ((uint8_t) 0x01)
#define FXAS21002_DR_STATUS_XDR_SHIFT ((uint8_t) 0)
#define FXAS21002_DR_STATUS_YDR_MASK ((uint8_t) 0x02)
#define FXAS21002_DR_STATUS_YDR_SHIFT ((uint8_t) 1)
#define FXAS21002_DR_STATUS_ZDR_MASK ((uint8_t) 0x04)
#define FXAS21002_DR_STATUS_ZDR_SHIFT ((uint8_t) 2)
#define FXAS21002_DR_STATUS_ZYXDR_MASK ((uint8_t) 0x08)
#define FXAS21002_DR_STATUS_ZYXDR_SHIFT ((uint8_t) 3)
#define FXAS21002_DR_STATUS_XOW_MASK ((uint8_t) 0x10)
#define FXAS21002_DR_STATUS_XOW_SHIFT ((uint8_t) 4)
#define FXAS21002_DR_STATUS_YOW_MASK ((uint8_t) 0x20)
#define FXAS21002_DR_STATUS_YOW_SHIFT ((uint8_t) 5)
#define FXAS21002_DR_STATUS_ZOW_MASK ((uint8_t) 0x40)
#define FXAS21002_DR_STATUS_ZOW_SHIFT ((uint8_t) 6)
#define FXAS21002_DR_STATUS_ZYXOW_MASK ((uint8_t) 0x80)
#define FXAS21002_DR_STATUS_ZYXOW_SHIFT ((uint8_t) 7)
/*
** DR_STATUS - Bit field value definitions
*/
#define FXAS21002_DR_STATUS_XDR_DRDY ((uint8_t) 0x01) /* Set to 1 whenever a new X-axis data acquisition */
/* is completed. Cleared anytime the OUT_X_MSB */
/* register is read. */
#define FXAS21002_DR_STATUS_YDR_DRDY ((uint8_t) 0x02) /* Set to 1 whenever a new Y-axis data acquisition */
/* is completed. Cleared anytime the OUT_Y_MSB */
/* register is read. */
#define FXAS21002_DR_STATUS_ZDR_DRDY ((uint8_t) 0x04) /* Set to 1 whenever a new Z-axis data acquisition */
/* is completed. Cleared anytime the OUT_Z_MSB */
/* register is read. */
#define FXAS21002_DR_STATUS_ZYXDR_DRDY ((uint8_t) 0x08) /* Cleared when the high-bytes of the acceleration */
/* data (OUT_X_MSB, OUT_Y_MSB, OUT_Z_MSB) are read. */
#define FXAS21002_DR_STATUS_XOW_OWR ((uint8_t) 0x10) /* Asserted whenever a new X-axis acquisition is */
/* completed before the retrieval of the previous */
/* data. */
#define FXAS21002_DR_STATUS_YOW_OWR ((uint8_t) 0x20) /* Asserted whenever a new Y-axis acquisition is */
/* completed before the retrieval of the previous */
/* data. */
#define FXAS21002_DR_STATUS_ZOW_OWR ((uint8_t) 0x40) /* Asserted whenever a new Z-axis acquisition is */
/* completed before the retrieval of the previous */
/* data. */
#define FXAS21002_DR_STATUS_ZYXOW_OWR ((uint8_t) 0x80) /* Asserted whenever new X-, Y-, and Z-axis data is */
/* acquired before completing the retrieval of the */
/* previous set. */
/*------------------------------*/
/*--------------------------------
** Register: F_STATUS
** Enum: FXAS21002_F_STATUS
** --
** Offset : 0x08 - FIFO status information (FIFO enabled by setting F_SETUP :: F_MODE > 0)
** ------------------------------*/
typedef union {
struct {
uint8_t f_cnt : 6; /* FIFO sample counter; indicates the number of samples currently stored in */
/* the FIFO. */
uint8_t f_wmkf : 1; /* FIFO sample count greater than or equal to the watermark count (F_SETUP :: */
/* F_WMRK) has been detected. */
uint8_t f_ovf : 1; /* FIFO overflow event, such as when F_CNT = 32 and a new sample arrives, */
/* asserts the F_OVF flag. */
} b;
uint8_t w;
} FXAS21002_F_STATUS_t;
/*
** F_STATUS - Bit field mask definitions
*/
#define FXAS21002_F_STATUS_F_CNT_MASK ((uint8_t) 0x3F)
#define FXAS21002_F_STATUS_F_CNT_SHIFT ((uint8_t) 0)
#define FXAS21002_F_STATUS_F_WMKF_MASK ((uint8_t) 0x40)
#define FXAS21002_F_STATUS_F_WMKF_SHIFT ((uint8_t) 6)
#define FXAS21002_F_STATUS_F_OVF_MASK ((uint8_t) 0x80)
#define FXAS21002_F_STATUS_F_OVF_SHIFT ((uint8_t) 7)
/*
** F_STATUS - Bit field value definitions
*/
#define FXAS21002_F_STATUS_F_WMKF_DETECT ((uint8_t) 0x40) /* FIFO Watermark event has been detected. */
#define FXAS21002_F_STATUS_F_OVF_DETECT ((uint8_t) 0x80) /* FIFO Overflow event has been detected. */
/*------------------------------*/
/*--------------------------------
** Register: F_SETUP
** Enum: FXAS21002_F_SETUP
** --
** Offset : 0x09 - FIFO configuration
** ------------------------------*/
typedef union {
struct {
uint8_t f_wmrk : 6; /* FIFO operating mode selection. */
uint8_t f_mode : 2; /* FIFO sample count watermark setting. */
} b;
uint8_t w;
} FXAS21002_F_SETUP_t;
/*
** F_SETUP - Bit field mask definitions
*/
#define FXAS21002_F_SETUP_F_WMRK_MASK ((uint8_t) 0x3F)
#define FXAS21002_F_SETUP_F_WMRK_SHIFT ((uint8_t) 0)
#define FXAS21002_F_SETUP_F_MODE_MASK ((uint8_t) 0xC0)
#define FXAS21002_F_SETUP_F_MODE_SHIFT ((uint8_t) 6)
/*
** F_SETUP - Bit field value definitions
*/
#define FXAS21002_F_SETUP_F_MODE_FIFO_OFF ((uint8_t) 0x00) /* FIFO is disabled. */
#define FXAS21002_F_SETUP_F_MODE_CIR_MODE ((uint8_t) 0x40) /* FIFO is in Circular Buffer mode. */
#define FXAS21002_F_SETUP_F_MODE_STOP_MODE ((uint8_t) 0x80) /* FIFO is in Stop mode. */
/*------------------------------*/
/*--------------------------------
** Register: F_EVENT
** Enum: FXAS21002_F_EVENT
** --
** Offset : 0x0A - FIFO event status
** ------------------------------*/
typedef union {
struct {
uint8_t fe_time : 5; /* Number of ODR periods elapsed since F_EVENT was set. */
uint8_t f_event : 1; /* FIFO Event: Indicates if either F_WMKF or F_OVF flags are set (logical */
/* OR). */
} b;
uint8_t w;
} FXAS21002_F_EVENT_t;
/*
** F_EVENT - Bit field mask definitions
*/
#define FXAS21002_F_EVENT_FE_TIME_MASK ((uint8_t) 0x1F)
#define FXAS21002_F_EVENT_FE_TIME_SHIFT ((uint8_t) 0)
#define FXAS21002_F_EVENT_F_EVENT_MASK ((uint8_t) 0x20)
#define FXAS21002_F_EVENT_F_EVENT_SHIFT ((uint8_t) 5)
/*
** F_EVENT - Bit field value definitions
*/
#define FXAS21002_F_EVENT_F_EVENT_DETECTED ((uint8_t) 0x20) /* FIFO event was detected */
/*------------------------------*/
/*--------------------------------
** Register: INT_SRC_FLAG
** Enum: FXAS21002_INT_SRC_FLAG
** --
** Offset : 0x0B - Interrupt source status
** ------------------------------*/
typedef union {
struct {
uint8_t src_drdy : 1; /* Data ready event source flag. */
uint8_t src_rt : 1; /* Rate threshold event source flag. */
uint8_t src_fifo : 1; /* FIFO event source flag. */
uint8_t bootend : 1; /* Boot sequence complete event flag. */
} b;
uint8_t w;
} FXAS21002_INT_SRC_FLAG_t;
/*
** INT_SRC_FLAG - Bit field mask definitions
*/
#define FXAS21002_INT_SRC_FLAG_SRC_DRDY_MASK ((uint8_t) 0x01)
#define FXAS21002_INT_SRC_FLAG_SRC_DRDY_SHIFT ((uint8_t) 0)
#define FXAS21002_INT_SRC_FLAG_SRC_RT_MASK ((uint8_t) 0x02)
#define FXAS21002_INT_SRC_FLAG_SRC_RT_SHIFT ((uint8_t) 1)
#define FXAS21002_INT_SRC_FLAG_SRC_FIFO_MASK ((uint8_t) 0x04)
#define FXAS21002_INT_SRC_FLAG_SRC_FIFO_SHIFT ((uint8_t) 2)
#define FXAS21002_INT_SRC_FLAG_BOOTEND_MASK ((uint8_t) 0x08)
#define FXAS21002_INT_SRC_FLAG_BOOTEND_SHIFT ((uint8_t) 3)
/*
** INT_SRC_FLAG - Bit field value definitions
*/
#define FXAS21002_INT_SRC_FLAG_SRC_DRDY_READY ((uint8_t) 0x01) /* Asserted whenever a data-ready event triggers */
/* the interrupt. */
#define FXAS21002_INT_SRC_FLAG_SRC_RT_THRESH ((uint8_t) 0x02) /* Indicates that the rate threshold event flag */
/* triggered the interrupt. */
#define FXAS21002_INT_SRC_FLAG_SRC_FIFO_EVENT ((uint8_t) 0x04) /* F_OVF or F_WMKF are set, provided the FIFO */
/* interrupt is enabled. */
#define FXAS21002_INT_SRC_FLAG_BOOTEND_BOOT_DONE ((uint8_t) 0x08) /* Boot sequence is complete. */
/*------------------------------*/
/*--------------------------------
** Register: WHO_AM_I
** Enum: FXAS21002_WHO_AM_I
** --
** Offset : 0x0C - The WHO_AM_I register contains the device idenifier.
** ------------------------------*/
typedef union {
struct {
uint8_t whoami; /* The WHO_AM_I register contains the device identifier which is factory */
/* programmed. */
} b;
uint8_t w;
} FXAS21002_WHO_AM_I_t;
/*
** WHO_AM_I - Bit field mask definitions
*/
#define FXAS21002_WHO_AM_I_WHOAMI_MASK ((uint8_t) 0xFF)
#define FXAS21002_WHO_AM_I_WHOAMI_SHIFT ((uint8_t) 0)
/*
** WHO_AM_I - Bit field value definitions
*/
#define FXAS21002_WHO_AM_I_WHOAMI_OLD_VALUE ((uint8_t) 0xd1) /* FXAS21000 */
#define FXAS21002_WHO_AM_I_WHOAMI_PRE_VALUE ((uint8_t) 0xd6) /* Engineering Samples */
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE ((uint8_t) 0xd7) /* FXAS21002 Rev 2.1 (production) */
/*------------------------------*/
/*--------------------------------
** Register: CTRL_REG0
** --
** Offset : 0x0D - Used for general control and configuration.
** ------------------------------*/
typedef union {
struct {
uint8_t fs : 2; /* Full-scale range selection. */
uint8_t hpf_en : 1; /* High-pass filter enable. The high-pass filter is initialized on operating */
/* mode and ODR change. When enabled, the HPF is applied to the angular rate */
/* data supplied to the output registers/FIFO and the embedded rate threshold */
/* algorithm. */
uint8_t sel : 2; /* High-pass filter cutoff frequency selection. */
uint8_t spiw : 1; /* SPI interface mode selection. */
uint8_t bw : 2; /* Bandwidth selects the cut-off frequency of the digital low-pass filter. */
} b;
uint8_t w;
} FXAS21002_CTRL_REG0_t;
/*
** CTRL_REG0 - Bit field mask definitions
*/
#define FXAS21002_CTRL_REG0_FS_MASK ((uint8_t) 0x03)
#define FXAS21002_CTRL_REG0_FS_SHIFT ((uint8_t) 0)
#define FXAS21002_CTRL_REG0_HPF_EN_MASK ((uint8_t) 0x04)
#define FXAS21002_CTRL_REG0_HPF_EN_SHIFT ((uint8_t) 2)
#define FXAS21002_CTRL_REG0_SEL_MASK ((uint8_t) 0x18)
#define FXAS21002_CTRL_REG0_SEL_SHIFT ((uint8_t) 3)
#define FXAS21002_CTRL_REG0_SPIW_MASK ((uint8_t) 0x20)
#define FXAS21002_CTRL_REG0_SPIW_SHIFT ((uint8_t) 5)
#define FXAS21002_CTRL_REG0_BW_MASK ((uint8_t) 0xC0)
#define FXAS21002_CTRL_REG0_BW_SHIFT ((uint8_t) 6)
/*
** CTRL_REG0 - Bit field value definitions
*/
#define FXAS21002_CTRL_REG0_FS_DPS2000 ((uint8_t) 0x00) /* 2000 degrees per second (4000 dps if CTRL_REG3 : */
/* FS_DOUBLE = 1). */
#define FXAS21002_CTRL_REG0_FS_DPS1000 ((uint8_t) 0x01) /* 1000 degrees per second (2000 dps if CTRL_REG3 : */
/* FS_DOUBLE = 1). */
#define FXAS21002_CTRL_REG0_FS_DPS500 ((uint8_t) 0x02) /* 500 degrees per second (1000 dps if CTRL_REG3 : */
/* FS_DOUBLE = 1). */
#define FXAS21002_CTRL_REG0_FS_DPS250 ((uint8_t) 0x03) /* 250 degrees per second (500 dps if CTRL_REG3 : */
/* FS_DOUBLE = 1). */
#define FXAS21002_CTRL_REG0_HPF_EN_ENABLE ((uint8_t) 0x04)
#define FXAS21002_CTRL_REG0_HPF_EN_DISABLE ((uint8_t) 0x00)
#define FXAS21002_CTRL_REG0_SPIW_4WIRE ((uint8_t) 0x00) /* SPI 4-wire mode (default). */
#define FXAS21002_CTRL_REG0_SPIW_3WIRE ((uint8_t) 0x20) /* SPI 3-wire mode (MOSI pin is used for SPI input */
/* and output signals). */
/*------------------------------*/
/*--------------------------------
** Register: RT_CFG
** Enum: FXAS21002_RT_CFG
** --
** Offset : 0x0E - Used to enable the Rate Threshold interrupt generation.
** ------------------------------*/
typedef union {
struct {
uint8_t xtefe : 1; /* Event flag enable on X rate. */
uint8_t ytefe : 1; /* Event flag enable on Y rate. */
uint8_t ztefe : 1; /* Event flag enable on Z rate. */
uint8_t ele : 1; /* Event latch enable. */
} b;
uint8_t w;
} FXAS21002_RT_CFG_t;
/*
** RT_CFG - Bit field mask definitions
*/
#define FXAS21002_RT_CFG_XTEFE_MASK ((uint8_t) 0x01)
#define FXAS21002_RT_CFG_XTEFE_SHIFT ((uint8_t) 0)
#define FXAS21002_RT_CFG_YTEFE_MASK ((uint8_t) 0x02)
#define FXAS21002_RT_CFG_YTEFE_SHIFT ((uint8_t) 1)
#define FXAS21002_RT_CFG_ZTEFE_MASK ((uint8_t) 0x04)
#define FXAS21002_RT_CFG_ZTEFE_SHIFT ((uint8_t) 2)
#define FXAS21002_RT_CFG_ELE_MASK ((uint8_t) 0x08)
#define FXAS21002_RT_CFG_ELE_SHIFT ((uint8_t) 3)
/*
** RT_CFG - Bit field value definitions
*/
#define FXAS21002_RT_CFG_XTEFE_ENABLE ((uint8_t) 0x01) /* X event detection enabled. */
#define FXAS21002_RT_CFG_XTEFE_DISABLE ((uint8_t) 0x00) /* X event detection disabled. */
#define FXAS21002_RT_CFG_YTEFE_ENABLE ((uint8_t) 0x02) /* Y event detection enabled. */
#define FXAS21002_RT_CFG_YTEFE_DISABLE ((uint8_t) 0x00) /* Y event detection disabled. */
#define FXAS21002_RT_CFG_ZTEFE_ENABLE ((uint8_t) 0x04) /* Z event detection enabled. */
#define FXAS21002_RT_CFG_ZTEFE_DISABLE ((uint8_t) 0x00) /* Z event detection disabled. */
#define FXAS21002_RT_CFG_ELE_ENABLE ((uint8_t) 0x08) /* Event flag latch enabled. */
#define FXAS21002_RT_CFG_ELE_DISABLE ((uint8_t) 0x00) /* Event flag latch disabled. */
/*------------------------------*/
/*--------------------------------
** Register: RT_SRC
** Enum: FXAS21002_RT_SRC
** --
** Offset : 0x0F - Indicates the source of the Rate Threshold event. It also clears the RT_SRC flag in the INT_SOURCE_FLAG register.
** ------------------------------*/
typedef union {
struct {
uint8_t x_rt_pol : 1; /* Polarity of X event. */
uint8_t xrt : 1; /* X rate Event. */
uint8_t y_rt_pol : 1; /* Polarity of Y event. */
uint8_t yrt : 1; /* Y rate event. */
uint8_t z_rt_pol : 1; /* Polarity of Z event. */
uint8_t zrt : 1; /* Z rate event. */
uint8_t ea : 1; /* Event active flag. */
} b;
uint8_t w;
} FXAS21002_RT_SRC_t;
/*
** RT_SRC - Bit field mask definitions
*/
#define FXAS21002_RT_SRC_X_RT_POL_MASK ((uint8_t) 0x01)
#define FXAS21002_RT_SRC_X_RT_POL_SHIFT ((uint8_t) 0)
#define FXAS21002_RT_SRC_XRT_MASK ((uint8_t) 0x02)
#define FXAS21002_RT_SRC_XRT_SHIFT ((uint8_t) 1)
#define FXAS21002_RT_SRC_Y_RT_POL_MASK ((uint8_t) 0x04)
#define FXAS21002_RT_SRC_Y_RT_POL_SHIFT ((uint8_t) 2)
#define FXAS21002_RT_SRC_YRT_MASK ((uint8_t) 0x08)
#define FXAS21002_RT_SRC_YRT_SHIFT ((uint8_t) 3)
#define FXAS21002_RT_SRC_Z_RT_POL_MASK ((uint8_t) 0x10)
#define FXAS21002_RT_SRC_Z_RT_POL_SHIFT ((uint8_t) 4)
#define FXAS21002_RT_SRC_ZRT_MASK ((uint8_t) 0x20)
#define FXAS21002_RT_SRC_ZRT_SHIFT ((uint8_t) 5)
#define FXAS21002_RT_SRC_EA_MASK ((uint8_t) 0x40)
#define FXAS21002_RT_SRC_EA_SHIFT ((uint8_t) 6)
/*
** RT_SRC - Bit field value definitions
*/
#define FXAS21002_RT_SRC_X_RT_POL_POS ((uint8_t) 0x00) /* Rate Event was Positive. */
#define FXAS21002_RT_SRC_X_RT_POL_NEG ((uint8_t) 0x01) /* Rate Event was Negative. */
#define FXAS21002_RT_SRC_XRT_LOWER ((uint8_t) 0x00) /* Rate lower than RT_THS value. */
#define FXAS21002_RT_SRC_XRT_GREATER ((uint8_t) 0x02) /* Rate greater than RT_THS value. Event has occured. */
#define FXAS21002_RT_SRC_Y_RT_POL_POS ((uint8_t) 0x00) /* Rate Event was Positive. */
#define FXAS21002_RT_SRC_Y_RT_POL_NEG ((uint8_t) 0x04) /* Rate Event was Negative. */
#define FXAS21002_RT_SRC_YRT_LOWER ((uint8_t) 0x00) /* Rate lower than RT_THS value. */
#define FXAS21002_RT_SRC_YRT_GREATER ((uint8_t) 0x08) /* Rate greater than RT_THS value. Event has occured. */
#define FXAS21002_RT_SRC_Z_RT_POL_POS ((uint8_t) 0x00) /* Rate Event was Positive. */
#define FXAS21002_RT_SRC_Z_RT_POL_NEG ((uint8_t) 0x10) /* Rate Event was Negative. */
#define FXAS21002_RT_SRC_ZRT_LOWER ((uint8_t) 0x00) /* Rate lower than RT_THS value. */
#define FXAS21002_RT_SRC_ZRT_GREATER ((uint8_t) 0x20) /* Rate greater than RT_THS value. Event has occured. */
#define FXAS21002_RT_SRC_EA_NOEVENT ((uint8_t) 0x00) /* No event flags have been asserted. */
#define FXAS21002_RT_SRC_EA_EVENT ((uint8_t) 0x40) /* One or more event flags have been asserted. */
/*------------------------------*/
/*--------------------------------
** Register: RT_THS
** Enum: FXAS21002_RT_THS
** --
** Offset : 0x10 - The RT_THS register sets the threshold limit for the detection of the rate and the debounce counter mode.
** ------------------------------*/
typedef union {
struct {
uint8_t ths : 7; /* Unsigned 7-bit rate threshold value; The contents should only be modified */
/* when the device is in Standby mode; The internal state of the Rate */
/* Threshold function is reset when a transition from Standby to Active or */
/* Ready to Active modes occurs. */
uint8_t dbcntm : 1; /* Debounce counter mode selection. */
} b;
uint8_t w;
} FXAS21002_RT_THS_t;
/*
** RT_THS - Bit field mask definitions
*/
#define FXAS21002_RT_THS_THS_MASK ((uint8_t) 0x7F)
#define FXAS21002_RT_THS_THS_SHIFT ((uint8_t) 0)
#define FXAS21002_RT_THS_DBCNTM_MASK ((uint8_t) 0x80)
#define FXAS21002_RT_THS_DBCNTM_SHIFT ((uint8_t) 7)
/*
** RT_THS - Bit field value definitions
*/
#define FXAS21002_RT_THS_DBCNTM_CLEAR ((uint8_t) 0x80) /* Clear counter when angular rate is below the */
/* threshold value. */
#define FXAS21002_RT_THS_DBCNTM_DECREMENT ((uint8_t) 0x00) /* Decrement counter on every ODR cycle that the */
/* angular rate is below the threshold value. */
/*------------------------------*/
/*--------------------------------
** Register: RT_COUNT
** Enum: FXAS21002_RT_COUNT
** --
** Offset : 0x11 - Sets the number of debounce counts.
** ------------------------------*/
typedef uint8_t FXAS21002_RT_COUNT_t;
/*--------------------------------
** Register: TEMP
** Enum: FXAS21002_TEMP
** --
** Offset : 0x12 - The TEMP register contains an 8-bit 2's complement temperature value with a range of 128 °C to +127 °C and a scaling of 1 °C/LSB.
** ------------------------------*/
typedef uint8_t FXAS21002_TEMP_t;
/*--------------------------------
** Register: CTRL_REG1
** Enum: FXAS21002_CTRL_REG1
** --
** Offset : 0x13 - The CTRL_REG1 register is used to configure the device ODR, set the operating mode, soft-reset the device, and exercise the Self-Test function.
** ------------------------------*/
typedef union {
struct {
uint8_t mode : 2; /* Operational Mode. */
uint8_t dr : 3; /* Output Data Rate selection. */
uint8_t st : 1; /* Self-Test Enable. */
uint8_t rst : 1; /* Software Reset. */
} b;
uint8_t w;
} FXAS21002_CTRL_REG1_t;
/*
** CTRL_REG1 - Bit field mask definitions
*/
#define FXAS21002_CTRL_REG1_MODE_MASK ((uint8_t) 0x03)
#define FXAS21002_CTRL_REG1_MODE_SHIFT ((uint8_t) 0)
#define FXAS21002_CTRL_REG1_DR_MASK ((uint8_t) 0x1C)
#define FXAS21002_CTRL_REG1_DR_SHIFT ((uint8_t) 2)
#define FXAS21002_CTRL_REG1_ST_MASK ((uint8_t) 0x20)
#define FXAS21002_CTRL_REG1_ST_SHIFT ((uint8_t) 5)
#define FXAS21002_CTRL_REG1_RST_MASK ((uint8_t) 0x40)
#define FXAS21002_CTRL_REG1_RST_SHIFT ((uint8_t) 6)
/*
** CTRL_REG1 - Bit field value definitions
*/
#define FXAS21002_CTRL_REG1_MODE_STANDBY ((uint8_t) 0x00) /* Standby Mode. Register setting allowed. Lowest */
/* power. */
#define FXAS21002_CTRL_REG1_MODE_READY ((uint8_t) 0x01) /* Ready Mode. The device is ready to measure */
/* angular rate but no data acquisitions are being */
/* made. Register reads only. Reduced power. */
#define FXAS21002_CTRL_REG1_MODE_ACTIVE ((uint8_t) 0x02) /* Active Mode. The device is fully functional. */
/* Register reads only. Maximum power. */
#define FXAS21002_CTRL_REG1_DR_800HZ ((uint8_t) 0x00)
#define FXAS21002_CTRL_REG1_DR_400HZ ((uint8_t) 0x04)
#define FXAS21002_CTRL_REG1_DR_200HZ ((uint8_t) 0x08)
#define FXAS21002_CTRL_REG1_DR_100HZ ((uint8_t) 0x0c)
#define FXAS21002_CTRL_REG1_DR_50HZ ((uint8_t) 0x10)
#define FXAS21002_CTRL_REG1_DR_25HZ ((uint8_t) 0x14)
#define FXAS21002_CTRL_REG1_DR_12_5HZ ((uint8_t) 0x18)
#define FXAS21002_CTRL_REG1_ST_ENABLE ((uint8_t) 0x20)
#define FXAS21002_CTRL_REG1_ST_DISABLE ((uint8_t) 0x00)
#define FXAS21002_CTRL_REG1_RST_TRIGGER ((uint8_t) 0x40)
#define FXAS21002_CTRL_REG1_RST_NOTTRIGGERED ((uint8_t) 0x00)
/*------------------------------*/
/*--------------------------------
** Register: CTRL_REG2
** Enum: FXAS21002_CTRL_REG2
** --
** Offset : 0x14 - This register enables and assigns the output pin(s) and logic polarities for the various interrupt sources available on the device.
** ------------------------------*/
typedef union {
struct {
uint8_t pp_od : 1; /* INT1 and INT2 pin output driver configuration. */
uint8_t ipol : 1; /* Interrupt logic polarity. */
uint8_t int_en_drdy : 1; /* Data ready interrupt enable. */
uint8_t int_cfg_drdy : 1; /* Data-ready interrupt pin routing. */
uint8_t int_en_rt : 1; /* Rate threshold interrupt enable. */
uint8_t int_cfg_rt : 1; /* Rate threshold interrupt pin routing. */
uint8_t int_en_fifo : 1; /* FIFO Interrupt Enable. */
uint8_t int_cfg_fifo : 1; /* FIFO interrupt pin routing. */
} b;
uint8_t w;
} FXAS21002_CTRL_REG2_t;
/*
** CTRL_REG2 - Bit field mask definitions
*/
#define FXAS21002_CTRL_REG2_PP_OD_MASK ((uint8_t) 0x01)
#define FXAS21002_CTRL_REG2_PP_OD_SHIFT ((uint8_t) 0)
#define FXAS21002_CTRL_REG2_IPOL_MASK ((uint8_t) 0x02)
#define FXAS21002_CTRL_REG2_IPOL_SHIFT ((uint8_t) 1)
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_MASK ((uint8_t) 0x04)
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_SHIFT ((uint8_t) 2)
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK ((uint8_t) 0x08)
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_SHIFT ((uint8_t) 3)
#define FXAS21002_CTRL_REG2_INT_EN_RT_MASK ((uint8_t) 0x10)
#define FXAS21002_CTRL_REG2_INT_EN_RT_SHIFT ((uint8_t) 4)
#define FXAS21002_CTRL_REG2_INT_CFG_RT_MASK ((uint8_t) 0x20)
#define FXAS21002_CTRL_REG2_INT_CFG_RT_SHIFT ((uint8_t) 5)
#define FXAS21002_CTRL_REG2_INT_EN_FIFO_MASK ((uint8_t) 0x40)
#define FXAS21002_CTRL_REG2_INT_EN_FIFO_SHIFT ((uint8_t) 6)
#define FXAS21002_CTRL_REG2_INT_CFG_FIFO_MASK ((uint8_t) 0x80)
#define FXAS21002_CTRL_REG2_INT_CFG_FIFO_SHIFT ((uint8_t) 7)
/*
** CTRL_REG2 - Bit field value definitions
*/
#define FXAS21002_CTRL_REG2_PP_OD_PUSHPULL ((uint8_t) 0x00) /* Push-pull output driver. */
#define FXAS21002_CTRL_REG2_PP_OD_OPENDRAIN ((uint8_t) 0x01) /* Open-drain output driver. */
#define FXAS21002_CTRL_REG2_IPOL_ACTIVE_LOW ((uint8_t) 0x00)
#define FXAS21002_CTRL_REG2_IPOL_ACTIVE_HIGH ((uint8_t) 0x02)
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE ((uint8_t) 0x04)
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_DISABLE ((uint8_t) 0x00)
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT2 ((uint8_t) 0x00) /* Interrupt is routed to INT2 pin. */
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT1 ((uint8_t) 0x08) /* Interrupt is routed to INT1 pin. */
#define FXAS21002_CTRL_REG2_INT_EN_RT_ENABLE ((uint8_t) 0x10)
#define FXAS21002_CTRL_REG2_INT_EN_RT_DISABLE ((uint8_t) 0x00)
#define FXAS21002_CTRL_REG2_INT_CFG_RT_INT2 ((uint8_t) 0x00) /* Interrupt is routed to INT2 pin. */
#define FXAS21002_CTRL_REG2_INT_CFG_RT_INT1 ((uint8_t) 0x20) /* Interrupt is routed to INT1 pin. */
#define FXAS21002_CTRL_REG2_INT_EN_FIFO_ENABLE ((uint8_t) 0x40)
#define FXAS21002_CTRL_REG2_INT_EN_FIFO_DISABLE ((uint8_t) 0x00)
#define FXAS21002_CTRL_REG2_INT_CFG_FIFO_INT2 ((uint8_t) 0x00) /* Interrupt is routed to INT2 pin. */
#define FXAS21002_CTRL_REG2_INT_CFG_FIFO_INT1 ((uint8_t) 0x80) /* Interrupt is routed to INT1 pin. */
/*------------------------------*/
/*--------------------------------
** Register: CTRL_REG3
** Enum: FXAS21002_CTRL_REG3
** --
** Offset : 0x15 - Auto-increment address configuration, external power control, Full Scale Range (FSR) expansion
** ------------------------------*/
typedef union {
struct {
uint8_t fs_double : 1; /* Increases the dynamic range for each CTRL_REG0 : FS selection by a factor */
/* of two. */
uint8_t _reserved_ : 1;
uint8_t extctrlen : 1; /* External power mode control input. */
uint8_t wraptoone : 1; /* Auto-increment read address pointer roll-over behavior. */
} b;
uint8_t w;
} FXAS21002_CTRL_REG3_t;
/*
** CTRL_REG3 - Bit field mask definitions
*/
#define FXAS21002_CTRL_REG3_FS_DOUBLE_MASK ((uint8_t) 0x01)
#define FXAS21002_CTRL_REG3_FS_DOUBLE_SHIFT ((uint8_t) 0)
#define FXAS21002_CTRL_REG3_EXTCTRLEN_MASK ((uint8_t) 0x04)
#define FXAS21002_CTRL_REG3_EXTCTRLEN_SHIFT ((uint8_t) 2)
#define FXAS21002_CTRL_REG3_WRAPTOONE_MASK ((uint8_t) 0x08)
#define FXAS21002_CTRL_REG3_WRAPTOONE_SHIFT ((uint8_t) 3)
/*
** CTRL_REG3 - Bit field value definitions
*/
#define FXAS21002_CTRL_REG3_FS_DOUBLE_ENABLE ((uint8_t) 0x01) /* Maximum full-scale range selections are doubled */
/* (4000, 2000, 1000, 500 dps). */
#define FXAS21002_CTRL_REG3_FS_DOUBLE_DISABLE ((uint8_t) 0x00) /* Maximum full-scale range selections are as per */
/* selectable full-scale ranges (2000, 1000, 500, */
/* 250 dps). */
#define FXAS21002_CTRL_REG3_EXTCTRLEN_INT2 ((uint8_t) 0x00) /* INT2 pin is used as an interrupt output */
/* (default). */
#define FXAS21002_CTRL_REG3_EXTCTRLEN_POWER_CONTROL ((uint8_t) 0x04) /* INT2 pin becomes an input pin that may be used */
/* to control the power mode. */
#define FXAS21002_CTRL_REG3_WRAPTOONE_ROLL_STATUS ((uint8_t) 0x00) /* The auto-increment read address pointer rolls */
/* over to address 0x00 (STATUS) after the Z-axis */
/* LSB is read (default). */
#define FXAS21002_CTRL_REG3_WRAPTOONE_ROLL_DATA ((uint8_t) 0x08) /* The auto-increment pointer rolls over to address */
/* 0x01 (X-axis MSB) in order to facilitate the */
/* faster read out of the FIFO data in a single */
/* burst read operation. */
/*------------------------------*/
#endif /* FXAS21002_H_ */