36 #define LIS3DH_DEFAULT_I2C_BUS 0 37 #define LIS3DH_DEFAULT_SPI_BUS 0 38 #define LIS3DH_DEFAULT_I2C_ADDR 0x18 40 #define LIS3DH_CHIPID 0x33 53 LIS3DH_REG_STATUS_REG_AUX = 0x07,
55 LIS3DH_REG_OUT_ADC1_L = 0x08,
56 LIS3DH_REG_OUT_ADC1_H = 0x09,
57 LIS3DH_REG_OUT_ADC2_L = 0x0A,
58 LIS3DH_REG_OUT_ADC2_H = 0x0B,
59 LIS3DH_REG_OUT_ADC3_L = 0x0C,
60 LIS3DH_REG_OUT_ADC3_H = 0x0D,
64 LIS3DH_REG_WHO_AM_I = 0x0F,
68 LIS3DH_REG_CTRL_REG0 = 0x1E,
69 LIS3DH_REG_TEMP_CFG_REG = 0x1F,
70 LIS3DH_REG_CTRL_REG1 = 0x20,
71 LIS3DH_REG_CTRL_REG2 = 0x21,
72 LIS3DH_REG_CTRL_REG3 = 0x22,
73 LIS3DH_REG_CTRL_REG4 = 0x23,
74 LIS3DH_REG_CTRL_REG5 = 0x24,
75 LIS3DH_REG_CTRL_REG6 = 0x25,
77 LIS3DH_REG_REFERENCE = 0x26,
79 LIS3DH_REG_STATUS_REG = 0x27,
81 LIS3DH_REG_OUT_X_L = 0x28,
82 LIS3DH_REG_OUT_X_H = 0x29,
83 LIS3DH_REG_OUT_Y_L = 0x2A,
84 LIS3DH_REG_OUT_Y_H = 0x2B,
85 LIS3DH_REG_OUT_Z_L = 0x2C,
86 LIS3DH_REG_OUT_Z_H = 0x2D,
88 LIS3DH_REG_FIFO_CTRL_REG = 0x2E,
89 LIS3DH_REG_FIFO_SRC_REG = 0x2F,
91 LIS3DH_REG_INT1_CFG = 0x30,
92 LIS3DH_REG_INT1_SRC = 0x31,
93 LIS3DH_REG_INT1_THS = 0x32,
94 LIS3DH_REG_INT1_DURATION = 0x33,
96 LIS3DH_REG_INT2_CFG = 0x34,
97 LIS3DH_REG_INT2_SRC = 0x35,
98 LIS3DH_REG_INT2_THS = 0x36,
99 LIS3DH_REG_INT2_DURATION = 0x37,
101 LIS3DH_REG_CLICK_CFG = 0x38,
102 LIS3DH_REG_CLICK_SRC = 0x39,
103 LIS3DH_REG_CLICK_THS = 0x3A,
105 LIS3DH_REG_TIME_LIMIT = 0x3B,
106 LIS3DH_REG_TIME_LATENCY = 0x3C,
107 LIS3DH_REG_TIME_WINDOW = 0x3D,
109 LIS3DH_REG_ACT_THS = 0x3E,
110 LIS3DH_REG_ACT_DUR = 0x3F,
117 LIS3DH_STATUS_REG_AUX_1DA = 0x01,
118 LIS3DH_STATUS_REG_AUX_2DA = 0x02,
119 LIS3DH_STATUS_REG_AUX_3DA = 0x04,
120 LIS3DH_STATUS_REG_AUX_321DA = 0x08,
122 LIS3DH_STATUS_REG_AUX_1OR = 0x10,
123 LIS3DH_STATUS_REG_AUX_2OR = 0x20,
124 LIS3DH_STATUS_REG_AUX_3OR = 0x40,
125 LIS3DH_STATUS_REG_AUX_321OR = 0x80,
126 } LIS3DH_STATUS_REG_AUX_BITS_T;
134 LIS3DH_CTRL_REG0_SDO_PU_DISC = 0x80,
135 } LIS3DH_CTRL_REG0_BITS_T;
143 LIS3DH_TEMP_CFG_REG_TEMP_EN = 0x40,
144 LIS3DH_TEMP_CFG_REG_ADC_EN = 0x80,
145 } LIS3DH_TEMP_CFG_REG_BITS_T;
151 LIS3DH_CTRL_REG1_XEN = 0x01,
152 LIS3DH_CTRL_REG1_YEN = 0x02,
153 LIS3DH_CTRL_REG1_ZEN = 0x04,
154 LIS3DH_CTRL_REG1_LPEN = 0x08,
156 LIS3DH_CTRL_REG1_ODR0 = 0x10,
157 LIS3DH_CTRL_REG1_ODR1 = 0x20,
158 LIS3DH_CTRL_REG1_ODR2 = 0x40,
159 LIS3DH_CTRL_REG1_ODR3 = 0x80,
160 _LIS3DH_CTRL_REG1_ODR_MASK = 0xF,
161 _LIS3DH_CTRL_REG1_ODR_SHIFT = 4,
162 } LIS3DH_CTRL_REG1_BITS_T;
168 LIS3DH_ODR_POWER_DOWN = 0x0,
171 LIS3DH_ODR_1HZ = 0x1,
172 LIS3DH_ODR_10HZ = 0x2,
173 LIS3DH_ODR_25HZ = 0x3,
174 LIS3DH_ODR_50HZ = 0x4,
175 LIS3DH_ODR_100HZ = 0x5,
176 LIS3DH_ODR_200HZ = 0x6,
177 LIS3DH_ODR_400HZ = 0x7,
188 LIS3DH_ODR_1344HZ = 0x9,
193 LIS3DH_ODR_5376HZ = (0x10 + 0x9),
196 LIS3DH_ODR_LP_1600HZ = (0x10 + 0x8),
203 LIS3DH_CTRL_REG2_HP_IA1 = 0x01,
204 LIS3DH_CTRL_REG2_HP_IA2 = 0x02,
205 LIS3DH_CTRL_REG2_HPCLICK = 0x04,
206 LIS3DH_CTRL_REG2_FDS = 0x08,
208 LIS3DH_CTRL_REG2_HPCF0 = 0x10,
209 LIS3DH_CTRL_REG2_HPCF1 = 0x20,
210 _LIS3DH_CTRL_REG2_HPCF_MASK = 0x3,
211 _LIS3DH_CTRL_REG2_HPCF_SHIFT = 4,
213 LIS3DH_CTRL_REG2_HPM0 = 0x40,
214 LIS3DH_CTRL_REG2_HPM1 = 0x80,
215 _LIS3DH_CTRL_REG2_HPM_MASK = 0x3,
216 _LIS3DH_CTRL_REG2_HPM_SHIFT = 6,
217 } LIS3DH_CTRL_REG2_BITS_T;
223 LIS3DH_HPM_NORMAL_RST_REF_READ = 0x0,
224 LIS3DH_HPM_REF_SIGNAL = 0x1,
225 LIS3DH_HPM_NORMAL = 0x2,
226 LIS3DH_HPM_AUTORST = 0x3,
235 LIS3DH_CTRL_REG3_I1_OVERRUN = 0x02,
236 LIS3DH_CTRL_REG3_I1_WTM = 0x04,
237 LIS3DH_CTRL_REG3_I1_321DA = 0x08,
238 LIS3DH_CTRL_REG3_I1_ZYXDA = 0x10,
239 LIS3DH_CTRL_REG3_I1_IA2 = 0x20,
240 LIS3DH_CTRL_REG3_I1_IA1 = 0x40,
241 LIS3DH_CTRL_REG3_I1_CLICK = 0x80,
242 } LIS3DH_CTRL_REG3_BITS_T;
248 LIS3DH_CTRL_REG4_SIM = 0x01,
250 LIS3DH_CTRL_REG4_ST0 = 0x02,
251 LIS3DH_CTRL_REG4_ST1 = 0x04,
252 _LIS3DH_CTRL_REG4_ST_MASK = 0x3,
253 _LIS3DH_CTRL_REG4_ST_SHIFT = 1,
255 LIS3DH_CTRL_REG4_HR = 0x08,
257 LIS3DH_CTRL_REG4_FS0 = 0x10,
258 LIS3DH_CTRL_REG4_FS1 = 0x20,
259 _LIS3DH_CTRL_REG4_FS_MASK = 0x3,
260 _LIS3DH_CTRL_REG4_FS_SHIFT = 4,
262 LIS3DH_CTRL_REG4_BLE = 0x40,
263 LIS3DH_CTRL_REG4_BDU = 0x80,
264 } LIS3DH_CTRL_REG4_BITS_T;
270 LIS3DH_ST_NORMAL = 0x0,
289 LIS3DH_CTRL_REG5_D4D_INT2 = 0x01,
290 LIS3DH_CTRL_REG5_LIR_INT2 = 0x02,
291 LIS3DH_CTRL_REG5_D4D_INT1 = 0x04,
292 LIS3DH_CTRL_REG5_LIR_INT1 = 0x08,
296 LIS3DH_CTRL_REG5_FIFO_EN = 0x40,
297 LIS3DH_CTRL_REG5_BOOT = 0x80,
298 } LIS3DH_CTRL_REG5_BITS_T;
306 LIS3DH_CTRL_REG6_INT_POLARITY = 0x02,
310 LIS3DH_CTRL_REG6_I2_ACT = 0x08,
311 LIS3DH_CTRL_REG6_I2_BOOT = 0x10,
312 LIS3DH_CTRL_REG6_I2_IA2 = 0x20,
313 LIS3DH_CTRL_REG6_I2_IA1 = 0x40,
314 LIS3DH_CTRL_REG6_I2_CLICK = 0x80,
315 } LIS3DH_CTRL_REG6_BITS_T;
321 LIS3DH_STATUS_REG_XDA = 0x01,
322 LIS3DH_STATUS_REG_YDA = 0x02,
323 LIS3DH_STATUS_REG_ZDA = 0x04,
324 LIS3DH_STATUS_REG_ZYXDA = 0x08,
326 LIS3DH_STATUS_REG_XOR = 0x10,
327 LIS3DH_STATUS_REG_YOR = 0x20,
328 LIS3DH_STATUS_REG_ZOR = 0x40,
329 LIS3DH_STATUS_REG_ZYXOR = 0x80,
330 } LIS3DH_STATUS_REG_BITS_T;
336 LIS3DH_FIFO_CTRL_REG_FTH0 = 0x01,
337 LIS3DH_FIFO_CTRL_REG_FTH1 = 0x02,
338 LIS3DH_FIFO_CTRL_REG_FTH2 = 0x04,
339 LIS3DH_FIFO_CTRL_REG_FTH3 = 0x08,
340 LIS3DH_FIFO_CTRL_REG_FTH4 = 0x10,
341 _LIS3DH_FIFO_CTRL_REG_FTH_MASK = 0x1F,
342 _LIS3DH_FIFO_CTRL_REG_FTH_SHIFT = 0,
344 LIS3DH_FIFO_CTRL_REG_TR = 0x20,
346 LIS3DH_FIFO_CTRL_REG_FM0 = 0x40,
347 LIS3DH_FIFO_CTRL_REG_FM1 = 0x80,
348 _LIS3DH_FIFO_CTRL_REG_FM_MASK = 0x3,
349 _LIS3DH_FIFO_CTRL_REG_FM_SHIFT = 6,
350 } LIS3DH_FIFO_CTRL_REG_BITS_T;
356 LIS3DH_FM_BYPASS = 0x0,
357 LIS3DH_FM_FIFO = 0x1,
358 LIS3DH_FM_STREAM = 0x2,
359 LIS3DH_FM_STREAM_TO_FIFO = 0x3,
366 LIS3DH_FIFO_SRC_REG_FSS0 = 0x01,
367 LIS3DH_FIFO_SRC_REG_FSS1 = 0x02,
368 LIS3DH_FIFO_SRC_REG_FSS2 = 0x04,
369 LIS3DH_FIFO_SRC_REG_FSS3 = 0x08,
370 LIS3DH_FIFO_SRC_REG_FSS4 = 0x10,
371 _LIS3DH_FIFO_SRC_REG_FSS_MASK = 0x1F,
372 _LIS3DH_FIFO_SRC_REG_FSS_SHIFT = 0,
374 LIS3DH_FIFO_SRC_REG_EMPTY = 0x20,
375 LIS3DH_FIFO_SRC_REG_OVRN_FIFO = 0x40,
376 LIS3DH_FIFO_SRC_REG_WTM = 0x80,
377 } LIS3DH_FIFO_SRC_REG_BITS_T;
383 LIS3DH_INT1_CFG_XLIE = 0x01,
384 LIS3DH_INT1_CFG_XHIE = 0x02,
386 LIS3DH_INT1_CFG_YLIE = 0x04,
387 LIS3DH_INT1_CFG_YHIE = 0x08,
389 LIS3DH_INT1_CFG_ZLIE = 0x10,
390 LIS3DH_INT1_CFG_ZHIE = 0x20,
392 LIS3DH_INT1_CFG_6D = 0x40,
393 LIS3DH_INT1_CFG_AOI = 0x80,
394 } LIS3DH_INT1_CFG_BITS_T;
400 LIS3DH_INT1_SRC_XL = 0x01,
401 LIS3DH_INT1_SRC_XH = 0x02,
403 LIS3DH_INT1_SRC_YL = 0x04,
404 LIS3DH_INT1_SRC_YH = 0x08,
406 LIS3DH_INT1_SRC_ZL = 0x10,
407 LIS3DH_INT1_SRC_ZH = 0x20,
409 LIS3DH_INT1_SRC_IA = 0x40,
412 } LIS3DH_INT1_SRC_BITS_T;
418 LIS3DH_INT2_CFG_XLIE = 0x01,
419 LIS3DH_INT2_CFG_XHIE = 0x02,
421 LIS3DH_INT2_CFG_YLIE = 0x04,
422 LIS3DH_INT2_CFG_YHIE = 0x08,
424 LIS3DH_INT2_CFG_ZLIE = 0x10,
425 LIS3DH_INT2_CFG_ZHIE = 0x20,
427 LIS3DH_INT2_CFG_6D = 0x40,
428 LIS3DH_INT2_CFG_AOI = 0x80,
429 } LIS3DH_INT2_CFG_BITS_T;
435 LIS3DH_INT2_SRC_XL = 0x01,
436 LIS3DH_INT2_SRC_XH = 0x02,
438 LIS3DH_INT2_SRC_YL = 0x04,
439 LIS3DH_INT2_SRC_YH = 0x08,
441 LIS3DH_INT2_SRC_ZL = 0x10,
442 LIS3DH_INT2_SRC_ZH = 0x20,
444 LIS3DH_INT2_SRC_IA = 0x40,
447 } LIS3DH_INT2_SRC_BITS_T;
453 LIS3DH_CLICK_CFG_XS = 0x01,
454 LIS3DH_CLICK_CFG_XD = 0x02,
456 LIS3DH_CLICK_CFG_YS = 0x04,
457 LIS3DH_CLICK_CFG_YD = 0x08,
459 LIS3DH_CLICK_CFG_ZS = 0x10,
460 LIS3DH_CLICK_CFG_ZD = 0x20,
463 } LIS3DH_CLICK_CFG_BITS_T;
469 LIS3DH_CLICK_SRC_X = 0x01,
470 LIS3DH_CLICK_SRC_Y = 0x02,
471 LIS3DH_CLICK_SRC_Z = 0x04,
473 LIS3DH_CLICK_SRC_SIGN = 0x08,
475 LIS3DH_CLICK_SRC_SCLICK = 0x10,
476 LIS3DH_CLICK_SRC_DCLICK = 0x20,
478 LIS3DH_CLICK_SRC_IA = 0x40,
481 } LIS3DH_CLICK_SRC_BITS_T;
487 LIS3DH_CLICK_THS_THS0 = 0x01,
488 LIS3DH_CLICK_THS_THS1 = 0x02,
489 LIS3DH_CLICK_THS_THS2 = 0x04,
490 LIS3DH_CLICK_THS_THS3 = 0x08,
491 LIS3DH_CLICK_THS_THS4 = 0x10,
492 LIS3DH_CLICK_THS_THS5 = 0x20,
493 LIS3DH_CLICK_THS_THS6 = 0x40,
494 _LIS3DH_CLICK_THS_THS_MASK = 0x7F,
495 _LIS3DH_CLICK_THS_THS_SHIFT = 0,
497 LIS3DH_CLICK_THS_LIR_CLICK = 0x80,
498 } LIS3DH_CLICK_THS_BITS_T;
501 typedef enum { LIS3DH_INTERRUPT_INT1, LIS3DH_INTERRUPT_INT2 } LIS3DH_INTERRUPT_PINS_T;