-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmma8451.h
1549 lines (1508 loc) · 37.6 KB
/
mma8451.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
/*
* libmma8451 - Library for controlling and reading from MMA8451 accelerometers.
* Copyright (C) 2017 Michael Powers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* This is the identifier the MMA8451 returns when asked for its MMA8451_REGISTER_WHO_AM_I
* register.
*/
#define MMA8451_ID 0x1A
/**
* Constant for acceleration due to gravity.
*/
#define GRAVITY_ACCEL 9.80665
/**
* The divider for gravity in 2G mode for 14-bit mode.
*/
#define RANGE_DIV_2G_14BIT (0x1000 / GRAVITY_ACCEL)
/**
* The divider for gravity in 4G mode for 14-bit mode.
*/
#define RANGE_DIV_4G_14BIT (0x800 / GRAVITY_ACCEL)
/**
* The divider for gravity in 8G mode for 14-bit mode.
*/
#define RANGE_DIV_8G_14BIT (0x400 / GRAVITY_ACCEL)
/**
* The divider for gravity in 2G mode for 8-bit mode.
*/
#define RANGE_DIV_2G_8BIT (0x40 / GRAVITY_ACCEL)
/**
* The divider for gravity in 4G mode for 8-bit mode.
*/
#define RANGE_DIV_4G_8BIT (0x20 / GRAVITY_ACCEL)
/**
* The divider for gravity in 8G mode for 8-bit mode.
*/
#define RANGE_DIV_8G_8BIT (0x10 / GRAVITY_ACCEL)
/**
* The maximum size of an error message returned by this library.
*/
#define MMA8451_ERROR_SIZE 500
/**
* The maximum value for a 14-bit signed sensor value.
*/
#define MAX_14BIT_SIGNED 0x4000
/**
* The maximum value for a 14-bit sensor value.
*/
#define MAX_14BIT_VALUE 0x1FFF
/**
* The maximum value for a 8-bit signed sensor value.
*/
#define MAX_8BIT_VALUE 0x7F
/**
* The maximum value for a 8-bit sensor value.
*/
#define MAX_8BIT_SIGNED 0xFF
/**
* This enumeration contains all of the different MMA8451 register ID's.
*/
typedef enum mma8451_register {
MMA8451_REGISTER_STATUS = 0x0,
MMA8451_REGISTER_F_STATUS = 0x0,
MMA8451_REGISTER_OUT_X_MSB = 0x1,
MMA8451_REGISTER_OUT_X_LSB = 0x2,
MMA8451_REGISTER_OUT_Y_MSB = 0x3,
MMA8451_REGISTER_OUT_Y_LSB = 0x4,
MMA8451_REGISTER_OUT_Z_MSB = 0x5,
MMA8451_REGISTER_OUT_Z_LSB = 0x6,
MMA8451_REGISTER_RESERVED_1 = 0x7,
MMA8451_REGISTER_RESERVED_2 = 0x8,
MMA8451_REGISTER_F_SETUP = 0x9,
MMA8451_REGISTER_TRIG_CFG = 0xA,
MMA8451_REGISTER_SYSMOD = 0xB,
MMA8451_REGISTER_INT_SOURCE = 0xC,
MMA8451_REGISTER_WHO_AM_I = 0xD,
MMA8451_REGISTER_XYZ_DATA_CFG = 0xE,
MMA8451_REGISTER_HP_FILTER_CUTOFF = 0xF,
MMA8451_REGISTER_PL_STATUS = 0x10,
MMA8451_REGISTER_PL_CFG = 0x11,
MMA8451_REGISTER_PL_COUNT = 0x12,
MMA8451_REGISTER_PL_BF_ZCOMP = 0x13,
MMA8451_REGISTER_P_L_THS_REG = 0x14,
MMA8451_REGISTER_FF_MT_CFG = 0x15,
MMA8451_REGISTER_FF_MT_SRC = 0x16,
MMA8451_REGISTER_FF_MT_THS = 0x17,
MMA8451_REGISTER_FF_MT_COUNT = 0x18,
MMA8451_REGISTER_RESERVED_3 = 0x19,
MMA8451_REGISTER_RESERVED_4 = 0x1A,
MMA8451_REGISTER_RESERVED_5 = 0x1B,
MMA8451_REGISTER_RESERVED_6 = 0x1C,
MMA8451_REGISTER_TRANSIENT_CFG = 0x1D,
MMA8451_REGISTER_TRANSIENT_SCR = 0x1E,
MMA8451_REGISTER_TRANSIENT_THS = 0x1F,
MMA8451_REGISTER_TRANSIENT_COUNT = 0x20,
MMA8451_REGISTER_PULSE_CFG = 0x21,
MMA8451_REGISTER_PULSE_SRC = 0x22,
MMA8451_REGISTER_PULSE_THSX = 0x23,
MMA8451_REGISTER_PULSE_THSY = 0x24,
MMA8451_REGISTER_PULSE_THSZ = 0x25,
MMA8451_REGISTER_PULSE_TMLT = 0x26,
MMA8451_REGISTER_PULSE_LTCY = 0x27,
MMA8451_REGISTER_PULSE_WIND = 0x28,
MMA8451_REGISTER_ASLP_COUNT = 0x29,
MMA8451_REGISTER_CTRL_REG1 = 0x2A,
MMA8451_REGISTER_CTRL_REG2 = 0x2B,
MMA8451_REGISTER_CTRL_REG3 = 0x2C,
MMA8451_REGISTER_CTRL_REG4 = 0x2D,
MMA8451_REGISTER_CTRL_REG5 = 0x2E,
MMA8451_REGISTER_OFF_X = 0x2F,
MMA8451_REGISTER_OFF_Y = 0x30,
MMA8451_REGISTER_OFF_Z = 0x31
} mma8451_register;
/**
* An enumeration containing the different supported FIFO modes.
*/
typedef enum mma8451_fifo_mode {
/**
* Disables the FIFO.
*/
MMA8451_FIFO_MODE_DISABLED = 0,
/**
* Enables the FIFO in ring buffer mode.
*/
MMA8451_FIFO_MODE_RING_BUFFER = 1,
/**
* Enables the FIFO, buffer stops when filled.
*/
MMA8451_FIFO_MODE_STOP_BUFFER = 2,
/**
* Enables the FIFO, triggers when the buffer fills past the high water mark.
*/
MMA8451_FIFO_MODE_TRIGGER = 3
} mma8451_fifo_mode;
/**
* An enumeration containing the supported system modes.
*/
typedef enum mma8451_system_mode {
/**
* Standby mode.
*/
MMA8451_SYSTEM_MODE_STANDBY = 0,
/**
* Wake mode.
*/
MMA8451_SYSTEM_MODE_WAKE = 1,
/**
* Sleep mode.
*/
MMA8451_SYSTEM_MODE_SLEEP = 2
} mma8451_system_mode;
/**
* An enumeration containing the supported acceleration scales.
*/
typedef enum mma8451_range_scale {
/**
* Range from -2g to 2g.
*/
MMA8451_RANGE_2G = 0,
/**
* Range from -4g to 4g.
*/
MMA8451_RANGE_4G = 1,
/**
* Range from -8g to 8g.
*/
MMA8451_RANGE_8G = 2,
/**
* Reserved for future use.
*/
MMA8451_RANGE_RESERVED = 3
} mma8451_range_scale;
/**
* An enumeration containing the supported bit scales.
*/
typedef enum mma8451_output_size {
/**
* Sensor values are returned in 8-bit sensor values.
*/
MMA8451_8BIT_OUTPUT = 1,
/**
* Sensor values are returned in 14-bit sensor values.
*/
MMA8451_14BIT_OUTPUT = 0
} mma8451_output_size;
/**
* An enumeration containing the supported sleep rates.
*/
typedef enum mma8451_aslp_rate {
/**
* Sleeping at 50hz.
*/
MMA8451_ASLP_RATE_50HZ = 0,
/**
* Sleeping at 12.5hz.
*/
MMA8451_ASLP_RATE_12_5HZ = 1,
/**
* Sleeping at 6.25hz.
*/
MMA8451_ASLP_RATE_6_25HZ = 2,
/**
* Sleeping at 1.56hz.
*/
MMA8451_ASLP_RATE_1_56HZ = 3,
} mma8451_aslp_rate;
/**
* An enumeration containing the supported data rates.
*/
typedef enum mma8451_data_rate {
/**
* Samples taken at 800hz.
*/
MMA8451_DATA_RATE_800HZ = 0,
/**
* Samples taken at 400hz.
*/
MMA8451_DATA_RATE_400HZ = 1,
/**
* Samples taken at 200hz.
*/
MMA8451_DATA_RATE_200HZ = 2,
/**
* Samples taken at 100hz.
*/
MMA8451_DATA_RATE_100HZ = 3,
/**
* Samples taken at 50hz.
*/
MMA8451_DATA_RATE_50HZ = 4,
/**
* Samples taken at 12.5hz.
*/
MMA8451_DATA_RATE_12_5HZ = 5,
/**
* Samples taken 6.25hz.
*/
MMA8451_DATA_RATE_6_25HZ = 6,
/**
* Samples taken at 1.56hz.
*/
MMA8451_DATA_RATE_1_56HZ = 7
} mma8451_data_rate;
/**
* An enumeration containing supported power modes.
*/
typedef enum mma8451_power_mode {
/**
* Normal high power mode.
*/
MMA8451_POWER_MODE_NORMAL = 0,
/**
* Low noise, low power mode.
*/
MMA8451_POWER_MODE_LNOISE_LPOWER = 1,
/**
* High resolution mode.
*/
MMA8451_POWER_MODE_HIGH_RES = 2,
/**
* Lower power mode.
*/
MMA8451_POWER_MODE_LOW_POWER = 3
} mma8451_power_mode;
/**
* This structure contains the bits for the STATUS register.
*/
typedef struct mma8451_register_status {
/**
* X, Y, and Z axis data overwrite.
* 0 - No data overwrite has occurred.
* 1 - Previous x, y, or z data was overwritten before it was read.
*/
unsigned char zyxow;
/**
* Z-axis data overwrite.
* 0 - No data overwrite has occurred.
* 1 - Previous Z-axis data was overwritten before it was read.
*/
unsigned char zow;
/**
* Y-axis data overwrite.
* 0 - No data overwrite has occurred.
* 1 - Previous Y-axis data was overwritten before it was read.
*/
unsigned char yow;
/**
* X-axis data overwrite.
* 0 - No data overwrite has occurred.
* 1 - Previous X-axis data was overwritten before it was read.
*/
unsigned char xow;
/**
* X, Y, or Z axis has new data ready.
* 0 - No new data available.
* 1 - New set of data is available.
*/
unsigned char zyxdr;
/**
* Z-axis daa has new data ready.
* 0 - No new data available.
* 1 - New set of data is availb
*/
unsigned char zdr;
/**
* Y-axis daa has new data ready.
* 0 - No new data available.
* 1 - New set of data is availb
*/
unsigned char ydr;
/**
* X-axis daa has new data ready.
* 0 - No new data available.
* 1 - New set of data is availb
*/
unsigned char xdr;
} mma8451_register_status;
/**
* This stucture contains the bits for the F_STATUS register.
*/
typedef struct mma8451_register_f_status {
/**
* Whether or not the FIFO has overflowed.
* 0 - No overflow
* 1 - Overflow detected.
*/
unsigned char f_ovf;
/**
* Whether or not a FIFO watermark event has occurred.
* 0 - No FIFO watermark event detected.
* 1 - Fifo watermark detected, sample count grater than watermark value.
*/
unsigned char f_wmrk_flag;
/**
* Bit 5 of the the FIFO sample counter.
*/
unsigned char f_cnt5;
/**
* Bit 4 of the the FIFO sample counter.
*/
unsigned char f_cnt4;
/**
* Bit 3 of the the FIFO sample counter.
*/
unsigned char f_cnt3;
/**
* Bit 2 of the the FIFO sample counter.
*/
unsigned char f_cnt2;
/**
* Bit 1 of the the FIFO sample counter.
*/
unsigned char f_cnt1;
/**
* Bit 0 of the the FIFO sample counter.
*/
unsigned char f_cnt0;
/**
* The FIFO sample counter, contains the number from f_cnt5 through f_cnt0.
*/
unsigned char f_cnt;
} mma8451_register_f_status;
/**
* This structure contains the bits for the F_SETUP register.
*/
typedef struct mma8451_register_f_setup {
/**
* Bit 1 of the f_mode flag.
*/
unsigned char f_mode1;
/**
* Bit 0 of the f_mode flag.
*/
unsigned char f_mode0;
/**
* Bit 5 of the f_wmrk counter.
*/
unsigned char f_wmrk5;
/**
* Bit 4 of the f_wmrk counter.
*/
unsigned char f_wmrk4;
/**
* Bit 3 of the f_wmrk counter.
*/
unsigned char f_wmrk3;
/**
* Bit 2 of the f_wmrk counter.
*/
unsigned char f_wmrk2;
/**
* Bit 1 of the f_wmrk counter.
*/
unsigned char f_wmrk1;
/**
* Bit 0 of the f_wmrk counter.
*/
unsigned char f_wmrk0;
/**
* The FIFO buffer overflow mode, the default is MMA8451_FIFO_MODE_DISABLED.
*/
mma8451_fifo_mode f_mode;
/**
* FIFO event sample count watermark. Sets the number of samples required to
* trigger an interrupt.
*/
unsigned char f_wmrk;
} mma8451_register_f_setup;
/**
* This structure contains the bits for the TRIG_CFG register.
*/
typedef struct mma8451_register_trig_cfg {
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Transient interrupt trigger bit.
*/
unsigned char trig_trans;
/**
* Landscape/portrait orientation interrupt trigger bit.
*/
unsigned char trig_lndprt;
/**
* Pulse interrupt trigger bit.
*/
unsigned char trig_pulse;
/**
* Freefall motion trigger bit.
*/
unsigned char trig_ff_mt;
/**
* Unused.
*/
unsigned char unused3;
/**
* Unused.
*/
unsigned char unused4;
} mma8451_register_trig_cfg;
/**
* This structure contains the bits for the SYSMOD register.
*/
typedef struct mma8451_register_sysmod {
/**
* FIFO Gate Error
* 0 - No FIFO Gate error
* 1 - FIFO gate error.
*/
unsigned char fgerr;
/**
* Bit 4 of fgt.
*/
unsigned char fgt_4;
/**
* Bit 3 of fgt.
*/
unsigned char fgt_3;
/**
* Bit 2 of fgt.
*/
unsigned char fgt_2;
/**
* Bit 1 of fgt.
*/
unsigned char fgt_1;
/**
* Bit 0 of fgt.
*/
unsigned char fgt_0;
/**
* Bit 1 of sysmod.
*/
unsigned char sysmod1;
/**
* Bit 0 of sysmod.
*/
unsigned char sysmod0;
/**
* Number of ODR time units since fgerr was asserted. Reset when cleared.
*/
unsigned char fgt;
/**
* System mode, defaults to STANDBY.
*/
mma8451_system_mode mode;
} mma8451_register_sysmod;
/**
* This structure contains the bits for the INT_SOURCE register.
*/
typedef struct mma8451_register_int_source {
/**
* Auto sleep/wake interrupt status bit.
*/
unsigned char src_aslp;
/**
* FIFO interrupt status bit.
*/
unsigned char src_fifo;
/**
* Transient interrupt status bit.
*/
unsigned char src_trans;
/**
* Landscape / portrait orientation interrupt status bit.
*/
unsigned char src_lndprt;
/**
* Pulse interrupt status bit.
*/
unsigned char src_pulse;
/**
* Freefall motion interrupt status bit.
*/
unsigned char src_ff_mt;
/**
* Unused.
*/
unsigned char unused;
/**
* Data read interrupt bit status.
*/
unsigned char src_drdy;
} mma8451_register_int_source;
/**
* This structure contains the bits for the XYZ_DATA_CFG register.
*/
typedef struct mma8451_register_xyz_data_cfg {
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Unused.
*/
unsigned char unused3;
/**
* Enable high pass filter.
*/
unsigned char hpf_out;
/**
* Unused.
*/
unsigned char unused4;
/**
* Unused.
*/
unsigned char unused5;
/**
* Bit 1 of the scale.
*/
unsigned char fs1;
/**
* Bit 0 of the scale.
*/
unsigned char fs0;
/**
* The range scale to use, 2G, 4G, or 8G.
*/
mma8451_range_scale fs;
} mma8451_register_xyz_data_cfg;
/**
* This structure contains the bits for the HP_FILTER_CUTOFF register.
*/
typedef struct mma8451_register_hp_filter_cutoff {
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Bypass high pass filter for pulse processing.
*/
unsigned char pulse_hpf_byp;
/**
* Enable low-pass filter for the pulse processing function.
*/
unsigned char pulse_lpf_en;
/**
* Unused.
*/
unsigned char unused3;
/**
* Unused.
*/
unsigned char unused4;
/**
* Bit 1 of the cutoff frequency selection
*/
unsigned char sel1;
/**
* Bit 0 of the cutoff frequency selection
*/
unsigned char sel0;
} mma8451_register_hp_filter_cutoff;
/**
* This structure contains the bits for the PL_STATUS register.
*/
typedef struct mma8451_register_pl_status {
/**
* Landscape / portrait status change flag.
*/
unsigned char newlp;
/**
* Z-tilt angle lockout
*/
unsigned char lo;
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Unused.
*/
unsigned char unused3;
/**
* Bit 1 of Landscape / portrait orientation.
*/
unsigned char lapo1;
/**
* Bit 0 of Landscape / portrait orientation.
*/
unsigned char lapo0;
/**
* Back or front orientation.
*/
unsigned char bafro;
} mma8451_register_pl_status;
/**
* This structure contains the bits for the PL_CFG register.
*/
typedef struct mma8451_register_pl_cfg {
/**
* Debounce counter mode selection
* 0 - Decrements debounce whenever condition of interest is no longer valid.
* 1 - Clears counter whenever condition of interest is no longer valid.
*/
unsigned char dbcntm;
/**
* Portrait/Landscape detection enable.
*/
unsigned char pl_en;
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Unused.
*/
unsigned char unused3;
/**
* Unused.
*/
unsigned char unused4;
/**
* Unused.
*/
unsigned char unused5;
/**
* Unused.
*/
unsigned char unused6;
} mma8451_register_pl_cfg;
/**
* This structure contains the bits for the PL_BF_ZCOMP register.
*/
typedef struct mma8451_register_pl_bf_zcomp {
/**
* Bit 1 of the back front trip angle.
*/
unsigned char bkfr1;
/**
* Bit 0 of the back front tip angle.
*/
unsigned char bkfr0;
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Unused.
*/
unsigned char unused3;
/**
* Bit 2 of the z-lock angle threshold.
*/
unsigned char zlock2;
/**
* Bit 1 of the z-lock angle threshold.
*/
unsigned char zlock1;
/**
* Bit 0 of the z-lock angle threshold.
*/
unsigned char zlock0;
/**
* Back front trip angle threshold. Default is 75 degrees (1). Step is 5 degrees.
*/
unsigned char bkfr;
/**
* Z-lock angle threshold. Range is from 14 degrees to 43 degrees. Step size is 4 degrees.
*/
unsigned char zlock;
} mma8451_register_pl_bf_zcomp;
/**
* This structure contains the bits for the P_L_THS_REG register.
*/
typedef struct mma8451_register_p_l_ths_reg {
/**
* Bit 4 of p_l_ths.
*/
unsigned char p_l_ths4;
/**
* Bit 3 of p_l_ths.
*/
unsigned char p_l_ths3;
/**
* Bit 2 of p_l_ths.
*/
unsigned char p_l_ths2;
/**
* Bit 1 of p_l_ths.
*/
unsigned char p_l_ths1;
/**
* Bit 0 of p_l_ths.
*/
unsigned char p_l_ths0;
/**
* Bit 2 of hys.
*/
unsigned char hys2;
/**
* Bit 1 of hys.
*/
unsigned char hys1;
/**
* Bit 0 of hys.
*/
unsigned char hys0;
/**
* Portrait / landscape trip threshold angle from 15 degrees to 75 degrees.
* Default is 45 degrees.
*/
unsigned char p_l_ths;
/**
* This angle is added to the threshold angle for a smoother transition from portrait
* to landscape and visa-versa. The angle ranges from 0 to +/- 24 degrees. Default is 100.
*/
unsigned char hys;
} mma8451_register_p_l_ths_reg;
/**
* This structure contains the bits for the FF_MT_CFG register.
*/
typedef struct mma8451_register_ff_mt_cfg {
/**
* Event latch enable.
*/
unsigned char ele;
/**
* Motion detect / freefall detect flag selection.
*/
unsigned char oae;
/**
* Event flag enable on z.
*/
unsigned char zefe;
/**
* Event flag enable on y.
*/
unsigned char yefe;
/**
* Event flag enable on x.
*/
unsigned char xefe;
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Unused.
*/
unsigned char unused3;
} mma8451_register_ff_mt_cfg;
/**
* This structure contains the bits for the FF_MT_SRC register.
*/
typedef struct mma8451_register_ff_mt_src {
/**
* Event active flag.
*/
unsigned char ea;
/**
* Unused.
*/
unsigned char unused1;
/**
* Z motion flag.
*/
unsigned char zhe;
/**
* Z motion polarity.
*/
unsigned char zhp;
/**
* Y motion flag.
*/
unsigned char yhe;
/**
* Y motion polarity.
*/
unsigned char yhp;
/**
* X motion flag.
*/
unsigned char xhe;
/**
* X motion polarity.
*/
unsigned char xhp;
} mma8451_register_ff_mt_src;
/**
* This structure contains the bits for the FF_MT_THS register.
*/
typedef struct mma8451_register_ff_mt_ths {
/**
* Debounce counter mode selection.
* 0 - Increments or decrements debounce.
* 1 - Increments or clears counter.
*/
unsigned char dbcntm;
/**
* Bit 6 of ths.
*/
unsigned char ths6;
/**
* Bit 5 of ths.
*/
unsigned char ths5;
/**
* Bit 4 of ths.
*/
unsigned char ths4;
/**
* Bit 3 of ths.
*/
unsigned char ths3;
/**
* Bit 2 of ths.
*/
unsigned char ths2;
/**
* Bit 1 of ths.
*/
unsigned char ths1;
/**
* Bit 0 of ths.
*/
unsigned char ths0;
/**
* Freefall motion threshold.
*/
unsigned char ths;
} mma8451_register_ff_mt_ths;
/**
* This structure contains the bits for the TRANSIENT_CFG register.
*/
typedef struct mma8451_register_transient_cfg {
/**
* Unused.
*/
unsigned char unused1;
/**
* Unused.
*/
unsigned char unused2;
/**
* Unused.
*/
unsigned char unused3;
/**
* Transient event flag.
*/
unsigned char ele;
/**
* Event flag enable on z.
*/
unsigned char ztefe;
/**
* Event flag enable on y.
*/
unsigned char ytefe;
/**
* Event flag enable on x.
*/
unsigned char xtefe;
/**
* Bypass high-pass filter.
*/
unsigned char hpf_byp;
} mma8451_register_transient_cfg;
/**
* This structure contains the bits for the TRANSIENT_SCR register.
*/
typedef struct mma8451_register_transient_scr {
/**
* Unused.
*/
unsigned char unused;
/**
* Event active flag.
*/
unsigned char ea;
/**
* Z transient event.
*/
unsigned char ztranse;
/**
* Polarity of the Z transient event that triggered interrupt.
*/
unsigned char z_trans_pol;
/**
* Y transient event.
*/
unsigned char ytranse;
/**
* Polarity of the Y transient event that triggered interrupt.
*/
unsigned char y_trans_pol;
/**
* X transient event.
*/