-
Notifications
You must be signed in to change notification settings - Fork 0
/
LSM9DS1_Types.h
252 lines (222 loc) · 5.39 KB
/
LSM9DS1_Types.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
/******************************************************************************
LSM9DS1_Types.h
SFE_LSM9DS1 Library - LSM9DS1 Types and Enumerations
Jim Lindblom @ SparkFun Electronics
Original Creation Date: April 21, 2015
https://github.com/sparkfun/LSM9DS1_Breakout
This file defines all types and enumerations used by the LSM9DS1 class.
Development environment specifics:
IDE: Arduino 1.6.0
Hardware Platform: Arduino Uno
LSM9DS1 Breakout Version: 1.0
This code is beerware; if you see me (or any other SparkFun employee) at the
local, and you've found our code helpful, please buy us a round!
Distributed as-is; no warranty is given.
******************************************************************************/
#ifndef __LSM9DS1_Types_H__
#define __LSM9DS1_Types_H__
#include "LSM9DS1_Registers.h"
#include <Wire.h>
// The LSM9DS1 functions over both I2C or SPI. This library supports both.
// But the interface mode used must be sent to the LSM9DS1 constructor. Use
// one of these two as the first parameter of the constructor.
enum interface_mode
{
IMU_MODE_SPI,
IMU_MODE_I2C,
};
// accel_scale defines all possible FSR's of the accelerometer:
enum accel_scale
{
A_SCALE_2G, // 00: 2g
A_SCALE_16G, // 01: 16g
A_SCALE_4G, // 10: 4g
A_SCALE_8G // 11: 8g
};
// gyro_scale defines the possible full-scale ranges of the gyroscope:
enum gyro_scale
{
G_SCALE_245DPS, // 00: 245 degrees per second
G_SCALE_500DPS, // 01: 500 dps
G_SCALE_2000DPS, // 11: 2000 dps
};
// mag_scale defines all possible FSR's of the magnetometer:
enum mag_scale
{
M_SCALE_4GS, // 00: 4Gs
M_SCALE_8GS, // 01: 8Gs
M_SCALE_12GS, // 10: 12Gs
M_SCALE_16GS, // 11: 16Gs
};
// gyro_odr defines all possible data rate/bandwidth combos of the gyro:
enum gyro_odr
{
//! TODO
G_ODR_PD, // Power down (0)
G_ODR_149, // 14.9 Hz (1)
G_ODR_595, // 59.5 Hz (2)
G_ODR_119, // 119 Hz (3)
G_ODR_238, // 238 Hz (4)
G_ODR_476, // 476 Hz (5)
G_ODR_952 // 952 Hz (6)
};
// accel_oder defines all possible output data rates of the accelerometer:
enum accel_odr
{
XL_POWER_DOWN, // Power-down mode (0x0)
XL_ODR_10, // 10 Hz (0x1)
XL_ODR_50, // 50 Hz (0x02)
XL_ODR_119, // 119 Hz (0x3)
XL_ODR_238, // 238 Hz (0x4)
XL_ODR_476, // 476 Hz (0x5)
XL_ODR_952 // 952 Hz (0x6)
};
// accel_abw defines all possible anti-aliasing filter rates of the accelerometer:
enum accel_abw
{
A_ABW_408, // 408 Hz (0x0)
A_ABW_211, // 211 Hz (0x1)
A_ABW_105, // 105 Hz (0x2)
A_ABW_50, // 50 Hz (0x3)
};
// mag_odr defines all possible output data rates of the magnetometer:
enum mag_odr
{
M_ODR_0625, // 0.625 Hz (0)
M_ODR_125, // 1.25 Hz (1)
M_ODR_250, // 2.5 Hz (2)
M_ODR_5, // 5 Hz (3)
M_ODR_10, // 10 Hz (4)
M_ODR_20, // 20 Hz (5)
M_ODR_40, // 40 Hz (6)
M_ODR_80 // 80 Hz (7)
};
enum interrupt_select
{
XG_INT1 = INT1_CTRL,
XG_INT2 = INT2_CTRL
};
enum interrupt_generators
{
INT_DRDY_XL = (1 << 0), // Accelerometer data ready (INT1 & INT2)
INT_DRDY_G = (1 << 1), // Gyroscope data ready (INT1 & INT2)
INT1_BOOT = (1 << 2), // Boot status (INT1)
INT2_DRDY_TEMP = (1 << 2), // Temp data ready (INT2)
INT_FTH = (1 << 3), // FIFO threshold interrupt (INT1 & INT2)
INT_OVR = (1 << 4), // Overrun interrupt (INT1 & INT2)
INT_FSS5 = (1 << 5), // FSS5 interrupt (INT1 & INT2)
INT_IG_XL = (1 << 6), // Accel interrupt generator (INT1)
INT1_IG_G = (1 << 7), // Gyro interrupt enable (INT1)
INT2_INACT = (1 << 7), // Inactivity interrupt output (INT2)
};
enum accel_interrupt_generator
{
XLIE_XL = (1 << 0),
XHIE_XL = (1 << 1),
YLIE_XL = (1 << 2),
YHIE_XL = (1 << 3),
ZLIE_XL = (1 << 4),
ZHIE_XL = (1 << 5),
GEN_6D = (1 << 6)
};
enum gyro_interrupt_generator
{
XLIE_G = (1 << 0),
XHIE_G = (1 << 1),
YLIE_G = (1 << 2),
YHIE_G = (1 << 3),
ZLIE_G = (1 << 4),
ZHIE_G = (1 << 5)
};
enum mag_interrupt_generator
{
ZIEN = (1 << 5),
YIEN = (1 << 6),
XIEN = (1 << 7)
};
enum h_lactive
{
INT_ACTIVE_HIGH,
INT_ACTIVE_LOW
};
enum pp_od
{
INT_PUSH_PULL,
INT_OPEN_DRAIN
};
enum fifoMode_type
{
FIFO_OFF = 0,
FIFO_THS = 1,
FIFO_CONT_TRIGGER = 3,
FIFO_OFF_TRIGGER = 4,
FIFO_CONT = 6
};
struct gyroSettings
{
// Gyroscope settings:
uint8_t enabled;
uint16_t scale; // Changed this to 16-bit
uint8_t sampleRate;
// New gyro stuff:
uint8_t bandwidth;
uint8_t lowPowerEnable;
uint8_t HPFEnable;
uint8_t HPFCutoff;
uint8_t flipX;
uint8_t flipY;
uint8_t flipZ;
uint8_t orientation;
uint8_t enableX;
uint8_t enableY;
uint8_t enableZ;
uint8_t latchInterrupt;
};
struct deviceSettings
{
uint8_t commInterface; // Can be I2C, SPI 4-wire or SPI 3-wire
uint8_t agAddress; // I2C address or SPI CS pin
uint8_t mAddress; // I2C address or SPI CS pin
TwoWire* i2c; // pointer to an instance of I2C interface
};
struct accelSettings
{
// Accelerometer settings:
uint8_t enabled;
uint8_t scale;
uint8_t sampleRate;
// New accel stuff:
uint8_t enableX;
uint8_t enableY;
uint8_t enableZ;
int8_t bandwidth;
uint8_t highResEnable;
uint8_t highResBandwidth;
};
struct magSettings
{
// Magnetometer settings:
uint8_t enabled;
uint8_t scale;
uint8_t sampleRate;
// New mag stuff:
uint8_t tempCompensationEnable;
uint8_t XYPerformance;
uint8_t ZPerformance;
uint8_t lowPowerEnable;
uint8_t operatingMode;
};
struct temperatureSettings
{
// Temperature settings
uint8_t enabled;
};
struct IMUSettings
{
deviceSettings device;
gyroSettings gyro;
accelSettings accel;
magSettings mag;
temperatureSettings temp;
};
#endif