-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmpl3115.h
1184 lines (881 loc) · 45.1 KB
/
mpl3115.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) 2016, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MPL3115_H_
#define MPL3115_H_
/**
**
** MPL3115 Sensor Internal Registers
*/
enum {
MPL3115_STATUS = 0x00,
MPL3115_OUT_P_MSB = 0x01,
MPL3115_OUT_P_CSB = 0x02,
MPL3115_OUT_P_LSB = 0x03,
MPL3115_OUT_T_MSB = 0x04,
MPL3115_OUT_T_LSB = 0x05,
MPL3115_DR_STATUS = 0x06,
MPL3115_OUT_P_DELTA_MSB = 0x07,
MPL3115_OUT_P_DELTA_CSB = 0x08,
MPL3115_OUT_P_DELTA_LSB = 0x09,
MPL3115_OUT_T_DELTA_MSB = 0x0A,
MPL3115_OUT_T_DELTA_LSB = 0x0B,
MPL3115_WHO_AM_I = 0x0C,
MPL3115_F_STATUS = 0x0D,
MPL3115_F_DATA = 0x0E,
MPL3115_F_SETUP = 0x0F,
MPL3115_TIME_DLY = 0x10,
MPL3115_SYSMOD = 0x11,
MPL3115_INT_SOURCE = 0x12,
MPL3115_PT_DATA_CFG = 0x13,
MPL3115_BAR_IN_MSB = 0x14,
MPL3115_BAR_IN_LSB = 0x15,
MPL3115_P_TGT_MSB = 0x16,
MPL3115_P_TGT_LSB = 0x17,
MPL3115_T_TGT = 0x18,
MPL3115_P_WND_MSB = 0x19,
MPL3115_P_WND_LSB = 0x1A,
MPL3115_T_WND = 0x1B,
MPL3115_P_MIN_MSB = 0x1C,
MPL3115_P_MIN_CSB = 0x1D,
MPL3115_P_MIN_LSB = 0x1E,
MPL3115_T_MIN_MSB = 0x1F,
MPL3115_T_MIN_LSB = 0x20,
MPL3115_P_MAX_MSB = 0x21,
MPL3115_P_MAX_CSB = 0x22,
MPL3115_P_MAX_LSB = 0x23,
MPL3115_T_MAX_MSB = 0x24,
MPL3115_T_MAX_LSB = 0x25,
MPL3115_CTRL_REG1 = 0x26,
MPL3115_CTRL_REG2 = 0x27,
MPL3115_CTRL_REG3 = 0x28,
MPL3115_CTRL_REG4 = 0x29,
MPL3115_CTRL_REG5 = 0x2A,
MPL3115_OFF_P = 0x2B,
MPL3115_OFF_T = 0x2C,
MPL3115_OFF_H = 0x2D,
};
#define MPL3115_I2C_ADDRESS (0x60) /*MPL3115A2 Address*/
#define MPL3115_WHOAMI_VALUE (0xC4) /*!< Who AM I address. */
/*--------------------------------
** Register: STATUS
** Enum: MPL3115_STATUS
** --
** Offset : 0x00 - Alias for DR_STATUS or F_STATUS.
** ------------------------------*/
typedef uint8_t MPL3115_STATUS_t;
/*--------------------------------
** Register: OUT_P_MSB
** Enum: MPL3115_OUT_P_MSB
** --
** Offset : 0x01 - Bits 12-19 of 20-bit real-time Pressure sample.
** ------------------------------*/
typedef uint8_t MPL3115_OUT_P_MSB_t;
/*--------------------------------
** Register: OUT_P_CSB
** Enum: MPL3115_OUT_P_CSB
** --
** Offset : 0x02 - Bits 4-11 of 20-bit real-time Pressure sample.
** ------------------------------*/
typedef uint8_t MPL3115_OUT_P_CSB_t;
/*--------------------------------
** Register: OUT_P_LSB
** Enum: MPL3115_OUT_P_LSB
** --
** Offset : 0x03 - Bits 0-3 of 20-bit real-time Pressure sample.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t pd : 4; /* - 20-bit pressure sample measurement data bits 3:0 */
} b;
uint8_t w;
} MPL3115_OUT_P_LSB_t;
/*
** OUT_P_LSB - Bit field mask definitions
*/
#define MPL3115_OUT_P_LSB_PD_MASK ((uint8_t) 0xF0)
#define MPL3115_OUT_P_LSB_PD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: OUT_T_MSB
** Enum: MPL3115_OUT_T_MSB
** --
** Offset : 0x04 - Bits 4-11 of 12-bit real-time Temperature sample.
** ------------------------------*/
typedef uint8_t MPL3115_OUT_T_MSB_t;
/*--------------------------------
** Register: OUT_T_LSB
** Enum: MPL3115_OUT_T_LSB
** --
** Offset : 0x05 - Bits 0-3 of 12-bit real-time Temperature sample.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t pd : 4; /* - 12-bit temperature sample measurement data bits 3:0 */
} b;
uint8_t w;
} MPL3115_OUT_T_LSB_t;
/*
** OUT_T_LSB - Bit field mask definitions
*/
#define MPL3115_OUT_T_LSB_PD_MASK ((uint8_t) 0xF0)
#define MPL3115_OUT_T_LSB_PD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: DR_STATUS
** Enum: MPL3115_DR_STATUS
** --
** Offset : 0x06 - Data-ready status information
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 1;
uint8_t tdr : 1; /* Temperature new Data Available. */
uint8_t pdr : 1; /* Pressure/Altitude new data available. */
uint8_t ptdr : 1; /* Pressure/Altitude OR Temperature data ready. */
uint8_t _reserved_1 : 1;
uint8_t tow : 1; /* Temperature data overwrite. */
uint8_t pow : 1; /* Pressure/Altitude data overwrite. */
uint8_t ptow : 1; /* Pressure/Altitude OR Temperature data overwrite. */
} b;
uint8_t w;
} MPL3115_DR_STATUS_t;
/*
** DR_STATUS - Bit field mask definitions
*/
#define MPL3115_DR_STATUS_TDR_MASK ((uint8_t) 0x02)
#define MPL3115_DR_STATUS_TDR_SHIFT ((uint8_t) 1)
#define MPL3115_DR_STATUS_PDR_MASK ((uint8_t) 0x04)
#define MPL3115_DR_STATUS_PDR_SHIFT ((uint8_t) 2)
#define MPL3115_DR_STATUS_PTDR_MASK ((uint8_t) 0x08)
#define MPL3115_DR_STATUS_PTDR_SHIFT ((uint8_t) 3)
#define MPL3115_DR_STATUS_TOW_MASK ((uint8_t) 0x20)
#define MPL3115_DR_STATUS_TOW_SHIFT ((uint8_t) 5)
#define MPL3115_DR_STATUS_POW_MASK ((uint8_t) 0x40)
#define MPL3115_DR_STATUS_POW_SHIFT ((uint8_t) 6)
#define MPL3115_DR_STATUS_PTOW_MASK ((uint8_t) 0x80)
#define MPL3115_DR_STATUS_PTOW_SHIFT ((uint8_t) 7)
/*
** DR_STATUS - Bit field value definitions
*/
#define MPL3115_DR_STATUS_TDR_DRDY ((uint8_t) 0x02) /* Set to 1 whenever a Temperature data acquisition is */
/* completed. Cleared anytime OUT_T_MSB register is */
/* read, when F_MODE is zero */
#define MPL3115_DR_STATUS_PDR_DRDY ((uint8_t) 0x04) /* Set to 1 whenever a new Pressure/Altitude data */
/* acquisition is completed. Cleared anytime OUT_P_MSB */
/* register is read, when F_MODE is zero */
#define MPL3115_DR_STATUS_PTDR_DRDY ((uint8_t) 0x08) /* Signals that a new acquisition for either */
/* Pressure/Altitude or Temperature is available. */
/* Cleared anytime OUT_P_MSB or OUT_T_MSB register is */
/* read, when F_MODE is zero */
#define MPL3115_DR_STATUS_TOW_OWR ((uint8_t) 0x20) /* Set to 1 whenever a new Temperature acquisition is */
/* completed before the retrieval of the previous */
/* data. When this occurs the previous data is */
/* overwritten. Cleared anytime OUT_T_MSB register is */
/* read, when F_MODE is zero */
#define MPL3115_DR_STATUS_POW_OWR ((uint8_t) 0x40) /* Set to 1 whenever a new Pressure/Altitude */
/* acquisition is completed before the retrieval of */
/* the previous data. When this occurs the previous */
/* data is overwritten. POW is cleared anytime */
/* OUT_P_MSB register is read, when F_MODE is zero */
#define MPL3115_DR_STATUS_PTOW_OWR ((uint8_t) 0x80) /* Set to 1 whenever new data is acquired before */
/* completing the retrieval of the previous set. This */
/* event occurs when the content of at least one data */
/* register (i.e. OUT_P, OUT_T) has been overwritten. */
/* PTOW is cleared when the high-bytes of the data */
/* (OUT_P_MSB or OUT_T_MSB) are read, when F_MODE is */
/* zero */
/*------------------------------*/
/*--------------------------------
** Register: OUT_P_DELTA_MSB
** Enum: MPL3115_OUT_P_DELTA_MSB
** --
** Offset : 0x07 - Bits 12-19 of 20-bit Pressure change data.
** ------------------------------*/
typedef uint8_t MPL3115_OUT_P_DELTA_MSB_t;
/*--------------------------------
** Register: OUT_P_DELTA_CSB
** Enum: MPL3115_OUT_P_DELTA_CSB
** --
** Offset : 0x08 - Bits 4-11 of 20-bit Pressure change data.
** ------------------------------*/
typedef uint8_t MPL3115_OUT_P_DELTA_CSB_t;
/*--------------------------------
** Register: OUT_P_DELTA_LSB
** Enum: MPL3115_OUT_P_DELTA_LSB
** --
** Offset : 0x09 - Bits 0-3 of 20-bit Pressure change data.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t pcd : 4; /* - 20-bit pressure change measurement data bits 3:0 */
} b;
uint8_t w;
} MPL3115_OUT_P_DELTA_LSB_t;
/*
** OUT_P_DELTA_LSB - Bit field mask definitions
*/
#define MPL3115_OUT_P_DELTA_LSB_PCD_MASK ((uint8_t) 0xF0)
#define MPL3115_OUT_P_DELTA_LSB_PCD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: OUT_T_DELTA_MSB
** Enum: MPL3115_OUT_T_DELTA_MSB
** --
** Offset : 0x0A - Bits 4-11 of 12-bit Temperature change data.
** ------------------------------*/
typedef uint8_t MPL3115_OUT_T_DELTA_MSB_t;
/*--------------------------------
** Register: OUT_T_DELTA_LSB
** Enum: MPL3115_OUT_T_DELTA_LSB
** --
** Offset : 0x0B - Bits 0-3 of 12-bit Temperature change data.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t tcd : 4; /* - 12-bit temperature change measurement data bits 3:0 */
} b;
uint8_t w;
} MPL3115_OUT_T_DELTA_LSB_t;
/*
** OUT_T_DELTA_LSB - Bit field mask definitions
*/
#define MPL3115_OUT_T_DELTA_LSB_TCD_MASK ((uint8_t) 0xF0)
#define MPL3115_OUT_T_DELTA_LSB_TCD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: WHO_AM_I
** Enum: MPL3115_WHO_AM_I
** --
** Offset : 0x0C - Fixed Device ID Number.
** ------------------------------*/
typedef uint8_t MPL3115_WHO_AM_I_t;
/*--------------------------------
** Register: F_STATUS
** Enum: MPL3115_F_STATUS
** --
** Offset : 0x0D - FIFO Status: No FIFO event detected.
** ------------------------------*/
typedef union {
struct {
uint8_t f_cnt : 6; /* FIFO sample counter. F_CNT[5:0] bits indicate the number of samples */
/* currently stored in the FIFO buffer */
uint8_t f_wmkf_flag : 1; /* FIFO Watermark event */
uint8_t f_ovf : 1; /* FIFO overflow event. */
} b;
uint8_t w;
} MPL3115_F_STATUS_t;
/*
** F_STATUS - Bit field mask definitions
*/
#define MPL3115_F_STATUS_F_CNT_MASK ((uint8_t) 0x3F)
#define MPL3115_F_STATUS_F_CNT_SHIFT ((uint8_t) 0)
#define MPL3115_F_STATUS_F_WMKF_FLAG_MASK ((uint8_t) 0x40)
#define MPL3115_F_STATUS_F_WMKF_FLAG_SHIFT ((uint8_t) 6)
#define MPL3115_F_STATUS_F_OVF_MASK ((uint8_t) 0x80)
#define MPL3115_F_STATUS_F_OVF_SHIFT ((uint8_t) 7)
/*
** F_STATUS - Bit field value definitions
*/
#define MPL3115_F_STATUS_F_WMKF_FLAG_NOEVT ((uint8_t) 0x00) /* No FIFO watermark event detected. */
#define MPL3115_F_STATUS_F_WMKF_FLAG_EVTDET ((uint8_t) 0x40) /* FIFO Watermark event has been detected. */
#define MPL3115_F_STATUS_F_OVF_NOOVFL ((uint8_t) 0x00) /* No FIFO overflow events detected. */
#define MPL3115_F_STATUS_F_OVF_OVFLDET ((uint8_t) 0x80) /* FIFO Overflow event has been detected. */
/*------------------------------*/
/*--------------------------------
** Register: F_DATA
** Enum: MPL3115_F_DATA
** --
** Offset : 0x0E - FIFO 8-bit data access.
** ------------------------------*/
typedef uint8_t MPL3115_F_DATA_t;
/*--------------------------------
** Register: F_SETUP
** Enum: MPL3115_F_SETUP
** --
** Offset : 0x0F - FIFO setup.
** ------------------------------*/
typedef union {
struct {
uint8_t f_wmrk : 6; /* FIFO Event Sample Count Watermark. */
uint8_t f_mode : 2; /* FIFO buffer overflow mode. */
} b;
uint8_t w;
} MPL3115_F_SETUP_t;
/*
** F_SETUP - Bit field mask definitions
*/
#define MPL3115_F_SETUP_F_WMRK_MASK ((uint8_t) 0x3F)
#define MPL3115_F_SETUP_F_WMRK_SHIFT ((uint8_t) 0)
#define MPL3115_F_SETUP_F_MODE_MASK ((uint8_t) 0xC0)
#define MPL3115_F_SETUP_F_MODE_SHIFT ((uint8_t) 6)
/*
** F_SETUP - Bit field value definitions
*/
#define MPL3115_F_SETUP_F_MODE_FIFO_OFF ((uint8_t) 0x00) /* FIFO is disabled. */
#define MPL3115_F_SETUP_F_MODE_CIR_MODE ((uint8_t) 0x40) /* FIFO contains the most recent samples when overflowed */
/* (circular buffer). */
#define MPL3115_F_SETUP_F_MODE_STOP_MODE ((uint8_t) 0x80) /* FIFO stops accepting new samples when overflowed. */
/*------------------------------*/
/*--------------------------------
** Register: TIME_DLY
** Enum: MPL3115_TIME_DLY
** --
** Offset : 0x10 - Time since FIFO overflow.
** ------------------------------*/
typedef uint8_t MPL3115_TIME_DLY_t;
/*--------------------------------
** Register: SYSMOD
** Enum: MPL3115_SYSMOD
** --
** Offset : 0x11 - Current system mode.
** ------------------------------*/
typedef union {
struct {
uint8_t sysmod : 1; /* - System mode data bit 0. (Bits 7-1 are reserved, will always read 0.) */
} b;
uint8_t w;
} MPL3115_SYSMOD_t;
/*
** SYSMOD - Bit field mask definitions
*/
#define MPL3115_SYSMOD_SYSMOD_MASK ((uint8_t) 0x01)
#define MPL3115_SYSMOD_SYSMOD_SHIFT ((uint8_t) 0)
/*
** SYSMOD - Bit field value definitions
*/
#define MPL3115_SYSMOD_SYSMOD_STANDBY ((uint8_t) 0x00) /* STANDBY Mode. */
#define MPL3115_SYSMOD_SYSMOD_ACTIVE ((uint8_t) 0x01) /* ACTIVE Mode. */
/*------------------------------*/
/*--------------------------------
** Register: INT_SOURCE
** Enum: MPL3115_INT_SOURCE
** --
** Offset : 0x12 - Interrupt status. The bits that are set (logic 1) indicate which function has asserted its interrupt and conversely, bits that are cleared (logic 0) indicate which function has not asserted its interrupt.
** ------------------------------*/
typedef union {
struct {
uint8_t src_tchg : 1; /* Delta T interrupt status bit. */
uint8_t src_pchg : 1; /* Delta P interrupt status bit. */
uint8_t src_tth : 1; /* Temperature threshold interrupt. */
uint8_t src_pth : 1; /* Altitude/Pressure threshold interrupt. */
uint8_t src_tw : 1; /* Temperature alerter status bit near or equal to target temperature. */
uint8_t src_pw : 1; /* Altitude/Pressure alerter status bit near or equal to target */
/* Pressure/Altitude. */
uint8_t src_fifo : 1; /* FIFO interrupt status bit. */
uint8_t src_drdy : 1; /* Data ready interrupt status bit. */
} b;
uint8_t w;
} MPL3115_INT_SOURCE_t;
/*
** INT_SOURCE - Bit field mask definitions
*/
#define MPL3115_INT_SOURCE_SRC_TCHG_MASK ((uint8_t) 0x01)
#define MPL3115_INT_SOURCE_SRC_TCHG_SHIFT ((uint8_t) 0)
#define MPL3115_INT_SOURCE_SRC_PCHG_MASK ((uint8_t) 0x02)
#define MPL3115_INT_SOURCE_SRC_PCHG_SHIFT ((uint8_t) 1)
#define MPL3115_INT_SOURCE_SRC_TTH_MASK ((uint8_t) 0x04)
#define MPL3115_INT_SOURCE_SRC_TTH_SHIFT ((uint8_t) 2)
#define MPL3115_INT_SOURCE_SRC_PTH_MASK ((uint8_t) 0x08)
#define MPL3115_INT_SOURCE_SRC_PTH_SHIFT ((uint8_t) 3)
#define MPL3115_INT_SOURCE_SRC_TW_MASK ((uint8_t) 0x10)
#define MPL3115_INT_SOURCE_SRC_TW_SHIFT ((uint8_t) 4)
#define MPL3115_INT_SOURCE_SRC_PW_MASK ((uint8_t) 0x20)
#define MPL3115_INT_SOURCE_SRC_PW_SHIFT ((uint8_t) 5)
#define MPL3115_INT_SOURCE_SRC_FIFO_MASK ((uint8_t) 0x40)
#define MPL3115_INT_SOURCE_SRC_FIFO_SHIFT ((uint8_t) 6)
#define MPL3115_INT_SOURCE_SRC_DRDY_MASK ((uint8_t) 0x80)
#define MPL3115_INT_SOURCE_SRC_DRDY_SHIFT ((uint8_t) 7)
/*------------------------------*/
/*--------------------------------
** Register: PT_DATA_CFG
** Enum: MPL3115_PT_DATA_CFG
** --
** Offset : 0x13 - Data event flag configuration.
** ------------------------------*/
typedef union {
struct {
uint8_t tdefe : 1; /* Data event flag enable on new Temperature data. */
uint8_t pdefe : 1; /* Data event flag enable on new Pressure/Altitude data. */
uint8_t drem : 1; /* Data ready event mode. */
} b;
uint8_t w;
} MPL3115_PT_DATA_CFG_t;
/*
** PT_DATA_CFG - Bit field mask definitions
*/
#define MPL3115_PT_DATA_CFG_TDEFE_MASK ((uint8_t) 0x01)
#define MPL3115_PT_DATA_CFG_TDEFE_SHIFT ((uint8_t) 0)
#define MPL3115_PT_DATA_CFG_PDEFE_MASK ((uint8_t) 0x02)
#define MPL3115_PT_DATA_CFG_PDEFE_SHIFT ((uint8_t) 1)
#define MPL3115_PT_DATA_CFG_DREM_MASK ((uint8_t) 0x04)
#define MPL3115_PT_DATA_CFG_DREM_SHIFT ((uint8_t) 2)
/*
** PT_DATA_CFG - Bit field value definitions
*/
#define MPL3115_PT_DATA_CFG_TDEFE_DISABLED ((uint8_t) 0x00) /* Event detection disabled. */
#define MPL3115_PT_DATA_CFG_TDEFE_ENABLED ((uint8_t) 0x01) /* Event detection enabled. Raise event flag on new */
/* Temperature data. */
#define MPL3115_PT_DATA_CFG_PDEFE_DISABLED ((uint8_t) 0x00) /* Event detection disabled. */
#define MPL3115_PT_DATA_CFG_PDEFE_ENABLED ((uint8_t) 0x02) /* Event detection enabled. Raise event flag on new */
/* Pressure/Altitude data. */
#define MPL3115_PT_DATA_CFG_DREM_DISABLED ((uint8_t) 0x00) /* Event detection disabled. */
#define MPL3115_PT_DATA_CFG_DREM_ENABLED ((uint8_t) 0x04) /* Event detection enabled. Generate data ready */
/* event flag on new Pressure/Altitude or */
/* Temperature data. */
/*------------------------------*/
/*--------------------------------
** Register: BAR_IN_MSB
** Enum: MPL3115_BAR_IN_MSB
** --
** Offset : 0x14 - Bits 8-15 of Barometric input for Altitude calculation.
** ------------------------------*/
typedef uint8_t MPL3115_BAR_IN_MSB_t;
/*--------------------------------
** Register: BAR_IN_LSB
** Enum: MPL3115_BAR_IN_LSB
** --
** Offset : 0x15 - Bits 0-7 of Barometric input for Altitude calculation.
** ------------------------------*/
typedef uint8_t MPL3115_BAR_IN_LSB_t;
/*--------------------------------
** Register: P_TGT_MSB
** Enum: MPL3115_P_TGT_MSB
** --
** Offset : 0x16 - Bits 8-15 of Pressure/Altitude target value.
** ------------------------------*/
typedef uint8_t MPL3115_P_TGT_MSB_t;
/*--------------------------------
** Register: P_TGT_LSB
** Enum: MPL3115_P_TGT_LSB
** --
** Offset : 0x17 - Bits 0-7 of Pressure/Altitude target value.
** ------------------------------*/
typedef uint8_t MPL3115_P_TGT_LSB_t;
/*--------------------------------
** Register: T_TGT
** Enum: MPL3115_T_TGT
** --
** Offset : 0x18 - Temperature target value.
** ------------------------------*/
typedef uint8_t MPL3115_T_TGT_t;
/*--------------------------------
** Register: P_WND_MSB
** Enum: MPL3115_P_WND_MSB
** --
** Offset : 0x19 - Bits 8-15 of Pressure/Altitude window value.
** ------------------------------*/
typedef uint8_t MPL3115_P_WND_MSB_t;
/*--------------------------------
** Register: P_WND_LSB
** Enum: MPL3115_P_WND_LSB
** --
** Offset : 0x1A - Bits 0-7 of Pressure/Altitude window value.
** ------------------------------*/
typedef uint8_t MPL3115_P_WND_LSB_t;
/*--------------------------------
** Register: T_WND
** Enum: MPL3115_T_WND
** --
** Offset : 0x1B - Temperature window value.
** ------------------------------*/
typedef uint8_t MPL3115_T_WND_t;
/*--------------------------------
** Register: P_MIN_MSB
** Enum: MPL3115_P_MIN_MSB
** --
** Offset : 0x1C - Bits 12-19 of 20-bit Minimum Pressure/Altitude data.
** ------------------------------*/
typedef uint8_t MPL3115_P_MIN_MSB_t;
/*--------------------------------
** Register: P_MIN_CSB
** Enum: MPL3115_P_MIN_CSB
** --
** Offset : 0x1D - Bits 4-11 of 20-bit Minimum Pressure/Altitude data.
** ------------------------------*/
typedef uint8_t MPL3115_P_MIN_CSB_t;
/*--------------------------------
** Register: P_MIN_LSB
** Enum: MPL3115_P_MIN_LSB
** --
** Offset : 0x1E - Bits 0-3 of 20-bit Minimum Pressure/Altitude data.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t minpad : 4; /* - 20-bit Minimum Pressure/Altitude data bits 3:0. */
} b;
uint8_t w;
} MPL3115_P_MIN_LSB_t;
/*
** P_MIN_LSB - Bit field mask definitions
*/
#define MPL3115_P_MIN_LSB_MINPAD_MASK ((uint8_t) 0xF0)
#define MPL3115_P_MIN_LSB_MINPAD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: T_MIN_MSB
** Enum: MPL3115_T_MIN_MSB
** --
** Offset : 0x1F - Bits 4-11 of 12-bit Minimum Temperature data.
** ------------------------------*/
typedef uint8_t MPL3115_T_MIN_MSB_t;
/*--------------------------------
** Register: T_MIN_LSB
** Enum: MPL3115_T_MIN_LSB
** --
** Offset : 0x20 - Bits 0-3 of 12-bit Minimum Temperature data.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t mintd : 4; /* - 12-bit Minimum Temperature data bits 3:0. */
} b;
uint8_t w;
} MPL3115_T_MIN_LSB_t;
/*
** T_MIN_LSB - Bit field mask definitions
*/
#define MPL3115_T_MIN_LSB_MINTD_MASK ((uint8_t) 0xF0)
#define MPL3115_T_MIN_LSB_MINTD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: P_MAX_MSB
** Enum: MPL3115_P_MAX_MSB
** --
** Offset : 0x21 - Bits 12-19 of 20-bit Maximum Pressure/Altitude data.
** ------------------------------*/
typedef uint8_t MPL3115_P_MAX_MSB_t;
/*--------------------------------
** Register: P_MAX_CSB
** Enum: MPL3115_P_MAX_CSB
** --
** Offset : 0x22 - Bits 4-11 of 20-bit Maximum Pressure/Altitude data.
** ------------------------------*/
typedef uint8_t MPL3115_P_MAX_CSB_t;
/*--------------------------------
** Register: P_MAX_LSB
** Enum: MPL3115_P_MAX_LSB
** --
** Offset : 0x23 - Bits 0-3 of 20-bit Maximum Pressure/Altitude data.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t maxpad : 4; /* - 20-bit Maximum Pressure/Altitude data bits 3:0. */
} b;
uint8_t w;
} MPL3115_P_MAX_LSB_t;
/*
** P_MAX_LSB - Bit field mask definitions
*/
#define MPL3115_P_MAX_LSB_MAXPAD_MASK ((uint8_t) 0xF0)
#define MPL3115_P_MAX_LSB_MAXPAD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: T_MAX_MSB
** Enum: MPL3115_T_MAX_MSB
** --
** Offset : 0x24 - Bits 4-11 of 12-bit Maximum Temperature data.
** ------------------------------*/
typedef uint8_t MPL3115_T_MAX_MSB_t;
/*--------------------------------
** Register: T_MAX_LSB
** Enum: MPL3115_T_MAX_LSB
** --
** Offset : 0x25 - Bits 0-3 of 12-bit Maximum Temperature data.
** ------------------------------*/
typedef union {
struct {
uint8_t _reserved_ : 4;
uint8_t maxtd : 4; /* - 12-bit Maximum Temperature data bits 3:0. */
} b;
uint8_t w;
} MPL3115_T_MAX_LSB_t;
/*
** T_MAX_LSB - Bit field mask definitions
*/
#define MPL3115_T_MAX_LSB_MAXTD_MASK ((uint8_t) 0xF0)
#define MPL3115_T_MAX_LSB_MAXTD_SHIFT ((uint8_t) 4)
/*------------------------------*/
/*--------------------------------
** Register: CTRL_REG1
** Enum: MPL3115_CTRL_REG1
** --
** Offset : 0x26 - Control Register 1: Modes, Oversampling.
** ------------------------------*/
typedef union {
struct {
uint8_t sbyb : 1; /* Operation Mode. */
uint8_t ost : 1; /* OST bit to initiate a measurement immediately, If the SBYB bit is set to */
/* active. */
uint8_t rst : 1; /* Software Reset. This bit is used to activate the software reset. */
uint8_t os : 3; /* Oversample Ratio. These bits select the oversampling ratio. */
uint8_t raw : 1; /* RAW output mode. RAW bit will output ADC data with no post processing, */
/* except for oversampling. */
uint8_t alt : 1; /* Altimeter-Barometer mode. */
} b;
uint8_t w;
} MPL3115_CTRL_REG1_t;
/*
** CTRL_REG1 - Bit field mask definitions
*/
#define MPL3115_CTRL_REG1_SBYB_MASK ((uint8_t) 0x01)
#define MPL3115_CTRL_REG1_SBYB_SHIFT ((uint8_t) 0)
#define MPL3115_CTRL_REG1_OST_MASK ((uint8_t) 0x02)
#define MPL3115_CTRL_REG1_OST_SHIFT ((uint8_t) 1)
#define MPL3115_CTRL_REG1_RST_MASK ((uint8_t) 0x04)
#define MPL3115_CTRL_REG1_RST_SHIFT ((uint8_t) 2)
#define MPL3115_CTRL_REG1_OS_MASK ((uint8_t) 0x38)
#define MPL3115_CTRL_REG1_OS_SHIFT ((uint8_t) 3)
#define MPL3115_CTRL_REG1_RAW_MASK ((uint8_t) 0x40)
#define MPL3115_CTRL_REG1_RAW_SHIFT ((uint8_t) 6)
#define MPL3115_CTRL_REG1_ALT_MASK ((uint8_t) 0x80)
#define MPL3115_CTRL_REG1_ALT_SHIFT ((uint8_t) 7)
/*
** CTRL_REG1 - Bit field value definitions
*/
#define MPL3115_CTRL_REG1_SBYB_STANDBY ((uint8_t) 0x00) /* Standby Mode. */
#define MPL3115_CTRL_REG1_SBYB_ACTIVE ((uint8_t) 0x01) /* Active Mode. */
#define MPL3115_CTRL_REG1_OST_RESET ((uint8_t) 0x00) /* Reset OST Bit. */
#define MPL3115_CTRL_REG1_OST_SET ((uint8_t) 0x02) /* SET OST Bit. */
#define MPL3115_CTRL_REG1_RST_DIS ((uint8_t) 0x00) /* Device reset disabled. */
#define MPL3115_CTRL_REG1_RST_EN ((uint8_t) 0x04) /* Device reset enabled. */
#define MPL3115_CTRL_REG1_OS_OSR_1 ((uint8_t) 0x00) /* OSR = 1 and Minimum Time Between Data Samples 6 ms */
#define MPL3115_CTRL_REG1_OS_OSR_2 ((uint8_t) 0x08) /* OSR = 2 and Minimum Time Between Data Samples 10 ms */
#define MPL3115_CTRL_REG1_OS_OSR_4 ((uint8_t) 0x10) /* OSR = 4 and Minimum Time Between Data Samples 18 ms */
#define MPL3115_CTRL_REG1_OS_OSR_8 ((uint8_t) 0x18) /* OSR = 8 and Minimum Time Between Data Samples 34 ms */
#define MPL3115_CTRL_REG1_OS_OSR_16 ((uint8_t) 0x20) /* OSR = 16 and Minimum Time Between Data Samples 66 */
/* ms */
#define MPL3115_CTRL_REG1_OS_OSR_32 ((uint8_t) 0x28) /* OSR = 32 and Minimum Time Between Data Samples 130 */
/* ms */
#define MPL3115_CTRL_REG1_OS_OSR_64 ((uint8_t) 0x30) /* OSR = 64 and Minimum Time Between Data Samples 258 */
/* ms */
#define MPL3115_CTRL_REG1_OS_OSR_128 ((uint8_t) 0x38) /* OSR = 128 and Minimum Time Between Data Samples 512 */
/* ms */
#define MPL3115_CTRL_REG1_RAW_DIS ((uint8_t) 0x00) /* Raw output disabled. */
#define MPL3115_CTRL_REG1_RAW_EN ((uint8_t) 0x40) /* Raw output enabled. */
#define MPL3115_CTRL_REG1_ALT_ALT ((uint8_t) 0x80) /* Altimeter Mode. */
#define MPL3115_CTRL_REG1_ALT_BAR ((uint8_t) 0x00) /* Barometer Mode. */
/*------------------------------*/
/*--------------------------------
** Register: CTRL_REG2
** Enum: MPL3115_CTRL_REG2
** --
** Offset : 0x27 - Control Register 2: Acquisition time step.
** ------------------------------*/
typedef union {
struct {
uint8_t st : 4; /* Auto acquisition time step.. */
uint8_t alarm_sel : 1; /* The bit selects the Target value for SRC_PW/SRC_TW and SRC_PTH/SRC_TTH. */
uint8_t load_output : 1; /* This is to load the target values for SRC_PW/SRC_TW and SRC_PTH/SRC_TTH. */
} b;
uint8_t w;
} MPL3115_CTRL_REG2_t;
/*
** CTRL_REG2 - Bit field mask definitions
*/
#define MPL3115_CTRL_REG2_ST_MASK ((uint8_t) 0x0F)
#define MPL3115_CTRL_REG2_ST_SHIFT ((uint8_t) 0)
#define MPL3115_CTRL_REG2_ALARM_SEL_MASK ((uint8_t) 0x10)
#define MPL3115_CTRL_REG2_ALARM_SEL_SHIFT ((uint8_t) 4)
#define MPL3115_CTRL_REG2_LOAD_OUTPUT_MASK ((uint8_t) 0x20)
#define MPL3115_CTRL_REG2_LOAD_OUTPUT_SHIFT ((uint8_t) 5)
/*
** CTRL_REG2 - Bit field value definitions
*/
#define MPL3115_CTRL_REG2_ALARM_SEL_USE_TGT ((uint8_t) 0x00) /* The values in P_TGT_MSB, P_TGT_LSB and T_TGT are */
/* used. */
#define MPL3115_CTRL_REG2_ALARM_SEL_USE_OUT ((uint8_t) 0x10) /* The values in OUT_P/OUT_T are used for calculating */
/* the interrupts SRC_PW/SRC_TW and SRC_PTH/SRC_TTH. */
#define MPL3115_CTRL_REG2_LOAD_OUTPUT_DNL ((uint8_t) 0x00) /* Do not load OUT_P/OUT_T as target values. */
#define MPL3115_CTRL_REG2_LOAD_OUTPUT_NXT_VAL ((uint8_t) 0x20) /* The next values of OUT_P/OUT_T are used to set the */
/* target values for the interrupts. */
/*------------------------------*/
/*--------------------------------
** Register: CTRL_REG3
** Enum: MPL3115_CTRL_REG3
** --
** Offset : 0x28 - Control Register 3: Interrupt pin configuration.
** ------------------------------*/
typedef union {
struct {
uint8_t pp_od2 : 1; /* This bit configures the interrupt pad INT2 to Push-Pull or in Open Drain */
/* mode. */
uint8_t ipol2 : 1; /* Interrupt Polarity active high, or active low on interrupt pad INT2. */
uint8_t _reserved_ : 2;
uint8_t pp_od1 : 1; /* This bit configures the interrupt pad INT1 to Push-Pull or in Open Drain */
/* mode. */
uint8_t ipol1 : 1; /* Interrupt Polarity active high, or active low on interrupt pad INT1. */
} b;
uint8_t w;
} MPL3115_CTRL_REG3_t;
/*
** CTRL_REG3 - Bit field mask definitions
*/
#define MPL3115_CTRL_REG3_PP_OD2_MASK ((uint8_t) 0x01)
#define MPL3115_CTRL_REG3_PP_OD2_SHIFT ((uint8_t) 0)
#define MPL3115_CTRL_REG3_IPOL2_MASK ((uint8_t) 0x02)
#define MPL3115_CTRL_REG3_IPOL2_SHIFT ((uint8_t) 1)
#define MPL3115_CTRL_REG3_PP_OD1_MASK ((uint8_t) 0x10)
#define MPL3115_CTRL_REG3_PP_OD1_SHIFT ((uint8_t) 4)
#define MPL3115_CTRL_REG3_IPOL1_MASK ((uint8_t) 0x20)
#define MPL3115_CTRL_REG3_IPOL1_SHIFT ((uint8_t) 5)
/*
** CTRL_REG3 - Bit field value definitions
*/
#define MPL3115_CTRL_REG3_PP_OD2_INTPULLUP ((uint8_t) 0x00) /* Internal Pull-up. */
#define MPL3115_CTRL_REG3_PP_OD2_OPENDRAIN ((uint8_t) 0x01) /* Open drain. */
#define MPL3115_CTRL_REG3_IPOL2_LOW ((uint8_t) 0x00) /* Active low. */
#define MPL3115_CTRL_REG3_IPOL2_HIGH ((uint8_t) 0x02) /* Active high. */
#define MPL3115_CTRL_REG3_PP_OD1_INTPULLUP ((uint8_t) 0x00) /* Internal Pull-up. */
#define MPL3115_CTRL_REG3_PP_OD1_OPENDRAIN ((uint8_t) 0x10) /* Open drain. */
#define MPL3115_CTRL_REG3_IPOL1_LOW ((uint8_t) 0x00) /* Active low. */
#define MPL3115_CTRL_REG3_IPOL1_HIGH ((uint8_t) 0x20) /* Active high. */
/*------------------------------*/
/*--------------------------------
** Register: CTRL_REG4
** Enum: MPL3115_CTRL_REG4
** --
** Offset : 0x29 - Control Register 4: Interrupt enables.
** ------------------------------*/