MRAS
Multi Rocket Avionics System
Loading...
Searching...
No Matches
ADXL375_constants.h
1#ifndef ARDUINO_ADXL375_ADXL375_CONSTANTS_H
2#define ARDUINO_ADXL375_ADXL375_CONSTANTS_H
3
4
5/* Datasheet: 5.1.2, pg. 37
6 bit 0: RW bit. When 0, the data DI(7:0) is written into the device. When 1, the data DO(7:0) from the
7 device is read. In latter case, the chip will drive SDO at the start of bit 8.
8*/
9#define ADXL375_WRITE_BYTE 0b01000000
10#define ADXL375_READ_BYTE 0b11000000
11
12#define ADXL375_DEFAULT_I2C_ADDRESS 0x1D // When the ALT ADDRESS pin (Pin 12) is tied high to VDD I/O, the 7-bit I2C address for the device
13
14enum DEVID{
15 ADXL375_Fixed_Device_ID_Code = 0xE5
16};
17
18
19//enum ADXL375_POWER_MODES {
20// LOW_POWER_MODE,
21// AUTOSLEEP_MODE,
22// STANDBY_MODE,
23//};
24
25
26enum ADXL375_BATCHING_DATA_RATE{
27
28 ADXL375_BDR_3200_HZ = 0b1111,
29 ADXL375_BDR_1600_HZ = 0b1110,
30 ADXL375_BDR_800_HZ = 0b1101,
31 ADXL375_BDR_6_25HZ = 0b0110,
32 ADXL375_BDR_3_13_HZ = 0b0101,
33 ADXL375_BDR_1_56_HZ = 0b0100,
34 ADXL375_BDR_0_78_HZ = 0b0011,
35 ADXL375_BDR_0_39_HZ = 0b0010,
36 ADXL375_BDR_0_20_HZ = 0b0001,
37 ADXL375_NO_BATCHING = 0b0000
38};
39
40enum ADXL375_Low_power_BDR{
41 ADXL375_BDR_400_HZ = 0b1100,
42 ADXL375_BDR_100_HZ = 0b1010,
43 ADXL375_BDR_50_HZ = 0b1001,
44 ADXL375_BDR_25_HZ = 0b1100,
45 ADXL375_BDR_12_5_HZ = 0b0111,
46};
47
48enum ADXL375_FIFO_MODES { //30 samples collected in each fifo mode except bypass. Bit D5 = 0 links the trigger event of trigger mode to the INT1 pin
49
50
51 ADXL375_BYPASS_MODE = 0b00000000,
52 //In bypass mode, the FIFO buffer is not operational and, therefore, remains empty.
53
54 ADXL375_FIFO_MODE = 0b01111010,
55
56 //In FIFO mode, data from measurements of the x-, y-, and z-axes
57 // is stored in the FIFO buffer. When the number of samples in the
58 // FIFO buffer equals the level specified by the samples bits of the
59 // FIFO_CTL register (Address 0x38), the watermark interrupt is
60 // set (see the Watermark Bit section). The FIFO buffer continues
61 // to accumulate samples until it is full (32 samples from measurements of the x-, y-, and z-axes) and then stops collecting data.
62 // After the FIFO buffer stops collecting data, the device continues
63 // to operate; therefore, features such as shock detection can be used
64 // after the FIFO buffer is full. The watermark interrupt bit remains
65 // set until the number of samples in the FIFO buffer is less than
66 // the value stored in the samples bits of the FIFO_CTL register.
67
68 ADXL375_STREAM_MODE = 0b01111001,
69
70 // In stream mode, data from measurements of the x-, y-, and z-axes
71 // is stored in the FIFO buffer. When the number of samples in the
72 // FIFO buffer equals the level specified by the samples bits of the
73 // FIFO_CTL register (Address 0x38), the watermark interrupt is set
74 // (see the Watermark Bit section). The FIFO buffer continues to
75 // accumulate samples; the buffer stores the latest 32 samples from
76 // measurements of the x-, y-, and z-axes, discarding older data as
77 // new data arrives. The watermark interrupt bit remains set until
78 // the number of samples in the FIFO buffer is less than the value
79 // stored in the samples bits of the FIFO_CTL register
80
81 ADXL375_TRIGGER_MODE = 0b01111011,
82
83 // In trigger mode, the FIFO buffer accumulates samples, storing
84 // the latest 32 samples from measurements of the x-, y-, and z-axes.
85 // After a trigger event occurs, an interrupt is sent to the INT1 or
86 // INT2 pin (determined by the trigger bit in the FIFO_CTL register),
87 // and the FIFO_TRIG bit (Bit D7) is set in the FIFO_STATUS
88 // register (Address 0x39).
89 // The FIFO buffer keeps the last n samples (n is the value specified
90 // by the samples bits in the FIFO_CTL register) and then operates
91 // in FIFO mode, collecting new samples only when the FIFO buffer
92 // is not full. A delay of at least 5 µs must elapse between the occurrence of the trigger event and the start of data readback from the
93 // FIFO buffer to allow the bufferto discard and retain the necessary
94 // samples.
95 // Additional trigger events cannot be recognized until the part is
96 // reset to trigger mode. To reset the part to trigger mode,
97 // 1. If desired, read data from the FIFO buffer (see the Retrieving
98 // Data from the FIFO Buffer section).
99 // Before resetting the part to trigger mode, read back the
100 // FIFO data; placing the device into bypass mode clears the
101 // FIFO buffer.
102 // 2. Configure the device for bypass mode by setting Bits[D7:D6]
103 // at Address 0x38 to 00.
104 // 3. Configure the device for trigger mode by setting Bits[D7:D6]
105 // at Address 0x38 to 11.
106
107
108
109};
110
111//enum INT_MAP not necessary
112// enum INT_MAP {
113// //0 referes to interrupt sending to INT1 pin and 1 reffers to interrupt sending to INT2 pin
114// D7 = 0, // DATA READY bit
115// D6 = 1, //SINGLE SHOCK bit
116// D5 = 1, //DOUBLE SHOCK bit
117// D4 = 1 // ACTIVITY bit
118// D3 = 1 // INACTIVITY bit
119// D1 = 0 //WATERMARK bit
120// D0 = 0 //OVERRUN bit
121// INT_MAP = 0b01111000
122// };
123
124
125
126
127enum ADXL375_INTERRUPTS {
128
129 ADXL375_Data_Ready = 7, //The DATA_READY bit is set when new data is available and is cleared when no new data is available.
130 ADXL375_Single_Shock = 6, // The SINGLE_SHOCK bit is set when a single acceleration event that is greater than the value in the THRESH_SHOCK register (Address 0x1D) occurs for less time than is specified by the DUR register (Address 0x21)
131 ADXL375_Double_Shock = 5,
132 //The DOUBLE_SHOCK bit is set when two acceleration events that are greater than the value in the THRESH_SHOCK register (Address 0x1D) occur for less time than is specified by the DUR
133 //register (Address 0x21). The second shock event starts after the time specified by the latent register (Address 0x22) but within the time specified by the window register (Address 0x23)
134 ADXL375_Activity = 4,
135 //The activity bit is set when acceleration greater than the value stored in the THRESH_ACT register (Address 0x24) is experienced on any participating axis.
136 //Participating axes are specified by the ACT_INACT_CTL register (Address 0x27).
137 ADXL375_Inactivity = 3,
138 //The inactivity bit is set when acceleration less than the value stored in the THRESH_INACT register (Address 0x25) is experienced
139 //for more time than is specified by the TIME_INACT register (Address 0x26) on all participating axes. Participating axes are
140 //specified by the ACT_INACT_CTL register (Address 0x27). The maximum value for TIME_INACT is 255 sec.
141 ADXL375_Watermark = 1,
142 //The watermark bit is set when the number of samples in the FIFO buffer equals the value stored in the samples bits (Bits[D4:D0])
143 //of the FIFO_CTL register (Address 0x38). The watermark bit is cleared automatically when the FIFO buffer is read and the
144 //FIFO contents return to a value below the value specified by the samples bits.
145 ADXL375_Overrun = 0,
146 // The overrun bit is set when new data replaces unread data. The precise operation of the overrun function depends on the FIFO mode.
147 //• In bypass mode, the overrun bit is set when new data replaces unread data in the data registers (Address 0x32 to Address 0x37).
148 //• In FIFO mode, stream mode, and trigger mode, the overrun bit is set when the FIFO buffer is full.
149 //The overrun bit is automatically cleared when the FIFO buffer contents are read.
150};
151
152
153enum ADXL375_ODR{
154 ADXL375_ODR_3200_HZ = 0b1111,
155 ADXL375_ODR_1600_HZ = 0b1110,
156 ADXL375_ODR_800_HZ = 0b1101,
158 ADXL375_ODR_200_HZ = 0b1011,
159 ADXL375_ODR_100_HZ = 0b1010,
160 ADXL375_ODR_50_HZ = 0b1001,
161 ADXL375_ODR_25_HZ = 0b1000,
162 ADXL375_ODR_12_5_HZ = 0b0111,
163 ADXL375_ODR_6_25HZ = 0b0110,
164 ADXL375_ODR_3_13_HZ = 0b0101,
165 ADXL375_ODR_1_56_HZ = 0b0100,
166 ADXL375_ODR_0_78_HZ = 0b0011,
167 ADXL375_ODR_0_39_HZ = 0b0010,
168 ADXL375_ODR_0_20_HZ = 0b0001,
169 ADXL375_ODR_0_10_HZ = 0b0000
170};
171
172
173
174enum ADXL375_Low_power_ODR{
175 ADXL375_Low_ODR_400_HZ = 0b1100,
176 ADXL375_Low_ODR_200_HZ = 0b1011,
177 ADXL375_Low_ODR_100_HZ = 0b1010,
178 ADXL375_Low_ODR_50_HZ = 0b1001,
179 ADXL375_Low_ODR_25_HZ = 0b1100,
180 ADXL375_Low_ODR_12_5_HZ = 0b0111,
181};
182
183 enum ADXL375_Self_test_ODR{
184 ADXL375_Self_ODR_800_HZ = 0b1101,
185 ADXL375_Self_ODR_400_HZ = 0b1100,
186 ADXL375_Self_ODR_200_HZ = 0b1011,
187 ADXL375_Self_ODR_100_HZ = 0b1010,
188 ADXL375_Self_ODR_3200_HZ = 0b1111,
189 };
190
191
192#endif