Revision 463eabf7 Adafruit_BNO055.h
Adafruit_BNO055.h | ||
---|---|---|
15 | 15 |
Written by KTOWN for Adafruit Industries. |
16 | 16 |
|
17 | 17 |
MIT license, all text above must be included in any redistribution |
18 |
***************************************************************************/
|
|
18 |
***************************************************************************/ |
|
19 | 19 |
|
20 | 20 |
#ifndef __ADAFRUIT_BNO055_H__ |
21 | 21 |
#define __ADAFRUIT_BNO055_H__ |
22 | 22 |
|
23 | 23 |
#if (ARDUINO >= 100) |
24 |
#include "Arduino.h" |
|
24 |
#include "Arduino.h"
|
|
25 | 25 |
#else |
26 |
#include "WProgram.h" |
|
26 |
#include "WProgram.h"
|
|
27 | 27 |
#endif |
28 | 28 |
|
29 | 29 |
#ifdef __AVR_ATtiny85__ |
30 |
#include <TinyWireM.h> |
|
31 |
#define Wire TinyWireM |
|
30 |
#include <TinyWireM.h>
|
|
31 |
#define Wire TinyWireM
|
|
32 | 32 |
#else |
33 |
#include <Wire.h> |
|
33 |
#include <Wire.h>
|
|
34 | 34 |
#endif |
35 | 35 |
|
36 | 36 |
#include <Adafruit_Sensor.h> |
... | ... | |
44 | 44 |
|
45 | 45 |
typedef struct |
46 | 46 |
{ |
47 |
uint16_t accel_offset_x;
|
|
48 |
uint16_t accel_offset_y;
|
|
49 |
uint16_t accel_offset_z;
|
|
50 |
uint16_t gyro_offset_x;
|
|
51 |
uint16_t gyro_offset_y;
|
|
52 |
uint16_t gyro_offset_z;
|
|
53 |
uint16_t mag_offset_x;
|
|
54 |
uint16_t mag_offset_y;
|
|
55 |
uint16_t mag_offset_z;
|
|
56 |
|
|
57 |
uint16_t accel_radius;
|
|
58 |
uint16_t mag_radius;
|
|
47 |
uint16_t accel_offset_x;
|
|
48 |
uint16_t accel_offset_y;
|
|
49 |
uint16_t accel_offset_z;
|
|
50 |
uint16_t gyro_offset_x;
|
|
51 |
uint16_t gyro_offset_y;
|
|
52 |
uint16_t gyro_offset_z;
|
|
53 |
uint16_t mag_offset_x;
|
|
54 |
uint16_t mag_offset_y;
|
|
55 |
uint16_t mag_offset_z;
|
|
56 |
|
|
57 |
uint16_t accel_radius;
|
|
58 |
uint16_t mag_radius;
|
|
59 | 59 |
} adafruit_bno055_offsets_t; |
60 | 60 |
|
61 | 61 |
class Adafruit_BNO055 : public Adafruit_Sensor |
62 | 62 |
{ |
63 |
public: |
|
64 |
typedef enum |
|
65 |
{ |
|
66 |
/* Page id register definition */ |
|
67 |
BNO055_PAGE_ID_ADDR = 0X07, |
|
68 |
|
|
69 |
/* PAGE0 REGISTER DEFINITION START*/ |
|
70 |
BNO055_CHIP_ID_ADDR = 0x00, |
|
71 |
BNO055_ACCEL_REV_ID_ADDR = 0x01, |
|
72 |
BNO055_MAG_REV_ID_ADDR = 0x02, |
|
73 |
BNO055_GYRO_REV_ID_ADDR = 0x03, |
|
74 |
BNO055_SW_REV_ID_LSB_ADDR = 0x04, |
|
75 |
BNO055_SW_REV_ID_MSB_ADDR = 0x05, |
|
76 |
BNO055_BL_REV_ID_ADDR = 0X06, |
|
77 |
|
|
78 |
/* Accel data register */ |
|
79 |
BNO055_ACCEL_DATA_X_LSB_ADDR = 0X08, |
|
80 |
BNO055_ACCEL_DATA_X_MSB_ADDR = 0X09, |
|
81 |
BNO055_ACCEL_DATA_Y_LSB_ADDR = 0X0A, |
|
82 |
BNO055_ACCEL_DATA_Y_MSB_ADDR = 0X0B, |
|
83 |
BNO055_ACCEL_DATA_Z_LSB_ADDR = 0X0C, |
|
84 |
BNO055_ACCEL_DATA_Z_MSB_ADDR = 0X0D, |
|
85 |
|
|
86 |
/* Mag data register */ |
|
87 |
BNO055_MAG_DATA_X_LSB_ADDR = 0X0E, |
|
88 |
BNO055_MAG_DATA_X_MSB_ADDR = 0X0F, |
|
89 |
BNO055_MAG_DATA_Y_LSB_ADDR = 0X10, |
|
90 |
BNO055_MAG_DATA_Y_MSB_ADDR = 0X11, |
|
91 |
BNO055_MAG_DATA_Z_LSB_ADDR = 0X12, |
|
92 |
BNO055_MAG_DATA_Z_MSB_ADDR = 0X13, |
|
93 |
|
|
94 |
/* Gyro data registers */ |
|
95 |
BNO055_GYRO_DATA_X_LSB_ADDR = 0X14, |
|
96 |
BNO055_GYRO_DATA_X_MSB_ADDR = 0X15, |
|
97 |
BNO055_GYRO_DATA_Y_LSB_ADDR = 0X16, |
|
98 |
BNO055_GYRO_DATA_Y_MSB_ADDR = 0X17, |
|
99 |
BNO055_GYRO_DATA_Z_LSB_ADDR = 0X18, |
|
100 |
BNO055_GYRO_DATA_Z_MSB_ADDR = 0X19, |
|
101 |
|
|
102 |
/* Euler data registers */ |
|
103 |
BNO055_EULER_H_LSB_ADDR = 0X1A, |
|
104 |
BNO055_EULER_H_MSB_ADDR = 0X1B, |
|
105 |
BNO055_EULER_R_LSB_ADDR = 0X1C, |
|
106 |
BNO055_EULER_R_MSB_ADDR = 0X1D, |
|
107 |
BNO055_EULER_P_LSB_ADDR = 0X1E, |
|
108 |
BNO055_EULER_P_MSB_ADDR = 0X1F, |
|
109 |
|
|
110 |
/* Quaternion data registers */ |
|
111 |
BNO055_QUATERNION_DATA_W_LSB_ADDR = 0X20, |
|
112 |
BNO055_QUATERNION_DATA_W_MSB_ADDR = 0X21, |
|
113 |
BNO055_QUATERNION_DATA_X_LSB_ADDR = 0X22, |
|
114 |
BNO055_QUATERNION_DATA_X_MSB_ADDR = 0X23, |
|
115 |
BNO055_QUATERNION_DATA_Y_LSB_ADDR = 0X24, |
|
116 |
BNO055_QUATERNION_DATA_Y_MSB_ADDR = 0X25, |
|
117 |
BNO055_QUATERNION_DATA_Z_LSB_ADDR = 0X26, |
|
118 |
BNO055_QUATERNION_DATA_Z_MSB_ADDR = 0X27, |
|
119 |
|
|
120 |
/* Linear acceleration data registers */ |
|
121 |
BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR = 0X28, |
|
122 |
BNO055_LINEAR_ACCEL_DATA_X_MSB_ADDR = 0X29, |
|
123 |
BNO055_LINEAR_ACCEL_DATA_Y_LSB_ADDR = 0X2A, |
|
124 |
BNO055_LINEAR_ACCEL_DATA_Y_MSB_ADDR = 0X2B, |
|
125 |
BNO055_LINEAR_ACCEL_DATA_Z_LSB_ADDR = 0X2C, |
|
126 |
BNO055_LINEAR_ACCEL_DATA_Z_MSB_ADDR = 0X2D, |
|
127 |
|
|
128 |
/* Gravity data registers */ |
|
129 |
BNO055_GRAVITY_DATA_X_LSB_ADDR = 0X2E, |
|
130 |
BNO055_GRAVITY_DATA_X_MSB_ADDR = 0X2F, |
|
131 |
BNO055_GRAVITY_DATA_Y_LSB_ADDR = 0X30, |
|
132 |
BNO055_GRAVITY_DATA_Y_MSB_ADDR = 0X31, |
|
133 |
BNO055_GRAVITY_DATA_Z_LSB_ADDR = 0X32, |
|
134 |
BNO055_GRAVITY_DATA_Z_MSB_ADDR = 0X33, |
|
135 |
|
|
136 |
/* Temperature data register */ |
|
137 |
BNO055_TEMP_ADDR = 0X34, |
|
138 |
|
|
139 |
/* Status registers */ |
|
140 |
BNO055_CALIB_STAT_ADDR = 0X35, |
|
141 |
BNO055_SELFTEST_RESULT_ADDR = 0X36, |
|
142 |
BNO055_INTR_STAT_ADDR = 0X37, |
|
143 |
|
|
144 |
BNO055_SYS_CLK_STAT_ADDR = 0X38, |
|
145 |
BNO055_SYS_STAT_ADDR = 0X39, |
|
146 |
BNO055_SYS_ERR_ADDR = 0X3A, |
|
147 |
|
|
148 |
/* Unit selection register */ |
|
149 |
BNO055_UNIT_SEL_ADDR = 0X3B, |
|
150 |
BNO055_DATA_SELECT_ADDR = 0X3C, |
|
151 |
|
|
152 |
/* Mode registers */ |
|
153 |
BNO055_OPR_MODE_ADDR = 0X3D, |
|
154 |
BNO055_PWR_MODE_ADDR = 0X3E, |
|
155 |
|
|
156 |
BNO055_SYS_TRIGGER_ADDR = 0X3F, |
|
157 |
BNO055_TEMP_SOURCE_ADDR = 0X40, |
|
158 |
|
|
159 |
/* Axis remap registers */ |
|
160 |
BNO055_AXIS_MAP_CONFIG_ADDR = 0X41, |
|
161 |
BNO055_AXIS_MAP_SIGN_ADDR = 0X42, |
|
162 |
|
|
163 |
/* SIC registers */ |
|
164 |
BNO055_SIC_MATRIX_0_LSB_ADDR = 0X43, |
|
165 |
BNO055_SIC_MATRIX_0_MSB_ADDR = 0X44, |
|
166 |
BNO055_SIC_MATRIX_1_LSB_ADDR = 0X45, |
|
167 |
BNO055_SIC_MATRIX_1_MSB_ADDR = 0X46, |
|
168 |
BNO055_SIC_MATRIX_2_LSB_ADDR = 0X47, |
|
169 |
BNO055_SIC_MATRIX_2_MSB_ADDR = 0X48, |
|
170 |
BNO055_SIC_MATRIX_3_LSB_ADDR = 0X49, |
|
171 |
BNO055_SIC_MATRIX_3_MSB_ADDR = 0X4A, |
|
172 |
BNO055_SIC_MATRIX_4_LSB_ADDR = 0X4B, |
|
173 |
BNO055_SIC_MATRIX_4_MSB_ADDR = 0X4C, |
|
174 |
BNO055_SIC_MATRIX_5_LSB_ADDR = 0X4D, |
|
175 |
BNO055_SIC_MATRIX_5_MSB_ADDR = 0X4E, |
|
176 |
BNO055_SIC_MATRIX_6_LSB_ADDR = 0X4F, |
|
177 |
BNO055_SIC_MATRIX_6_MSB_ADDR = 0X50, |
|
178 |
BNO055_SIC_MATRIX_7_LSB_ADDR = 0X51, |
|
179 |
BNO055_SIC_MATRIX_7_MSB_ADDR = 0X52, |
|
180 |
BNO055_SIC_MATRIX_8_LSB_ADDR = 0X53, |
|
181 |
BNO055_SIC_MATRIX_8_MSB_ADDR = 0X54, |
|
182 |
|
|
183 |
/* Accelerometer Offset registers */ |
|
184 |
ACCEL_OFFSET_X_LSB_ADDR = 0X55, |
|
185 |
ACCEL_OFFSET_X_MSB_ADDR = 0X56, |
|
186 |
ACCEL_OFFSET_Y_LSB_ADDR = 0X57, |
|
187 |
ACCEL_OFFSET_Y_MSB_ADDR = 0X58, |
|
188 |
ACCEL_OFFSET_Z_LSB_ADDR = 0X59, |
|
189 |
ACCEL_OFFSET_Z_MSB_ADDR = 0X5A, |
|
190 |
|
|
191 |
/* Magnetometer Offset registers */ |
|
192 |
MAG_OFFSET_X_LSB_ADDR = 0X5B, |
|
193 |
MAG_OFFSET_X_MSB_ADDR = 0X5C, |
|
194 |
MAG_OFFSET_Y_LSB_ADDR = 0X5D, |
|
195 |
MAG_OFFSET_Y_MSB_ADDR = 0X5E, |
|
196 |
MAG_OFFSET_Z_LSB_ADDR = 0X5F, |
|
197 |
MAG_OFFSET_Z_MSB_ADDR = 0X60, |
|
198 |
|
|
199 |
/* Gyroscope Offset register s*/ |
|
200 |
GYRO_OFFSET_X_LSB_ADDR = 0X61, |
|
201 |
GYRO_OFFSET_X_MSB_ADDR = 0X62, |
|
202 |
GYRO_OFFSET_Y_LSB_ADDR = 0X63, |
|
203 |
GYRO_OFFSET_Y_MSB_ADDR = 0X64, |
|
204 |
GYRO_OFFSET_Z_LSB_ADDR = 0X65, |
|
205 |
GYRO_OFFSET_Z_MSB_ADDR = 0X66, |
|
206 |
|
|
207 |
/* Radius registers */ |
|
208 |
ACCEL_RADIUS_LSB_ADDR = 0X67, |
|
209 |
ACCEL_RADIUS_MSB_ADDR = 0X68, |
|
210 |
MAG_RADIUS_LSB_ADDR = 0X69, |
|
211 |
MAG_RADIUS_MSB_ADDR = 0X6A |
|
212 |
} adafruit_bno055_reg_t; |
|
213 |
|
|
214 |
typedef enum |
|
215 |
{ |
|
216 |
POWER_MODE_NORMAL = 0X00, |
|
217 |
POWER_MODE_LOWPOWER = 0X01, |
|
218 |
POWER_MODE_SUSPEND = 0X02 |
|
219 |
} adafruit_bno055_powermode_t; |
|
220 |
|
|
221 |
typedef enum |
|
222 |
{ |
|
223 |
/* Operation mode settings*/ |
|
224 |
OPERATION_MODE_CONFIG = 0X00, |
|
225 |
OPERATION_MODE_ACCONLY = 0X01, |
|
226 |
OPERATION_MODE_MAGONLY = 0X02, |
|
227 |
OPERATION_MODE_GYRONLY = 0X03, |
|
228 |
OPERATION_MODE_ACCMAG = 0X04, |
|
229 |
OPERATION_MODE_ACCGYRO = 0X05, |
|
230 |
OPERATION_MODE_MAGGYRO = 0X06, |
|
231 |
OPERATION_MODE_AMG = 0X07, |
|
232 |
OPERATION_MODE_IMUPLUS = 0X08, |
|
233 |
OPERATION_MODE_COMPASS = 0X09, |
|
234 |
OPERATION_MODE_M4G = 0X0A, |
|
235 |
OPERATION_MODE_NDOF_FMC_OFF = 0X0B, |
|
236 |
OPERATION_MODE_NDOF = 0X0C |
|
237 |
} adafruit_bno055_opmode_t; |
|
238 |
|
|
239 |
typedef struct |
|
240 |
{ |
|
241 |
uint8_t accel_rev; |
|
242 |
uint8_t mag_rev; |
|
243 |
uint8_t gyro_rev; |
|
244 |
uint16_t sw_rev; |
|
245 |
uint8_t bl_rev; |
|
246 |
} adafruit_bno055_rev_info_t; |
|
247 |
|
|
248 |
typedef enum |
|
249 |
{ |
|
250 |
VECTOR_ACCELEROMETER = BNO055_ACCEL_DATA_X_LSB_ADDR, |
|
251 |
VECTOR_MAGNETOMETER = BNO055_MAG_DATA_X_LSB_ADDR, |
|
252 |
VECTOR_GYROSCOPE = BNO055_GYRO_DATA_X_LSB_ADDR, |
|
253 |
VECTOR_EULER = BNO055_EULER_H_LSB_ADDR, |
|
254 |
VECTOR_LINEARACCEL = BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR, |
|
255 |
VECTOR_GRAVITY = BNO055_GRAVITY_DATA_X_LSB_ADDR |
|
256 |
} adafruit_vector_type_t; |
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
Adafruit_BNO055(int32_t sensorID = -1, uint8_t address = BNO055_ADDRESS_A); |
|
261 |
|
|
262 |
bool begin(adafruit_bno055_opmode_t mode = OPERATION_MODE_NDOF); |
|
263 |
void setMode(adafruit_bno055_opmode_t mode); |
|
264 |
void getRevInfo(adafruit_bno055_rev_info_t*); |
|
265 |
void displayRevInfo(void); |
|
266 |
void setExtCrystalUse(boolean usextal); |
|
267 |
void getSystemStatus(uint8_t *system_status, |
|
268 |
uint8_t *self_test_result, |
|
269 |
uint8_t *system_error); |
|
270 |
void displaySystemStatus(void); |
|
271 |
void getCalibration(uint8_t* system, uint8_t* gyro, uint8_t* accel, uint8_t* mag); |
|
272 |
|
|
273 |
imu::Vector<3> getVector(adafruit_vector_type_t vector_type); |
|
274 |
imu::Quaternion getQuat(void); |
|
275 |
int8_t getTemp(void); |
|
276 |
|
|
277 |
/* Adafruit_Sensor implementation */ |
|
278 |
bool getEvent(sensors_event_t*); |
|
279 |
void getSensor(sensor_t*); |
|
280 |
|
|
281 |
/* Functions to deal with raw calibration data */ |
|
282 |
bool getSensorOffsets(uint8_t* calibData); |
|
283 |
bool getSensorOffsets(adafruit_bno055_offsets_t &offsets_type); |
|
284 |
void setSensorOffsets(const uint8_t* calibData); |
|
285 |
void setSensorOffsets(const adafruit_bno055_offsets_t &offsets_type); |
|
286 |
bool isFullyCalibrated(void); |
|
287 |
|
|
288 |
private: |
|
289 |
byte read8(adafruit_bno055_reg_t); |
|
290 |
bool readLen(adafruit_bno055_reg_t, byte* buffer, uint8_t len); |
|
291 |
bool write8(adafruit_bno055_reg_t, byte value); |
|
292 |
|
|
293 |
uint8_t _address; |
|
294 |
int32_t _sensorID; |
|
295 |
adafruit_bno055_opmode_t _mode; |
|
63 |
public: |
|
64 |
typedef enum |
|
65 |
{ |
|
66 |
/* Page id register definition */ |
|
67 |
BNO055_PAGE_ID_ADDR = 0X07, |
|
68 |
|
|
69 |
/* PAGE0 REGISTER DEFINITION START*/ |
|
70 |
BNO055_CHIP_ID_ADDR = 0x00, |
|
71 |
BNO055_ACCEL_REV_ID_ADDR = 0x01, |
|
72 |
BNO055_MAG_REV_ID_ADDR = 0x02, |
|
73 |
BNO055_GYRO_REV_ID_ADDR = 0x03, |
|
74 |
BNO055_SW_REV_ID_LSB_ADDR = 0x04, |
|
75 |
BNO055_SW_REV_ID_MSB_ADDR = 0x05, |
|
76 |
BNO055_BL_REV_ID_ADDR = 0X06, |
|
77 |
|
|
78 |
/* Accel data register */ |
|
79 |
BNO055_ACCEL_DATA_X_LSB_ADDR = 0X08, |
|
80 |
BNO055_ACCEL_DATA_X_MSB_ADDR = 0X09, |
|
81 |
BNO055_ACCEL_DATA_Y_LSB_ADDR = 0X0A, |
|
82 |
BNO055_ACCEL_DATA_Y_MSB_ADDR = 0X0B, |
|
83 |
BNO055_ACCEL_DATA_Z_LSB_ADDR = 0X0C, |
|
84 |
BNO055_ACCEL_DATA_Z_MSB_ADDR = 0X0D, |
|
85 |
|
|
86 |
/* Mag data register */ |
|
87 |
BNO055_MAG_DATA_X_LSB_ADDR = 0X0E, |
|
88 |
BNO055_MAG_DATA_X_MSB_ADDR = 0X0F, |
|
89 |
BNO055_MAG_DATA_Y_LSB_ADDR = 0X10, |
|
90 |
BNO055_MAG_DATA_Y_MSB_ADDR = 0X11, |
|
91 |
BNO055_MAG_DATA_Z_LSB_ADDR = 0X12, |
|
92 |
BNO055_MAG_DATA_Z_MSB_ADDR = 0X13, |
|
93 |
|
|
94 |
/* Gyro data registers */ |
|
95 |
BNO055_GYRO_DATA_X_LSB_ADDR = 0X14, |
|
96 |
BNO055_GYRO_DATA_X_MSB_ADDR = 0X15, |
|
97 |
BNO055_GYRO_DATA_Y_LSB_ADDR = 0X16, |
|
98 |
BNO055_GYRO_DATA_Y_MSB_ADDR = 0X17, |
|
99 |
BNO055_GYRO_DATA_Z_LSB_ADDR = 0X18, |
|
100 |
BNO055_GYRO_DATA_Z_MSB_ADDR = 0X19, |
|
101 |
|
|
102 |
/* Euler data registers */ |
|
103 |
BNO055_EULER_H_LSB_ADDR = 0X1A, |
|
104 |
BNO055_EULER_H_MSB_ADDR = 0X1B, |
|
105 |
BNO055_EULER_R_LSB_ADDR = 0X1C, |
|
106 |
BNO055_EULER_R_MSB_ADDR = 0X1D, |
|
107 |
BNO055_EULER_P_LSB_ADDR = 0X1E, |
|
108 |
BNO055_EULER_P_MSB_ADDR = 0X1F, |
|
109 |
|
|
110 |
/* Quaternion data registers */ |
|
111 |
BNO055_QUATERNION_DATA_W_LSB_ADDR = 0X20, |
|
112 |
BNO055_QUATERNION_DATA_W_MSB_ADDR = 0X21, |
|
113 |
BNO055_QUATERNION_DATA_X_LSB_ADDR = 0X22, |
|
114 |
BNO055_QUATERNION_DATA_X_MSB_ADDR = 0X23, |
|
115 |
BNO055_QUATERNION_DATA_Y_LSB_ADDR = 0X24, |
|
116 |
BNO055_QUATERNION_DATA_Y_MSB_ADDR = 0X25, |
|
117 |
BNO055_QUATERNION_DATA_Z_LSB_ADDR = 0X26, |
|
118 |
BNO055_QUATERNION_DATA_Z_MSB_ADDR = 0X27, |
|
119 |
|
|
120 |
/* Linear acceleration data registers */ |
|
121 |
BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR = 0X28, |
|
122 |
BNO055_LINEAR_ACCEL_DATA_X_MSB_ADDR = 0X29, |
|
123 |
BNO055_LINEAR_ACCEL_DATA_Y_LSB_ADDR = 0X2A, |
|
124 |
BNO055_LINEAR_ACCEL_DATA_Y_MSB_ADDR = 0X2B, |
|
125 |
BNO055_LINEAR_ACCEL_DATA_Z_LSB_ADDR = 0X2C, |
|
126 |
BNO055_LINEAR_ACCEL_DATA_Z_MSB_ADDR = 0X2D, |
|
127 |
|
|
128 |
/* Gravity data registers */ |
|
129 |
BNO055_GRAVITY_DATA_X_LSB_ADDR = 0X2E, |
|
130 |
BNO055_GRAVITY_DATA_X_MSB_ADDR = 0X2F, |
|
131 |
BNO055_GRAVITY_DATA_Y_LSB_ADDR = 0X30, |
|
132 |
BNO055_GRAVITY_DATA_Y_MSB_ADDR = 0X31, |
|
133 |
BNO055_GRAVITY_DATA_Z_LSB_ADDR = 0X32, |
|
134 |
BNO055_GRAVITY_DATA_Z_MSB_ADDR = 0X33, |
|
135 |
|
|
136 |
/* Temperature data register */ |
|
137 |
BNO055_TEMP_ADDR = 0X34, |
|
138 |
|
|
139 |
/* Status registers */ |
|
140 |
BNO055_CALIB_STAT_ADDR = 0X35, |
|
141 |
BNO055_SELFTEST_RESULT_ADDR = 0X36, |
|
142 |
BNO055_INTR_STAT_ADDR = 0X37, |
|
143 |
|
|
144 |
BNO055_SYS_CLK_STAT_ADDR = 0X38, |
|
145 |
BNO055_SYS_STAT_ADDR = 0X39, |
|
146 |
BNO055_SYS_ERR_ADDR = 0X3A, |
|
147 |
|
|
148 |
/* Unit selection register */ |
|
149 |
BNO055_UNIT_SEL_ADDR = 0X3B, |
|
150 |
BNO055_DATA_SELECT_ADDR = 0X3C, |
|
151 |
|
|
152 |
/* Mode registers */ |
|
153 |
BNO055_OPR_MODE_ADDR = 0X3D, |
|
154 |
BNO055_PWR_MODE_ADDR = 0X3E, |
|
155 |
|
|
156 |
BNO055_SYS_TRIGGER_ADDR = 0X3F, |
|
157 |
BNO055_TEMP_SOURCE_ADDR = 0X40, |
|
158 |
|
|
159 |
/* Axis remap registers */ |
|
160 |
BNO055_AXIS_MAP_CONFIG_ADDR = 0X41, |
|
161 |
BNO055_AXIS_MAP_SIGN_ADDR = 0X42, |
|
162 |
|
|
163 |
/* SIC registers */ |
|
164 |
BNO055_SIC_MATRIX_0_LSB_ADDR = 0X43, |
|
165 |
BNO055_SIC_MATRIX_0_MSB_ADDR = 0X44, |
|
166 |
BNO055_SIC_MATRIX_1_LSB_ADDR = 0X45, |
|
167 |
BNO055_SIC_MATRIX_1_MSB_ADDR = 0X46, |
|
168 |
BNO055_SIC_MATRIX_2_LSB_ADDR = 0X47, |
|
169 |
BNO055_SIC_MATRIX_2_MSB_ADDR = 0X48, |
|
170 |
BNO055_SIC_MATRIX_3_LSB_ADDR = 0X49, |
|
171 |
BNO055_SIC_MATRIX_3_MSB_ADDR = 0X4A, |
|
172 |
BNO055_SIC_MATRIX_4_LSB_ADDR = 0X4B, |
|
173 |
BNO055_SIC_MATRIX_4_MSB_ADDR = 0X4C, |
|
174 |
BNO055_SIC_MATRIX_5_LSB_ADDR = 0X4D, |
|
175 |
BNO055_SIC_MATRIX_5_MSB_ADDR = 0X4E, |
|
176 |
BNO055_SIC_MATRIX_6_LSB_ADDR = 0X4F, |
|
177 |
BNO055_SIC_MATRIX_6_MSB_ADDR = 0X50, |
|
178 |
BNO055_SIC_MATRIX_7_LSB_ADDR = 0X51, |
|
179 |
BNO055_SIC_MATRIX_7_MSB_ADDR = 0X52, |
|
180 |
BNO055_SIC_MATRIX_8_LSB_ADDR = 0X53, |
|
181 |
BNO055_SIC_MATRIX_8_MSB_ADDR = 0X54, |
|
182 |
|
|
183 |
/* Accelerometer Offset registers */ |
|
184 |
ACCEL_OFFSET_X_LSB_ADDR = 0X55, |
|
185 |
ACCEL_OFFSET_X_MSB_ADDR = 0X56, |
|
186 |
ACCEL_OFFSET_Y_LSB_ADDR = 0X57, |
|
187 |
ACCEL_OFFSET_Y_MSB_ADDR = 0X58, |
|
188 |
ACCEL_OFFSET_Z_LSB_ADDR = 0X59, |
|
189 |
ACCEL_OFFSET_Z_MSB_ADDR = 0X5A, |
|
190 |
|
|
191 |
/* Magnetometer Offset registers */ |
|
192 |
MAG_OFFSET_X_LSB_ADDR = 0X5B, |
|
193 |
MAG_OFFSET_X_MSB_ADDR = 0X5C, |
|
194 |
MAG_OFFSET_Y_LSB_ADDR = 0X5D, |
|
195 |
MAG_OFFSET_Y_MSB_ADDR = 0X5E, |
|
196 |
MAG_OFFSET_Z_LSB_ADDR = 0X5F, |
|
197 |
MAG_OFFSET_Z_MSB_ADDR = 0X60, |
|
198 |
|
|
199 |
/* Gyroscope Offset register s*/ |
|
200 |
GYRO_OFFSET_X_LSB_ADDR = 0X61, |
|
201 |
GYRO_OFFSET_X_MSB_ADDR = 0X62, |
|
202 |
GYRO_OFFSET_Y_LSB_ADDR = 0X63, |
|
203 |
GYRO_OFFSET_Y_MSB_ADDR = 0X64, |
|
204 |
GYRO_OFFSET_Z_LSB_ADDR = 0X65, |
|
205 |
GYRO_OFFSET_Z_MSB_ADDR = 0X66, |
|
206 |
|
|
207 |
/* Radius registers */ |
|
208 |
ACCEL_RADIUS_LSB_ADDR = 0X67, |
|
209 |
ACCEL_RADIUS_MSB_ADDR = 0X68, |
|
210 |
MAG_RADIUS_LSB_ADDR = 0X69, |
|
211 |
MAG_RADIUS_MSB_ADDR = 0X6A |
|
212 |
} adafruit_bno055_reg_t; |
|
213 |
|
|
214 |
typedef enum |
|
215 |
{ |
|
216 |
POWER_MODE_NORMAL = 0X00, |
|
217 |
POWER_MODE_LOWPOWER = 0X01, |
|
218 |
POWER_MODE_SUSPEND = 0X02 |
|
219 |
} adafruit_bno055_powermode_t; |
|
220 |
|
|
221 |
typedef enum |
|
222 |
{ |
|
223 |
/* Operation mode settings*/ |
|
224 |
OPERATION_MODE_CONFIG = 0X00, |
|
225 |
OPERATION_MODE_ACCONLY = 0X01, |
|
226 |
OPERATION_MODE_MAGONLY = 0X02, |
|
227 |
OPERATION_MODE_GYRONLY = 0X03, |
|
228 |
OPERATION_MODE_ACCMAG = 0X04, |
|
229 |
OPERATION_MODE_ACCGYRO = 0X05, |
|
230 |
OPERATION_MODE_MAGGYRO = 0X06, |
|
231 |
OPERATION_MODE_AMG = 0X07, |
|
232 |
OPERATION_MODE_IMUPLUS = 0X08, |
|
233 |
OPERATION_MODE_COMPASS = 0X09, |
|
234 |
OPERATION_MODE_M4G = 0X0A, |
|
235 |
OPERATION_MODE_NDOF_FMC_OFF = 0X0B, |
|
236 |
OPERATION_MODE_NDOF = 0X0C |
|
237 |
} adafruit_bno055_opmode_t; |
|
238 |
|
|
239 |
typedef struct |
|
240 |
{ |
|
241 |
uint8_t accel_rev; |
|
242 |
uint8_t mag_rev; |
|
243 |
uint8_t gyro_rev; |
|
244 |
uint16_t sw_rev; |
|
245 |
uint8_t bl_rev; |
|
246 |
} adafruit_bno055_rev_info_t; |
|
247 |
|
|
248 |
typedef enum |
|
249 |
{ |
|
250 |
VECTOR_ACCELEROMETER = BNO055_ACCEL_DATA_X_LSB_ADDR, |
|
251 |
VECTOR_MAGNETOMETER = BNO055_MAG_DATA_X_LSB_ADDR, |
|
252 |
VECTOR_GYROSCOPE = BNO055_GYRO_DATA_X_LSB_ADDR, |
|
253 |
VECTOR_EULER = BNO055_EULER_H_LSB_ADDR, |
|
254 |
VECTOR_LINEARACCEL = BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR, |
|
255 |
VECTOR_GRAVITY = BNO055_GRAVITY_DATA_X_LSB_ADDR |
|
256 |
} adafruit_vector_type_t; |
|
257 |
|
|
258 |
Adafruit_BNO055 ( int32_t sensorID = -1, uint8_t address = BNO055_ADDRESS_A ); |
|
259 |
|
|
260 |
bool begin ( adafruit_bno055_opmode_t mode = OPERATION_MODE_NDOF ); |
|
261 |
void setMode ( adafruit_bno055_opmode_t mode ); |
|
262 |
void getRevInfo ( adafruit_bno055_rev_info_t* ); |
|
263 |
void displayRevInfo ( void ); |
|
264 |
void setExtCrystalUse ( boolean usextal ); |
|
265 |
void getSystemStatus ( uint8_t *system_status, |
|
266 |
uint8_t *self_test_result, |
|
267 |
uint8_t *system_error); |
|
268 |
void displaySystemStatus ( void ); |
|
269 |
void getCalibration ( uint8_t* system, uint8_t* gyro, uint8_t* accel, uint8_t* mag); |
|
270 |
|
|
271 |
imu::Vector<3> getVector ( adafruit_vector_type_t vector_type ); |
|
272 |
imu::Quaternion getQuat ( void ); |
|
273 |
int8_t getTemp ( void ); |
|
274 |
|
|
275 |
/* Adafruit_Sensor implementation */ |
|
276 |
bool getEvent ( sensors_event_t* ); |
|
277 |
void getSensor ( sensor_t* ); |
|
278 |
|
|
279 |
/* Functions to deal with raw calibration data */ |
|
280 |
bool getSensorOffsets(uint8_t* calibData); |
|
281 |
bool getSensorOffsets(adafruit_bno055_offsets_t &offsets_type); |
|
282 |
void setSensorOffsets(const uint8_t* calibData); |
|
283 |
void setSensorOffsets(const adafruit_bno055_offsets_t &offsets_type); |
|
284 |
bool isFullyCalibrated(void); |
|
285 |
|
|
286 |
private: |
|
287 |
byte read8 ( adafruit_bno055_reg_t ); |
|
288 |
bool readLen ( adafruit_bno055_reg_t, byte* buffer, uint8_t len ); |
|
289 |
bool write8 ( adafruit_bno055_reg_t, byte value ); |
|
290 |
|
|
291 |
uint8_t _address; |
|
292 |
int32_t _sensorID; |
|
293 |
adafruit_bno055_opmode_t _mode; |
|
296 | 294 |
}; |
297 | 295 |
|
298 | 296 |
#endif |
Also available in: Unified diff