Smart Remote 3 nRF52 v1.2
drv_acc_lis3dh.h
1 /*$$$LICENCE_NORDIC_STANDARD<2016>$$$*/
2 
12 #ifndef __DRV_ACC_LIS3DH_H__
13 #define __DRV_ACC_LIS3DH_H__
14 
15 //-----------------------------------------------------------------------------
16 // Enumerations
17 //-----------------------------------------------------------------------------
21 typedef enum
22 {
23  ODR_1Hz = 0x01,
24  ODR_10Hz = 0x02,
25  ODR_25Hz = 0x03,
26  ODR_50Hz = 0x04,
27  ODR_100Hz = 0x05,
28  ODR_200Hz = 0x06,
29  ODR_400Hz = 0x07,
30  ODR_1620Hz_LP = 0x08,
31  ODR_1344Hz_NP_5367HZ_LP = 0x09
32 } ODR_t;
33 
37 typedef enum
38 {
39  POWER_DOWN = 0x00,
40  LOW_POWER = 0x01,
41  NORMAL = 0x02
42 } Mode_t;
43 
47 typedef enum
48 {
49  FULLSCALE_2 = 0x00,
50  FULLSCALE_4 = 0x01,
51  FULLSCALE_8 = 0x02,
52  FULLSCALE_16 = 0x03
53 } Fullscale_t;
54 
58 typedef enum
59 {
60  X_ENABLE = 0x01,
61  Y_ENABLE = 0x02,
62  Z_ENABLE = 0x04,
63 } AXISenable_t;
64 
68 typedef enum
69 {
70  IntOR = 0x00, // Sources are ORed.
71  Int6DMov = 0x01, // 6-direction movement interrupt.
72  IntAND = 0x02, // Sources are ANDed.
73  Int6DPos = 0x03, // 6-direction position change interrupt.
74  Int4DMov = 0x05, // 4-direction movement interrupt.
75  Int4DPos = 0x07, // 4-direction position interrupt.
76 } IntMode_t;
77 
81 typedef enum
82 {
83  IntActiveHigh = 0x00,
84  IntActiveLow = 0x02
86 
90 typedef enum
91 {
92  ClickSingle = 0x00, // Single-click interrupt.
93  ClickDouble = 0x01, // Double-click interrupt.
94 } ClickMode_t;
95 
99 typedef enum
100 {
101  HPNormalRes = 0x00, // Normal mode, reference register reset when read.
102  HPReference = 0x01, // Reference mode.
103  HPNormal = 0x02, // Normal mode.
104  HPAutoResInt = 0x03 // Autoreset upon interrupt.
106 
107 //-----------------------------------------------------------------------------
108 // Structs
109 //-----------------------------------------------------------------------------/
113 typedef struct
114 {
115  int16_t AXIS_X;
116  int16_t AXIS_Y;
117  int16_t AXIS_Z;
118 } AccAxesRaw_t;
119 
120 //-----------------------------------------------------------------------------
121 // SPI register map
122 //-----------------------------------------------------------------------------
123 // Device identification register
124 #define WHO_AM_I 0x0F
125 #define INT_COUNTER_REG 0x0E
126 #define INT1_SOURCE 0x31
127 
128 // Control register 1
129 #define CTRL_REG1 0x20
130 #define ODR_BIT BIT_4
131 #define LPEN BIT_3
132 #define ZEN BIT_2
133 #define YEN BIT_1
134 #define XEN BIT_0
135 
136 // Control register 2
137 #define CTRL_REG2 0x21
138 #define HPM BIT_6
139 #define HPCF BIT_4
140 #define FDS BIT_3
141 #define HPCLICK BIT_2
142 #define HPIS2 BIT_1
143 #define HPIS1 BIT_0
144 
145 // High-pass filter bitmask
146 #define HP_INT1 BIT_0
147 #define HP_INT2 BIT_1
148 #define HP_CLICK BIT_2
149 #define HP_DATA BIT_3
150 
151 // Control register 3
152 #define CTRL_REG3 0x22
153 #define I1_CLICK BIT_7
154 #define I1_AOI1 BIT_6
155 #define I1_AOI2 BIT_5
156 #define I1_DRDY1 BIT_4
157 #define I1_DRDY2 BIT_3
158 #define I1_WTM BIT_2
159 #define I1_ORUN BIT_1
160 
161 // Control register 6
162 #define CTRL_REG6 0x25
163 #define I2_CLICK BIT_7
164 #define I2_INT1 BIT_6
165 #define I2_BOOT BIT_4
166 #define H_LACTIVE BIT_1
167 
168 // Temperature configuration register
169 #define TEMP_CFG_REG 0x1F
170 #define ADC_PD BIT_7
171 #define TEMP_EN BIT_6
172 
173 // Control register 4
174 #define CTRL_REG4 0x23
175 #define BDU BIT_7
176 #define BLE BIT_6
177 #define FS1 BIT_5
178 #define FS0 BIT_4
179 #define HR BIT_3
180 #define ST BIT_1
181 #define SIM BIT_0
182 
183 // Control register 5
184 #define CTRL_REG5 0x24
185 #define BOOT BIT_7
186 #define FIFO_EN BIT_6
187 #define LIR_INT1 BIT_3
188 #define D4D_INT1 BIT_2
189 
190 // Reference/datacapture register
191 #define REFERENCE_REG 0x26
192 #define REF BIT_0
193 
194 // Axis status register
195 #define STATUS_REG 0x27
196 #define ZYXOR BIT_7
197 #define ZOR BIT_6
198 #define YOR BIT_5
199 #define XOR BIT_4
200 #define ZYXDA BIT_3
201 #define ZDA BIT_2
202 #define YDA BIT_1
203 #define XDA BIT_0
204 
205 // Aux status register
206 #define STATUS_AUX 0x07
207 
208 // Interrupt 1 configuration
209 #define INT1_CFG 0x30
210 #define ANDOR BIT_7
211 #define INT_6D BIT_6
212 #define ZHIE BIT_5
213 #define ZLIE BIT_4
214 #define YHIE BIT_3
215 #define YLIE BIT_2
216 #define XHIE BIT_1
217 #define XLIE BIT_0
218 
219 // FIFO control register
220 #define FIFO_CTRL_REG 0x2E
221 #define FM BIT_6
222 #define TR BIT_5
223 #define FTH BIT_0
224 
225 // Control register 3 bitmask
226 #define CLICK_ON_PIN_INT1_ENABLE BIT_7
227 #define I1_INT1_ON_PIN_INT1_ENABLE BIT_6
228 #define I1_INT2_ON_PIN_INT1_ENABLE BIT_5
229 #define I1_DRDY1_ON_INT1_ENABLE BIT_4
230 #define I1_DRDY2_ON_INT1_ENABLE BIT_3
231 #define WTM_ON_INT1_ENABLE BIT_2
232 #define INT1_OVERRUN_ENABLE BIT_1
233 
234 // Control register 6 bitmask
235 #define CLICK_ON_PIN_INT2_ENABLE BIT_7
236 #define I2_INT1_ON_PIN_INT2_ENABLE BIT_6
237 #define I2_INT2_ON_PIN_INT2_ENABLE BIT_5
238 #define I2_BOOT_ON_INT2_ENABLE BIT_4
239 #define INT_ACTIVE_LOW BIT_1
240 
241 // INT1_CFG bitmask
242 #define INT1_AND BIT_7
243 #define INT1_D_ENABLE BIT_6
244 #define INT1_ZHIE_ENABLE BIT_5
245 #define INT1_ZLIE_ENABLE BIT_4
246 #define INT1_YHIE_ENABLE BIT_3
247 #define INT1_YLIE_ENABLE BIT_2
248 #define INT1_XHIE_ENABLE BIT_1
249 #define INT1_XLIE_ENABLE BIT_0
250 
251 // INT1_SRC bitmask
252 #define INT1_SRC_IA BIT_6
253 #define INT1_SRC_ZH BIT_5
254 #define INT1_SRC_ZL BIT_4
255 #define INT1_SRC_YH BIT_3
256 #define INT1_SRC_YL BIT_2
257 #define INT1_SRC_XH BIT_1
258 #define INT1_SRC_XL BIT_0
259 
260 // INT1 registers
261 #define INT1_THS 0x32
262 #define INT1_DURATION 0x33
263 
264 // Interrupt 1 source register
265 #define INT1_SRC 0x31
266 
267 // FIFO Source Register bitmask
268 #define FIFO_SRC_WTM BIT_7
269 #define FIFO_SRC_OVRUN BIT_6
270 #define FIFO_SRC_EMPTY BIT_5
271 
272 // Click interrupt register
273 #define CLICK_CFG 0x38
274 // Click interrupt configuration bitmask
275 #define ZD_ENABLE BIT_5
276 #define ZS_ENABLE BIT_4
277 #define YD_ENABLE BIT_3
278 #define YS_ENABLE BIT_2
279 #define XD_ENABLE BIT_1
280 #define XS_ENABLE BIT_0
281 
282 // Click interrupt source register
283 #define CLICK_SRC 0x39
284 // Click interrupt source register bitmask
285 #define IA BIT_6
286 #define DCLICK BIT_5
287 #define SCLICK BIT_4
288 #define CLICK_SIGN BIT_3
289 #define CLICK_Z BIT_2
290 #define CLICK_Y BIT_1
291 #define CLICK_X BIT_0
292 
293 // Click-click register
294 #define CLICK_THS 0x3A
295 #define TIME_LIMIT 0x3B
296 #define TIME_LATENCY 0x3C
297 #define TIME_WINDOW 0x3D
298 
299 // Output register
300 #define OUT_X_L 0x28
301 #define OUT_X_H 0x29
302 #define OUT_Y_L 0x2A
303 #define OUT_Y_H 0x2B
304 #define OUT_Z_L 0x2C
305 #define OUT_Z_H 0x2D
306 
307 // Aux register
308 #define OUT_1_L 0x08
309 #define OUT_1_H 0x09
310 #define OUT_2_L 0x0A
311 #define OUT_2_H 0x0B
312 #define OUT_3_L 0x0C
313 #define OUT_3_H 0x0D
314 
315 // Status register bitmask
316 #define STATUS_REG_ZYXOR BIT_7 // 1 : New data set has overwritten the previous one.
317  // 0 : No overrun has occurred (default).
318 #define STATUS_REG_ZOR BIT_6 // 0 : No overrun has occurred (default).
319  // 1 : New Z-axis data has overwritten the previous one.
320 #define STATUS_REG_YOR BIT_5 // 0 : No overrun has occurred (default).
321  // 1 : New Y-axis data has overwritten the previous one.
322 #define STATUS_REG_XOR BIT_4 // 0 : No overrun has occurred (default).
323  // 1 : New X-axis data has overwritten the previous one.
324 #define STATUS_REG_ZYXDA BIT_3 // 0 : A new set of data is not yet available.
325  // 1 : A new set of data is available.
326 #define STATUS_REG_ZDA BIT_2 // 0 : A new data for the Z-Axis is not available.
327  // 1 : A new data for the Z-Axis is available.
328 #define STATUS_REG_YDA BIT_1 // 0 : A new data for the Y-Axis is not available.
329  // 1 : A new data for the Y-Axis is available.
330 #define STATUS_REG_XDA BIT_0 // 0 : A new data for the X-Axis is not available.
331 
332 #define DATAREADY_BIT STATUS_REG_ZYXDA
333 
334 
335 // Aux status register bitmask
336 #define STATUS_AUX_321OR BIT_7
337 #define STATUS_AUX_3OR BIT_6
338 #define STATUS_AUX_2OR BIT_5
339 #define STATUS_AUX_1OR BIT_4
340 #define STATUS_AUX_321DA BIT_3
341 #define STATUS_AUX_3DA BIT_2
342 #define STATUS_AUX_2DA BIT_1
343 #define STATUS_AUX_1DA BIT_0
344 
345 #define I_AM_LIS3DH 0x33
346 
347 // FIFO registers
348 #define FIFO_CTRL_REG 0x2E
349 #define FIFO_SRC_REG 0x2F
350 
351 #endif /* __DRV_ACC_LIS3DH_TYPES_H__ */
352 

Documentation feedback | Developer Zone | Subscribe | Updated