-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLSM9DS1_Driver.h
665 lines (514 loc) · 36 KB
/
LSM9DS1_Driver.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
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LSM9DS1_DRIVER__H
#define __LSM9DS1_DRIVER__H
#endif
// User include starts here
#include <stdint.h>
#include <stdlib.h>
#include "stm32f4xx_hal.h"
#include "i2c.h"
#include "gpio.h"
#include "motion_fx.h"
// User include ends here
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_LSM9DS1_I2C_FREQUENCY
# define CONFIG_LSM9DS1_I2C_FREQUENCY 400000
#endif
/* Register Addresses *******************************************************/
/* Accelerometer and gyroscope registers */
#define LSM9DS1_ACT_THS 0x04 /* Inactivity threshold */
#define LSM9DS1_ACT_DUR 0x05 /* Inactivity duration */
#define LSM9DS1_INT_GEN_CFG_XL 0x06 /* Accelerometer interrupt configuration */
#define LSM9DS1_INT_GEN_THS_X_XL 0x07 /* Accelerometer X interrupt threshold */
#define LSM9DS1_INT_GEN_THS_Y_XL 0x08 /* Accelerometer Y interrupt threshold */
#define LSM9DS1_INT_GEN_THS_Z_XL 0x09 /* Accelerometer Z interrupt threshold */
#define LSM9DS1_INT_GEN_DUR_XL 0x0a /* Accelerometer interrupt duration */
#define LSM9DS1_REFERENCE_G 0x0b /* Gyroscope reference value for high-pass filter */
#define LSM9DS1_INT1_CTRL 0x0c /* INT1_A/G pin control */
#define LSM9DS1_INT2_CTRL 0x0d /* INT2_A/G pin control */
#define LSM9DS1_WHO_AM_I 0x0f /* Accelerometer and gyroscope device identification */
#define LSM9DS1_CTRL_REG1_G 0x10 /* Gyroscope control register 1 */
#define LSM9DS1_CTRL_REG2_G 0x11 /* Gyroscope control register 2 */
#define LSM9DS1_CTRL_REG3_G 0x12 /* Gyroscope control register 3 */
#define LSM9DS1_ORIENT_CFG_G 0x13 /* Gyroscope sign and orientation */
#define LSM9DS1_INT_GEN_SRC_G 0x14 /* Gyroscope interrupt source */
#define LSM9DS1_OUT_TEMP_L 0x15 /* Temperature low byte */
#define LSM9DS1_OUT_TEMP_H 0x16 /* Temperature high byte */
#define LSM9DS1_STATUS_REG 0x17 /* Status register */
#define LSM9DS1_OUT_X_L_G 0x18 /* Gyroscope pitch (X) low byte */
#define LSM9DS1_OUT_X_H_G 0x19 /* Gyroscope pitch (X) high byte */
#define LSM9DS1_OUT_Y_L_G 0x1a /* Gyroscope roll (Y) low byte */
#define LSM9DS1_OUT_Y_H_G 0x1b /* Gyroscope roll (Y) high byte */
#define LSM9DS1_OUT_Z_L_G 0x1c /* Gyroscope yaw (Z) low byte */
#define LSM9DS1_OUT_Z_H_G 0x1d /* Gyroscope yaw (Z) high byte */
#define LSM9DS1_CTRL_REG4 0x1e /* Control register 4 */
#define LSM9DS1_CTRL_REG5_XL 0x1f /* Accelerometer control register 5 */
#define LSM9DS1_CTRL_REG6_XL 0x20 /* Accelerometer control register 6 */
#define LSM9DS1_CTRL_REG7_XL 0x21 /* Accelerometer control register 7 */
#define LSM9DS1_CTRL_REG8 0x22 /* Control register 8 */
#define LSM9DS1_CTRL_REG9 0x23 /* Control register 9 */
#define LSM9DS1_CTRL_REG10 0x24 /* Control register 10 */
#define LSM9DS1_INT_GEN_SRC_XL 0x26 /* Accelerometer interrupt source */
#define LSM9DS1_STATUS_REG2 0x27 /* Status register 2 */
#define LSM9DS1_OUT_X_L_XL 0x28 /* Accelerometer X low byte */
#define LSM9DS1_OUT_X_H_XL 0x29 /* Accelerometer X high byte */
#define LSM9DS1_OUT_Y_L_XL 0x2a /* Accelerometer Y low byte */
#define LSM9DS1_OUT_Y_H_XL 0x2b /* Accelerometer Y high byte */
#define LSM9DS1_OUT_Z_L_XL 0x2c /* Accelerometer Z low byte */
#define LSM9DS1_OUT_Z_H_XL 0x2d /* Accelerometer Z high byte */
#define LSM9DS1_FIFO_CTRL 0x2e /* FIFO control register */
#define LSM9DS1_FIFO_SRC 0x2f /* FIFO status control register */
#define LSM9DS1_INT_GEN_CFG_G 0x30 /* Gyroscope interrupt configuration */
#define LSM9DS1_INT_GEN_THS_XH_G 0x31 /* Gyroscope pitch (X) interrupt threshold high byte */
#define LSM9DS1_INT_GEN_THS_XL_G 0x32 /* Gyroscope pitch (X) interrupt threshold low byte */
#define LSM9DS1_INT_GEN_THS_YH_G 0x33 /* Gyroscope roll (Y) interrupt threshold high byte */
#define LSM9DS1_INT_GEN_THS_YL_G 0x34 /* Gyroscope roll (Y) interrupt threshold low byte */
#define LSM9DS1_INT_GEN_THS_ZH_G 0x35 /* Gyroscope yaw (Z) interrupt threshold high byte */
#define LSM9DS1_INT_GEN_THS_ZL_G 0x36 /* Gyroscope yaw (Z) interrupt threshold low byte */
#define LSM9DS1_INT_GEN_DUR_G 0x37 /* Gyroscope interrupt duration */
/* Magnetometer registers */
#define LSM9DS1_OFFSET_X_REG_L_M 0x05 /* X low byte offset */
#define LSM9DS1_OFFSET_X_REG_H_M 0x06 /* X high byte offset */
#define LSM9DS1_OFFSET_Y_REG_L_M 0x07 /* Y low byte offset */
#define LSM9DS1_OFFSET_Y_REG_H_M 0x08 /* Y high byte offset */
#define LSM9DS1_OFFSET_Z_REG_L_M 0x09 /* Z low byte offset */
#define LSM9DS1_OFFSET_Z_REG_H_M 0x0a /* Z high byte offset */
#define LSM9DS1_WHO_AM_I_M 0x0f /* Device identification */
#define LSM9DS1_CTRL_REG1_M 0x20 /* Control register 1 */
#define LSM9DS1_CTRL_REG2_M 0x21 /* Control register 2 */
#define LSM9DS1_CTRL_REG3_M 0x22 /* Control register 3 */
#define LSM9DS1_CTRL_REG4_M 0x23 /* Control register 4 */
#define LSM9DS1_CTRL_REG5_M 0x24 /* Control register 5 */
#define LSM9DS1_STATUS_REG_M 0x27 /* Status register */
#define LSM9DS1_OUT_X_L_M 0x28 /* X low byte */
#define LSM9DS1_OUT_X_H_M 0x29 /* X high byte */
#define LSM9DS1_OUT_Y_L_M 0x2a /* Y low byte */
#define LSM9DS1_OUT_Y_H_M 0x2b /* Y high byte */
#define LSM9DS1_OUT_Z_L_M 0x2c /* Z low byte */
#define LSM9DS1_OUT_Z_H_M 0x2d /* Z high byte */
#define LSM9DS1_INT_CFG_M 0x30 /* Interrupt configuration */
#define LSM9DS1_INT_SRC_M 0x31 /* Interrupt source */
#define LSM9DS1_INT_THS_L_M 0x32 /* Interrupt threshold low byte */
#define LSM9DS1_INT_THS_H_M 0x33 /* Interrupt threshold high byte */
/* Register Bit Definitions *************************************************/
/* Inactivity threshold register */
#define LSM9DS1_ACT_THS_ACT_THS_SHIFT 0 /* Inactivity threshold */
#define LSM9DS1_ACT_THS_ACT_THS_MASK (127 << LSM9DS1_ACT_THS_ACT_THS_SHIFT)
#define LSM9DS1_ACT_THS_SLEEP_ON_INACT_EN (1 << 7) /* Gyroscope operating mode during inactivity */
/* Accelerometer interrupt configuration register */
#define LSM9DS1_INT_GEN_CFG_XL_XLIE_XL (1 << 0) /* X-axis low byte interrupt enable */
#define LSM9DS1_INT_GEN_CFG_XL_XHIE_XL (1 << 1) /* X-axis high byte interrupt enable */
#define LSM9DS1_INT_GEN_CFG_XL_YLIE_XL (1 << 2) /* Y-axis low byte interrupt enable */
#define LSM9DS1_INT_GEN_CFG_XL_YHIE_XL (1 << 3) /* Y-axis high byte interrupt enable */
#define LSM9DS1_INT_GEN_CFG_XL_ZLIE_XL (1 << 4) /* Z-axis low byte interrupt enable */
#define LSM9DS1_INT_GEN_CFG_XL_ZHIE_XL (1 << 5) /* Z-axis high byte interrupt enable */
#define LSM9DS1_INT_GEN_CFG_XL_6D (1 << 6) /* 6-direction detection function for interrupt */
#define LSM9DS1_INT_GEN_CFG_XL_AOI_XL (1 << 7) /* AND/OR combination of interrupt events */
/* Accelerometer interrupt duration register */
#define LSM9DS1_INT_GEN_DUR_XL_DUR_XL_SHIFT 0 /* Enter/exit interrupt duration */
#define LSM9DS1_INT_GEN_DUR_XL_DUR_XL_MASK (127 << LSM9DS1_INT_GEN_DUR_XL_DUR_XL_SHIFT)
#define LSM9DS1_INT_GEN_DUR_XL_WAIT_XL (1 << 7) /* Wait function enabled on duration counter */
/* INT1_A/G pin control register */
#define LSM9DS1_INT1_CTRL_INT1_DRDY_XL (1 << 0) /* Accelerometer data ready */
#define LSM9DS1_INT1_CTRL_INT1_DRDY_G (1 << 1) /* Gyroscope data ready */
#define LSM9DS1_INT1_CTRL_INT1_BOOT (1 << 2) /* Boot status available */
#define LSM9DS1_INT1_CTRL_INT1_FTH (1 << 3) /* FIFO threshold interrupt */
#define LSM9DS1_INT1_CTRL_INT1_OVR (1 << 4) /* Overrun interrupt */
#define LSM9DS1_INT1_CTRL_INT1_FSS5 (1 << 5) /* FSS5 interrupt */
#define LSM9DS1_INT1_CTRL_INT1_IG_XL (1 << 6) /* Accelerometer interrupt enable */
#define LSM9DS1_INT1_CTRL_INT1_IG_G (1 << 7) /* Gyroscope interrupt enable */
/* INT2_A/G pin control register */
#define LSM9DS1_INT2_CTRL_INT2_DRDY_XL (1 << 0) /* Accelerometer data ready */
#define LSM9DS1_INT2_CTRL_INT2_DRDY_G (1 << 1) /* Gyroscope data ready */
#define LSM9DS1_INT2_CTRL_INT2_DRDY_TEMP (1 << 2) /* Temperature data ready */
#define LSM9DS1_INT2_CTRL_INT2_FTH (1 << 3) /* FIFO threshold interrupt */
#define LSM9DS1_INT2_CTRL_INT2_OVR (1 << 4) /* Overrun interrupt */
#define LSM9DS1_INT2_CTRL_INT2_FSS5 (1 << 5) /* FSS5 interrupt */
#define LSM9DS1_INT2_CTRL_INT2_INACT (1 << 7) /* Inactivity interrupt output signal */
/* Device identification register of accelerometer and gyroscope*/
#define LSM9DS1_WHO_AM_I_VALUE 0x68
/* Gyroscope control register 1 */
#define LSM9DS1_CTRL_REG1_G_BW_G_SHIFT 0 /* Gyroscope bandwidth selection */
#define LSM9DS1_CTRL_REG1_G_BW_G_MASK (3 << LSM9DS1_CTRL_REG1_G_BW_G_SHIFT)
#define LSM9DS1_CTRL_REG1_G_FS_G_SHIFT 3 /* Gyroscope full-scale selection */
#define LSM9DS1_CTRL_REG1_G_FS_G_MASK (3 << LSM9DS1_CTRL_REG1_G_FS_G_SHIFT)
# define LSM9DS1_CTRL_REG1_G_FS_G_245DPS (0 << LSM9DS1_CTRL_REG1_G_FS_G_SHIFT) /* 245 dps */
# define LSM9DS1_CTRL_REG1_G_FS_G_500DPS (1 << LSM9DS1_CTRL_REG1_G_FS_G_SHIFT) /* 500 dps */
# define LSM9DS1_CTRL_REG1_G_FS_G_2000DPS (3 << LSM9DS1_CTRL_REG1_G_FS_G_SHIFT) /* 2000 dps */
#define LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT 5 /* Gyroscope bandwidth selection */
#define LSM9DS1_CTRL_REG1_G_ODR_G_MASK (7 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT)
# define LSM9DS1_CTRL_REG1_G_ODR_G_POWERDOWN (0 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT) /* Power-down mode */
# define LSM9DS1_CTRL_REG1_G_ODR_G_14p9HZ (1 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT) /* 14.9 Hz */
# define LSM9DS1_CTRL_REG1_G_ODR_G_59p5HZ (2 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT) /* 59.5 Hz */
# define LSM9DS1_CTRL_REG1_G_ODR_G_119HZ (3 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT) /* 119 Hz */
# define LSM9DS1_CTRL_REG1_G_ODR_G_238HZ (4 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT) /* 238 Hz */
# define LSM9DS1_CTRL_REG1_G_ODR_G_476HZ (5 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT) /* 476 Hz */
# define LSM9DS1_CTRL_REG1_G_ODR_G_952HZ (6 << LSM9DS1_CTRL_REG1_G_ODR_G_SHIFT) /* 952 Hz */
/* Gyroscope control register 2 */
#define LSM9DS1_CTRL_REG2_G_OUT_SEL_SHIFT 0 /* Out selection configuration */
#define LSM9DS1_CTRL_REG2_G_OUT_SEL_MASK (3 << LSM9DS1_CTRL_REG2_G_OUT_SEL_SHIFT)
#define LSM9DS1_CTRL_REG2_G_INT_SEL_SHIFT 2 /* INT selection configuration */
#define LSM9DS1_CTRL_REG2_G_INT_SEL_MASK (3 << LSM9DS1_CTRL_REG2_G_INT_SEL_SHIFT)
/* Gyroscope control register 3 */
#define LSM9DS1_CTRL_REG3_G_HPCF_G_SHIFT 0 /* Gyroscope high-pass filter cutoff frequency selection */
#define LSM9DS1_CTRL_REG3_G_HPCF_G_MASK (15 << LSM9DS1_CTRL_REG3_G_HPCF_G_SHIFT)
#define LSM9DS1_CTRL_REG3_G_HP_EN (1 << 6) /* High-pass filter enable */
#define LSM9DS1_CTRL_REG3_G_LP_MODE (1 << 7) /* Low-power mode enable */
/* Gyroscope sign and orientation register */
#define LSM9DS1_ORIENT_CFG_G_ORIENT_SHIFT 0 /* Directional user orientation selection */
#define LSM9DS1_ORIENT_CFG_G_ORIENT_MASK (3 << LSM9DS1_ORIENT_CFG_G_ORIENT_SHIFT)
#define LSM9DS1_ORIENT_CFG_G_SIGNZ_G (1 << 3) /* Yaw axis (Z) angular rate sign */
#define LSM9DS1_ORIENT_CFG_G_SIGNY_G (1 << 4) /* Roll axis (Y) angular rate sign */
#define LSM9DS1_ORIENT_CFG_G_SIGNX_G (1 << 5) /* Pitch axis (X) angular rate sign */
/* Gyroscope interrupt source register */
#define LSM9DS1_INT_GEN_SRC_G_XL_G (1 << 0) /* Pitch (X) low */
#define LSM9DS1_INT_GEN_SRC_G_XH_G (1 << 1) /* Pitch (X) high */
#define LSM9DS1_INT_GEN_SRC_G_YL_G (1 << 2) /* Roll (Y) low */
#define LSM9DS1_INT_GEN_SRC_G_YH_G (1 << 3) /* Roll (Y) high */
#define LSM9DS1_INT_GEN_SRC_G_ZL_G (1 << 4) /* Yaw (Z) low */
#define LSM9DS1_INT_GEN_SRC_G_ZH_G (1 << 5) /* Yaw (Z) high */
#define LSM9DS1_INT_GEN_SRC_G_IA_G (1 << 6) /* Interrupt active */
/* Status register */
#define LSM9DS1_STATUS_REG_XLDA (1 << 0) /* Accelerometer new data available */
#define LSM9DS1_STATUS_REG_GDA (1 << 1) /* Gyroscope new data available */
#define LSM9DS1_STATUS_REG_TDA (1 << 2) /* Temperature sensor new data available */
#define LSM9DS1_STATUS_REG_BOOT_STATUS (1 << 3) /* Boot running flag signal */
#define LSM9DS1_STATUS_REG_INACT (1 << 4) /* Inactivity interrupt output signal */
#define LSM9DS1_STATUS_REG_IG_G (1 << 5) /* Gyroscope interrupt output signal */
#define LSM9DS1_STATUS_REG_IG_XL (1 << 6) /* Accelerometer interrupt output signal */
/* Control register 4 */
#define LSM9DS1_CTRL_REG4_4D_XL1 (1 << 0) /* 4D option enabled on interrupt */
#define LSM9DS1_CTRL_REG4_LIR_XL1 (1 << 1) /* Latched interrupt */
#define LSM9DS1_CTRL_REG4_XEN_G (1 << 3) /* Gyroscope's pitch axis (X) output enable */
#define LSM9DS1_CTRL_REG4_YEN_G (1 << 4) /* Gyroscope's roll axis (Y) output enable */
#define LSM9DS1_CTRL_REG4_ZEN_G (1 << 5) /* Gyroscope's yaw axis (Z) output enable */
/* Accelerometer control register 5 */
#define LSM9DS1_CTRL_REG5_XL_XEN_XL (1 << 3) /* Accelerometer's X-axis output enable */
#define LSM9DS1_CTRL_REG5_XL_YEN_XL (1 << 4) /* Accelerometer's Y-axis output enable */
#define LSM9DS1_CTRL_REG5_XL_ZEN_XL (1 << 5) /* Accelerometer's Z-axis output enable */
#define LSM9DS1_CTRL_REG5_XL_DEC_SHIFT 6 /* Decimation of acceleration data on OUT REG and FIFO */
#define LSM9DS1_CTRL_REG5_XL_DEC_MASK (3 << LSM9DS1_CTRL_REG5_XL_DEC_SHIFT)
# define LSM9DS1_CTRL_REG5_XL_DEC_NODEC (0 << LSM9DS1_CTRL_REG5_XL_DEC_SHIFT) /* No decimation */
# define LSM9DS1_CTRL_REG5_XL_DEC_2SAMPLES (1 << LSM9DS1_CTRL_REG5_XL_DEC_SHIFT) /* Update every 2 samples */
# define LSM9DS1_CTRL_REG5_XL_DEC_4SAMPLES (2 << LSM9DS1_CTRL_REG5_XL_DEC_SHIFT) /* Update every 4 samples */
# define LSM9DS1_CTRL_REG5_XL_DEC_8SAMPLES (3 << LSM9DS1_CTRL_REG5_XL_DEC_SHIFT) /* Update every 8 samples */
/* Accelerometer control register 6 */
#define LSM9DS1_CTRL_REG6_XL_BW_XL_SHIFT 0 /* Anti-aliasing filter bandwidth selection */
#define LSM9DS1_CTRL_REG6_XL_BW_XL_MASK (3 << LSM9DS1_CTRL_REG6_XL_BW_XL_SHIFT)
# define LSM9DS1_CTRL_REG6_XL_BW_XL_408HZ (0 << LSM9DS1_CTRL_REG6_XL_BW_XL_SHIFT) /* 408 Hz */
# define LSM9DS1_CTRL_REG6_XL_BW_XL_211HZ (1 << LSM9DS1_CTRL_REG6_XL_BW_XL_SHIFT) /* 211 Hz */
# define LSM9DS1_CTRL_REG6_XL_BW_XL_105HZ (2 << LSM9DS1_CTRL_REG6_XL_BW_XL_SHIFT) /* 105 Hz */
# define LSM9DS1_CTRL_REG6_XL_BW_XL_50HZ (3 << LSM9DS1_CTRL_REG6_XL_BW_XL_SHIFT) /* 50 Hz */
#define LSM9DS1_CTRL_REG6_XL_BW_SCAL_ODR (1 << 2) /* Bandwidth selection */
#define LSM9DS1_CTRL_REG6_XL_FS_XL_SHIFT 3 /* Accelerometer full-scale selection */
#define LSM9DS1_CTRL_REG6_XL_FS_XL_MASK (3 << LSM9DS1_CTRL_REG6_XL_FS_XL_SHIFT)
# define LSM9DS1_CTRL_REG6_XL_FS_XL_2G (0 << LSM9DS1_CTRL_REG6_XL_FS_XL_SHIFT) /* +/- 2 g */
# define LSM9DS1_CTRL_REG6_XL_FS_XL_16G (1 << LSM9DS1_CTRL_REG6_XL_FS_XL_SHIFT) /* +/- 16 g */
# define LSM9DS1_CTRL_REG6_XL_FS_XL_4G (2 << LSM9DS1_CTRL_REG6_XL_FS_XL_SHIFT) /* +/- 4 g */
# define LSM9DS1_CTRL_REG6_XL_FS_XL_8G (3 << LSM9DS1_CTRL_REG6_XL_FS_XL_SHIFT) /* +/- 8 g */
#define LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT 5 /* Output data rate and power mode selection */
#define LSM9DS1_CTRL_REG6_XL_ODR_XL_MASK (7 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT)
# define LSM9DS1_CTRL_REG6_XL_ODR_XL_POWERDOWN (0 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT) /* Power-down mode */
# define LSM9DS1_CTRL_REG6_XL_ODR_XL_10HZ (1 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT) /* 10 Hz */
# define LSM9DS1_CTRL_REG6_XL_ODR_XL_50HZ (2 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT) /* 50 Hz */
# define LSM9DS1_CTRL_REG6_XL_ODR_XL_119HZ (3 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT) /* 119 Hz */
# define LSM9DS1_CTRL_REG6_XL_ODR_XL_238HZ (4 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT) /* 238 Hz */
# define LSM9DS1_CTRL_REG6_XL_ODR_XL_476HZ (5 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT) /* 476 Hz */
# define LSM9DS1_CTRL_REG6_XL_ODR_XL_952HZ (6 << LSM9DS1_CTRL_REG6_XL_ODR_XL_SHIFT) /* 952 Hz */
/* Accelerometer control register 7 */
#define LSM9DS1_CTRL_REG7_XL_HPIS1 (1 << 0) /* High-pass filter enabled */
#define LSM9DS1_CTRL_REG7_XL_FDS (1 << 2) /* Filtered data selection */
#define LSM9DS1_CTRL_REG7_XL_DCF_SHIFT 5 /* Accelerometer digital filter cutoff frequency selection */
#define LSM9DS1_CTRL_REG7_XL_DCF_MASK (3 << LSM9DS1_CTRL_REG7_XL_DCF_SHIFT)
# define LSM9DS1_CTRL_REG7_XL_DCF_ODR_DIV50 (0 << LSM9DS1_CTRL_REG7_XL_DCF_SHIFT)
# define LSM9DS1_CTRL_REG7_XL_DCF_ODR_DIV100 (1 << LSM9DS1_CTRL_REG7_XL_DCF_SHIFT)
# define LSM9DS1_CTRL_REG7_XL_DCF_ODR_DIV9 (2 << LSM9DS1_CTRL_REG7_XL_DCF_SHIFT)
# define LSM9DS1_CTRL_REG7_XL_DCF_ODR_DIV400 (3 << LSM9DS1_CTRL_REG7_XL_DCF_SHIFT)
#define LSM9DS1_CTRL_REG7_XL_HR (1 << 7) /* High resolution mode enable */
/* Control register 8 */
#define LSM9DS1_CTRL_REG8_SW_RESET (1 << 0) /* Software reset */
#define LSM9DS1_CTRL_REG8_BLE (1 << 1) /* Big/little endian data selection */
#define LSM9DS1_CTRL_REG8_IF_ADD_INC (1 << 2) /* Register address automatically incremented during a multibyte access */
#define LSM9DS1_CTRL_REG8_SIM (1 << 3) /* SPI serial interface mode selection */
#define LSM9DS1_CTRL_REG8_PP_OD (1 << 4) /* Push-pull/open-drain selection on the INT1_A/G and INT2_A/G pins */
#define LSM9DS1_CTRL_REG8_H_LACTIVE (1 << 5) /* Interrupt activation level */
#define LSM9DS1_CTRL_REG8_BDU (1 << 6) /* Block data update */
#define LSM9DS1_CTRL_REG8_BOOT (1 << 7) /* Reboot memory content */
/* Control register 9 */
#define LSM9DS1_CTRL_REG9_STOP_ON_FTH (1 << 0) /* Enable FIFO threshold level use */
#define LSM9DS1_CTRL_REG9_FIFO_EN (1 << 1) /* FIFO memory enable */
#define LSM9DS1_CTRL_REG9_I2C_DISABLE (1 << 2) /* Disable I2C interface */
#define LSM9DS1_CTRL_REG9_DRDY_MASK_BIT (1 << 3) /* Data available enable bit */
#define LSM9DS1_CTRL_REG9_FIFO_TEMP_EN (1 << 4) /* Temperature data storage in FIFO enable */
#define LSM9DS1_CTRL_REG9_SLEEP_G (1 << 6) /* Gyroscope sleep mode enable */
/* Control register 10 */
#define LSM9DS1_CTRL_REG10_ST_XL (1 << 0) /* Linear acceleration sensor self-test enable */
#define LSM9DS1_CTRL_REG10_ST_G (1 << 2) /* Angular rate sensor self-test enable */
/* Accelerometer interrupt source register */
#define LSM9DS1_INT_GEN_SRC_XL_XL_XL (1 << 0) /* Accelerometer's X low event */
#define LSM9DS1_INT_GEN_SRC_XL_XH_XL (1 << 1) /* Accelerometer's X high event */
#define LSM9DS1_INT_GEN_SRC_XL_YL_XL (1 << 2) /* Accelerometer's Y low event */
#define LSM9DS1_INT_GEN_SRC_XL_YH_XL (1 << 3) /* Accelerometer's Y high event */
#define LSM9DS1_INT_GEN_SRC_XL_ZL_XL (1 << 4) /* Accelerometer's Z low event */
#define LSM9DS1_INT_GEN_SRC_XL_ZH_XL (1 << 5) /* Accelerometer's Z high event */
#define LSM9DS1_INT_GEN_SRC_XL_IA_XL (1 << 6) /* Interrupt active */
/* Status register 2 */
#define LSM9DS1_STATUS_REG2_XLDA (1 << 0) /* Accelerometer new data available */
#define LSM9DS1_STATUS_REG2_GDA (1 << 1) /* Gyroscope new data available */
#define LSM9DS1_STATUS_REG2_TDA (1 << 2) /* Temperature sensor new data available */
#define LSM9DS1_STATUS_REG2_BOOT_STATUS (1 << 3) /* Boot running flag signal */
#define LSM9DS1_STATUS_REG2_INACT (1 << 4) /* Inactivity interrupt output signal */
#define LSM9DS1_STATUS_REG2_IG_G (1 << 5) /* Gyroscope interrupt output signal */
#define LSM9DS1_STATUS_REG2_IG_XL (1 << 6) /* Accelerometer interrupt output signal */
/* FIFO control register */
#define LSM9DS1_FIFO_CTRL_FTH_SHIFT 0 /* FIFO threshold level setting */
#define LSM9DS1_FIFO_CTRL_FTH_MASK (31 << LSM9DS1_FIFO_CTRL_FTH_SHIFT)
#define LSM9DS1_FIFO_CTRL_FMODE_SHIFT 5 /* FIFO mode selection bits */
#define LSM9DS1_FIFO_CTRL_FMODE_MASK (7 << LSM9DS1_FIFO_CTRL_FMODE_SHIFT)
# define LSM9DS1_FIFO_CTRL_FMODE_BYPASS (0 << LSM9DS1_FIFO_CTRL_FMODE_SHIFT) /* Bypass mode */
# define LSM9DS1_FIFO_CTRL_FMODE_FIFO (1 << LSM9DS1_FIFO_CTRL_FMODE_SHIFT) /* FIFO mode */
# define LSM9DS1_FIFO_CTRL_FMODE_CONT_FIFO (3 << LSM9DS1_FIFO_CTRL_FMODE_SHIFT) /* Continuous-to-FIFO mode */
# define LSM9DS1_FIFO_CTRL_FMODE_BYPASS_CONT (4 << LSM9DS1_FIFO_CTRL_FMODE_SHIFT) /* Bypass-to-continuous mode */
# define LSM9DS1_FIFO_CTRL_FMODE_CONT (5 << LSM9DS1_FIFO_CTRL_FMODE_SHIFT) /* Continuous mode */
/* FIFO status control register */
#define LSM9DS1_FIFO_SRC_FSS_SHIFT 0 /* Number of unread samples stored into FIFO */
#define LSM9DS1_FIFO_SRC_FSS_MASK (63 << LSM9DS1_FIFO_SRC_FSS_SHIFT)
#define LSM9DS1_FIFO_SRC_OVRN (1 << 6) /* FIFO overrun status */
#define LSM9DS1_FIFO_SRC_FTH (1 << 7) /* FIFO threshold status */
/* Gyroscope interrupt configuration register */
#define LSM9DS1_INT_GEN_CFG_G_XLIE_G (1 << 0) /* Pitch (X) axis low event interrupt enable */
#define LSM9DS1_INT_GEN_CFG_G_XHIE_G (1 << 1) /* Pitch (X) axis high event interrupt enable */
#define LSM9DS1_INT_GEN_CFG_G_YLIE_G (1 << 2) /* Roll (Y) axis low event interrupt enable */
#define LSM9DS1_INT_GEN_CFG_G_YHIE_G (1 << 3) /* Roll (Y) axis high event interrupt enable */
#define LSM9DS1_INT_GEN_CFG_G_ZLIE_G (1 << 4) /* Yaw (Z) axis low event interrupt enable */
#define LSM9DS1_INT_GEN_CFG_G_ZHIE_G (1 << 5) /* Yaw (Z) axis high event interrupt enable */
#define LSM9DS1_INT_GEN_CFG_G_LIR_G (1 << 6) /* Latch interrupt request */
#define LSM9DS1_INT_GEN_CFG_G_AOI_G (1 << 7) /* AND/OR combination of interrupt events */
/* Gyroscope interrupt threshold registers */
#define LSM9DS1_INT_GEN_THS_XH_G_THS_XH_G_SHIFT 0 /* X interrupt threshold high byte */
#define LSM9DS1_INT_GEN_THS_XH_G_THS_XH_G_MASK (127 << LSM9DS1_INT_GEN_THS_XH_G_THS_XH_G_SHIFT)
#define LSM9DS1_INT_GEN_THS_XH_G_DCRM_G (1 << 7) /* Decrement or reset counter mode selection */
/* Gyroscope interrupt duration register */
#define LSM9DS1_INT_GEN_DUR_G_DUR_G_SHIFT 0 /* Enter/exit interrupt duration */
#define LSM9DS1_INT_GEN_DUR_G_DUR_G_MASK (127 << LSM9DS1_INT_GEN_DUR_G_DUR_G_SHIFT)
#define LSM9DS1_INT_GEN_DUR_G_WAIT_G (1 << 7) /* Exit from interrupt wait function enable */
/* Device identification register */
#define LSM9DS1_WHO_AM_I_M_VALUE 0x3d
/* Magnetometer control register 1 */
#define LSM9DS1_CTRL_REG1_M_ST (1 << 0) /* Self-test enable */
#define LSM9DS1_CTRL_REG1_M_FAST_ODR (1 << 1) /* Enable data rates higher than 80 Hz */
#define LSM9DS1_CTRL_REG1_M_DO_SHIFT 2 /* Output data rate selection */
#define LSM9DS1_CTRL_REG1_M_DO_MASK (7 << LSM9DS1_CTRL_REG1_M_DO_SHIFT)
# define LSM9DS1_CTRL_REG1_M_DO_0p625HZ (0 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 0.625 Hz */
# define LSM9DS1_CTRL_REG1_M_DO_1p25HZ (1 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 1.25 Hz */
# define LSM9DS1_CTRL_REG1_M_DO_2p5HZ (2 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 2.5 Hz */
# define LSM9DS1_CTRL_REG1_M_DO_5HZ (3 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 5 Hz */
# define LSM9DS1_CTRL_REG1_M_DO_10HZ (4 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 10 Hz */
# define LSM9DS1_CTRL_REG1_M_DO_20HZ (5 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 20 Hz */
# define LSM9DS1_CTRL_REG1_M_DO_40HZ (6 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 40 Hz */
# define LSM9DS1_CTRL_REG1_M_DO_80HZ (7 << LSM9DS1_CTRL_REG1_M_DO_SHIFT) /* 80 Hz */
#define LSM9DS1_CTRL_REG1_M_OM_SHIFT 5 /* X and Y axes operative mode selection */
#define LSM9DS1_CTRL_REG1_M_OM_MASK (3 << LSM9DS1_CTRL_REG1_M_OM_SHIFT)
# define LSM9DS1_CTRL_REG1_M_OM_LOW (0 << LSM9DS1_CTRL_REG1_M_OM_SHIFT) /* Low-power mode */
# define LSM9DS1_CTRL_REG1_M_OM_MEDIUM (1 << LSM9DS1_CTRL_REG1_M_OM_SHIFT) /* Medium-performance mode */
# define LSM9DS1_CTRL_REG1_M_OM_HIGH (2 << LSM9DS1_CTRL_REG1_M_OM_SHIFT) /* High-performance mode */
# define LSM9DS1_CTRL_REG1_M_OM_ULTRAHIGH (3 << LSM9DS1_CTRL_REG1_M_OM_SHIFT) /* Ultra-high performance mode */
#define LSM9DS1_CTRL_REG1_M_TEMP_COMP (1 << 7) /* Temperature compensation enable */
/* Magnetometer control register 2 */
#define LSM9DS1_CTRL_REG2_M_SOFT_RST (1 << 2) /* Configuration register and user register reset */
#define LSM9DS1_CTRL_REG2_M_REBOOT (1 << 3) /* Reboot memory content */
#define LSM9DS1_CTRL_REG2_M_FS_SHIFT 5 /* Full-scale configuration */
#define LSM9DS1_CTRL_REG2_M_FS_MASK (3 << LSM9DS1_CTRL_REG2_M_FS_SHIFT)
# define LSM9DS1_CTRL_REG2_M_FS_4GAUSS (0 << LSM9DS1_CTRL_REG2_M_FS_SHIFT) /* +/- 4 gauss */
# define LSM9DS1_CTRL_REG2_M_FS_8GAUSS (1 << LSM9DS1_CTRL_REG2_M_FS_SHIFT) /* +/- 8 gauss */
# define LSM9DS1_CTRL_REG2_M_FS_12GAUSS (2 << LSM9DS1_CTRL_REG2_M_FS_SHIFT) /* +/- 12 gauss */
# define LSM9DS1_CTRL_REG2_M_FS_16GAUSS (3 << LSM9DS1_CTRL_REG2_M_FS_SHIFT) /* +/- 16 gauss */
/* Magnetometer control register 3 */
#define LSM9DS1_CTRL_REG3_M_MD_SHIFT 0 /* Operating mode selection */
#define LSM9DS1_CTRL_REG3_M_MD_MASK (3 << LSM9DS1_CTRL_REG3_M_MD_SHIFT)
# define LSM9DS1_CTRL_REG3_M_MD_CONT (0 << LSM9DS1_CTRL_REG3_M_MD_SHIFT) /* Continuous-conversion mode */
# define LSM9DS1_CTRL_REG3_M_MD_SINGLE (1 << LSM9DS1_CTRL_REG3_M_MD_SHIFT) /* Single-conversion mode */
# define LSM9DS1_CTRL_REG3_M_MD_POWERDOWN (2 << LSM9DS1_CTRL_REG3_M_MD_SHIFT) /* Power-down mode */
# define LSM9DS1_CTRL_REG3_M_MD_POWERDOWN2 (3 << LSM9DS1_CTRL_REG3_M_MD_SHIFT) /* Power-down mode */
#define LSM9DS1_CTRL_REG3_M_SIM (1 << 2) /* SPI serial interface mode selection */
#define LSM9DS1_CTRL_REG3_M_LP (1 << 5) /* Low-power mode configuration */
#define LSM9DS1_CTRL_REG3_M_I2C_DISABLE (1 << 7) /* Disable I2C interface */
/* Magnetometer control register 4 */
#define LSM9DS1_CTRL_REG4_M_BLE (1 << 1) /* Big/little endian data selection */
#define LSM9DS1_CTRL_REG4_M_OMZ_SHIFT 2 /* Z-axis operative mode selection */
#define LSM9DS1_CTRL_REG4_M_OMZ_MASK (3 << LSM9DS1_CTRL_REG4_M_OMZ_SHIFT)
# define LSM9DS1_CTRL_REG4_M_OMZ_LOW (0 << LSM9DS1_CTRL_REG4_M_OMZ_SHIFT) /* Low-power mode */
# define LSM9DS1_CTRL_REG4_M_OMZ_MEDIUM (1 << LSM9DS1_CTRL_REG4_M_OMZ_SHIFT) /* Medium-performance mode */
# define LSM9DS1_CTRL_REG4_M_OMZ_HIGH (2 << LSM9DS1_CTRL_REG4_M_OMZ_SHIFT) /* High-performance mode */
# define LSM9DS1_CTRL_REG4_M_OMZ_ULTRAHIGH (3 << LSM9DS1_CTRL_REG4_M_OMZ_SHIFT) /* Ultra-high performance mode */
/* Magnetometer control register 5 */
#define LSM9DS1_CTRL_REG5_M_BDU (1 << 6) /* Block data update */
#define LSM9DS1_CTRL_REG5_M_FAST_READ (1 << 7) /* Fast read enable */
/* Magnetometer status register */
#define LSM9DS1_STATUS_REG_M_XDA (1 << 0) /* X-axis new data available */
#define LSM9DS1_STATUS_REG_M_YDA (1 << 1) /* Y-axis new data available */
#define LSM9DS1_STATUS_REG_M_ZDA (1 << 2) /* Z-axis new data available */
#define LSM9DS1_STATUS_REG_M_ZYXDA (1 << 3) /* X, Y and Z-axis new data available */
#define LSM9DS1_STATUS_REG_M_XOR (1 << 4) /* X-axis data overrun */
#define LSM9DS1_STATUS_REG_M_YOR (1 << 5) /* Y-axis data overrun */
#define LSM9DS1_STATUS_REG_M_ZOR (1 << 6) /* Z-axis data overrun */
#define LSM9DS1_STATUS_REG_M_ZYXOR (1 << 7) /* X, Y and Z-axis data overrun */
/* Magnetometer interrupt configuration register */
#define LSM9DS1_INT_CFG_M_IEN (1 << 0) /* Interrupt enable on the INT_M pin */
#define LSM9DS1_INT_CFG_M_IEL (1 << 1) /* Latch interrupt request */
#define LSM9DS1_INT_CFG_M_IEA (1 << 2) /* Interrupt active configuration on INT_MAG */
#define LSM9DS1_INT_CFG_M_ZIEN (1 << 5) /* Z-axis interrupt enable */
#define LSM9DS1_INT_CFG_M_YIEN (1 << 6) /* Y-axis interrupt enable */
#define LSM9DS1_INT_CFG_M_XIEN (1 << 7) /* X-axis interrupt enable */
/* Magnetometer interrupt source register */
#define LSM9DS1_INT_SRC_M_INT (1 << 0) /* Interrupt occurred */
#define LSM9DS1_INT_SRC_M_MROI (1 << 1) /* Internal measurement range overflow */
#define LSM9DS1_INT_SRC_M_NTH_Z (1 << 2) /* Value on Z-axis exceeds threshold on negative side */
#define LSM9DS1_INT_SRC_M_NTH_Y (1 << 3) /* Value on Y-axis exceeds threshold on negative side */
#define LSM9DS1_INT_SRC_M_NTH_X (1 << 4) /* Value on X-axis exceeds threshold on negative side */
#define LSM9DS1_INT_SRC_M_PTH_Z (1 << 5) /* Value on Z-axis exceeds threshold on positive side */
#define LSM9DS1_INT_SRC_M_PTH_Y (1 << 6) /* Value on Y-axis exceeds threshold on positive side */
#define LSM9DS1_INT_SRC_M_PTH_X (1 << 7) /* Value on X-axis exceeds threshold on positive side */
/* Accelerometer and gyroscope Base address I2C */
#define LSM9DS1_I2C_BADD (uint8_t)0xd6
#define LSM9DS1_I2C_BADD_M (uint8_t)0x3c
#ifdef __cplusplus
extern "C" {
#endif
/* Exported Types -------------------------------------------------------------*/
/** @defgroup LSM9DS1_Exported_Types
* @{
*/
/**
* @brief Error type.
*/
typedef enum {
LSM9DS1_ERROR =0x00U,
LSM9DS1_OK = 0x01U, // Accelerometer, Gyroscope and Magnetometer connection are fine
LSM9DS1_XLG_ERROR=0x02U, //Accelerometer and gyroscope connection error
LSM9DS1_XLG_OK=0x03U,
LSM9DS1_M_ERROR= 0x04U, //Magnetometer connection error
LSM9DS1_M_OK=0x05U} LSM9DS1_State_Connection;
/**
* @brief Enable/Disable type.
*/
typedef enum {LSM9DS1_DISABLE = (uint8_t)0, LSM9DS1_ENABLE = !LSM9DS1_DISABLE} LSM9DS1_State_et;
#define IS_LSM9DS1_State(MODE) ((MODE == LSM9DS1_ENABLE) || (MODE == LSM9DS1_DISABLE) )
/**
* @brief Accelerometer start Success/Error type.
*/
typedef enum {
LSM9DS1_XL_START_ERROR = 0x00U,
LSM9DS1_XL_START_SUCCESS = 0x01U,
LSM9DS1_XL_START_ERROR_ODR = 0x02U,
LSM9DS1_XL_START_ERROR_FS = 0x03U,
} LSM9DS1_XL_START;
typedef enum {
LSM9DS1_XLG_START_ERROR = 0x00U,
LSM9DS1_XLG_START_SUCCESS = 0x01U,
LSM9DS1_XLG_START_ERROR_ODR = 0x02U,
LSM9DS1_XLG_START_ERROR_FS = 0x03U,
} LSM9DS1_XLG_START;
typedef enum {
LSM9DS1_XLGM_START_ERROR = 0x00U,
LSM9DS1_XLGM_START_SUCCESS = 0x01U,
LSM9DS1_XLGM_START_ERROR_ODR = 0x02U,
LSM9DS1_XLGM_START_ERROR_FS = 0x03U,
LSM9DS1_M_START_ERROR_ODR = 0x04U,
} LSM9DS1_XLGM_START;
/**
* @brief Accelerometer read Success/Error type.
*/
typedef enum {
LSM9DS1_XL_READ_ERROR = 0x00U,
LSM9DS1_XL_READ_SUCCESS = 0x01U,
} LSM9DS1_XL_READ;
/**
* @brief Gyrscope read Success/Error type.
*/
typedef enum {
LSM9DS1_G_READ_ERROR = 0x00U,
LSM9DS1_G_READ_SUCCESS = 0x01U,
} LSM9DS1_G_READ;
/**
* @brief Gyrscope read Success/Error type.
*/
typedef enum {
LSM9DS1_XLG_READ_ERROR = 0x00U,
LSM9DS1_XLG_READ_SUCCESS = 0x01U,
} LSM9DS1_XLG_READ;
/**
* @brief Accelerometer write Success/Error type.
*/
typedef enum {
LSM9DS1_MEM_WRITE_ERROR = 0x00U,
LSM9DS1_MEM_WRITE_SUCCESS = 0x01U,
} LSM9DS1_MEM_WRITE;
/**
* @brief I2C address.
*/
/*SDO/SA0 (pin5) is connected to GND*/
#define LPS25HB_BADDR ((uint8_t)0xB8)
/** @defgroup LPS25HB_Private_Variables
* @{
*/
static uint32_t I2C_Timeout = 0x10000;
/** @brief LSM9DS1_XL_SENSITIVITY Accelerometer sensitivity values based on selected full scale
* @{
*/
#define LSM9DS1_ACC_SENSITIVITY_FOR_FS_2G 0.061 /**< Sensitivity value for 2 g full scale [mg/LSB] */
#define LSM9DS1_ACC_SENSITIVITY_FOR_FS_4G 0.122 /**< Sensitivity value for 4 g full scale [mg/LSB] */
#define LSM9DS1_ACC_SENSITIVITY_FOR_FS_8G 0.244 /**< Sensitivity value for 8 g full scale [mg/LSB] */
#define LSM9DS1_ACC_SENSITIVITY_FOR_FS_16G 0.488 /**< Sensitivity value for 16 g full scale [mg/LSB] */
/** @addtogroup LSM9DS1_GYRO_SENSITIVITY Gyro sensitivity values based on selected full scale
* @{
*/
#define LSM9DS1_GYRO_SENSITIVITY_FOR_FS_245DPS 08.750 /**< Sensitivity value for 245 dps full scale [mdps/LSB] */
#define LSM9DS1_GYRO_SENSITIVITY_FOR_FS_500DPS 17.500 /**< Sensitivity value for 500 dps full scale [mdps/LSB] */
#define LSM9DS1_GYRO_SENSITIVITY_FOR_FS_2000DPS 70.000 /**< Sensitivity value for 2000 dps full scale [mdps/LSB] */
/** @addtogroup LSM9DS1_M_SENSITIVITY Magnetometer sensitivity values based on selected full scale
* @{
*/
#define LSM9DS1_M_SENSITIVITY_FOR_FS_4GAUSS 0.14 /**< Sensitivity value for 4 gauss full scale [mgauss/LSB] */
#define LSM9DS1_M_SENSITIVITY_FOR_FS_8GAUSS 0.29 /**< Sensitivity value for 8 dps full scale [mgauss/LSB] */
#define LSM9DS1_M_SENSITIVITY_FOR_FS_12GAUSS 0.43 /**< Sensitivity value for 12 dps full scale [magauss/LSB] */
#define LSM9DS1_M_SENSITIVITY_FOR_FS_16GAUSS 0.58 /**< Sensitivity value for 16 dps full scale [mgauss/LSB] */
/** @defgroup LSM9DS1_Private_Function_Prototypes
* @{
*/
static uint8_t I2C_ReadData(uint8_t B_Addr, uint8_t Reg, uint8_t* pBuffer, uint16_t Size);
static uint8_t I2C_WriteData(uint8_t B_Addr, uint8_t Reg, uint8_t* pBuffer, uint16_t Size);
static uint32_t lsm9ds1_midpoint(uint32_t a, uint32_t b);
/** @defgroup LSM9DS1_Private_Accelerometer_Function_Prototypes
* @{
*/
static int LSM9DS1_XL_SetOdr(int odr);
static int LSM9DS1_XL_SetFs(int fullscale);
static int LSM9SD1_SetFIFO();
static LSM9DS1_MEM_WRITE LSM9DS1_modifyReg8(uint8_t B_Addr,uint8_t Reg, uint8_t pBuffer, uint8_t mask);
uint8_t LSM9DS1_get_Odr_XL();
uint8_t LSM9DS1_get_Odr_G();
uint8_t LSM9DS1_get_Fs_XL();
uint8_t LSM9DS1_get_Fs_G();
double LSM9DS1_get_Sens_XL();
double LSM9DS1_get_Sens_G();
LSM9DS1_State_Connection LSM9DS1_IsConnected();
void LSM9DS1_XLG_TurnOff();
LSM9DS1_XL_START LSM9DS1_XL_Start(int odr, int fs);
LSM9DS1_XLG_START LSM9DS1_XLG_Start(int odr, int fsG, int fsXl );
LSM9DS1_XLGM_START LSM9DS1_XLGM_Start(int odr,int odrM, int fsG, int fsXl, int fsM);
struct SensorXLAxes_t{
double axis_x;
double axis_y;
double axis_z;
};
struct SensorGAxes_t{
double axis_x;
double axis_y;
double axis_z;
};
LSM9DS1_XL_READ LSM9DS1_Read_XL(struct SensorXLAxes_t *acceleration,int samples);
LSM9DS1_XLG_READ LSM9DS1_Read_XLG(MFX_input_t *data_in, int samples);
void gotBackCursor();