[136] | 1 | /****************************************************************************
|
---|
| 2 | * Copyright (C) 2011 - 2014 Bosch Sensortec GmbH
|
---|
| 3 | *
|
---|
| 4 | * NAxisMotion.h
|
---|
| 5 | * Date: 2015/02/10
|
---|
| 6 | * Revision: 3.0 $
|
---|
| 7 | *
|
---|
| 8 | * Usage: Header file of the C++ Wrapper for the BNO055 Sensor API
|
---|
| 9 | *
|
---|
| 10 | ****************************************************************************
|
---|
| 11 | *
|
---|
| 12 | * Added Arduino M0/M0 Pro support
|
---|
| 13 | *
|
---|
| 14 | * Date: 07/27/2015
|
---|
| 15 | *
|
---|
| 16 | * Modified by: Arduino.org development Team.
|
---|
| 17 | *
|
---|
| 18 | ****************************************************************************
|
---|
| 19 | /***************************************************************************
|
---|
| 20 | * License:
|
---|
| 21 | *
|
---|
| 22 | * Redistribution and use in source and binary forms, with or without
|
---|
| 23 | * modification, are permitted provided that the following conditions are met:
|
---|
| 24 | *
|
---|
| 25 | * Redistributions of source code must retain the above copyright
|
---|
| 26 | * notice, this list of conditions and the following disclaimer.
|
---|
| 27 | *
|
---|
| 28 | * Redistributions in binary form must reproduce the above copyright
|
---|
| 29 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 30 | * documentation and/or other materials provided with the distribution.
|
---|
| 31 | *
|
---|
| 32 | * Neither the name of the copyright holder nor the names of the
|
---|
| 33 | * contributors may be used to endorse or promote products derived from
|
---|
| 34 | * this software without specific prior written permission.
|
---|
| 35 | *
|
---|
| 36 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
---|
| 37 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
| 38 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 39 | * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
---|
| 40 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
| 41 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
| 42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 44 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
| 45 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
---|
| 46 | *
|
---|
| 47 | * The information provided is believed to be accurate and reliable.
|
---|
| 48 | * The copyright holder assumes no responsibility for the consequences of use
|
---|
| 49 | * of such information nor for any infringement of patents or
|
---|
| 50 | * other rights of third parties which may result from its use.
|
---|
| 51 | * No license is granted by implication or otherwise under any patent or
|
---|
| 52 | * patent rights of the copyright holder.
|
---|
| 53 | */
|
---|
| 54 | #ifndef __NAXISMOTION_H__
|
---|
| 55 | #define __NAXISMOTION_H__
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | extern "C" {
|
---|
| 61 | #include <utility/BNO055.h>
|
---|
| 62 | }
|
---|
| 63 | #include <Wire.h>
|
---|
| 64 | #include "Arduino.h"
|
---|
| 65 |
|
---|
| 66 | //Custom Data structures
|
---|
| 67 | //Structure to hold the calibration status
|
---|
| 68 | struct bno055_calib_stat_t {
|
---|
| 69 | uint8_t accel; //Calibration Status of the accelerometer
|
---|
| 70 | uint8_t mag; //Calibration Status of the magnetometer
|
---|
| 71 | uint8_t gyro; //Calibration Status of the gyroscope
|
---|
| 72 | uint8_t system; //Calibration Status of the overall system
|
---|
| 73 | };
|
---|
| 74 |
|
---|
| 75 | //Structure to hold the accelerometer configurations
|
---|
| 76 | struct bno055_accel_stat_t {
|
---|
| 77 | uint8_t range; //Range: 2G - 16G
|
---|
| 78 | uint8_t bandwidth; //Bandwidth: 7.81Hz - 1000Hz
|
---|
| 79 | uint8_t powerMode; //Power mode: Normal - Deep suspend
|
---|
| 80 | };
|
---|
| 81 |
|
---|
| 82 | //GPIO pins used for controlling the Sensor
|
---|
| 83 | #define RESET_PIN 4 //GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
|
---|
| 84 |
|
---|
| 85 | #if defined(__AVR_ATmega32U4__) //Arduino Yun and Leonardo
|
---|
| 86 | #define INT_PIN 4 //GPIO to receive the Interrupt from the BNO055 for the Arduino Uno(Interrupt is visible on the INT LED on the Shield)
|
---|
| 87 | #elif defined(ARDUINO_ARCH_SAM) //INT_PIN is the interrupt number not the interrupt pin
|
---|
| 88 | #define INT_PIN 2
|
---|
| 89 | #elif defined(ARDUINO_ARCH_SAMD)
|
---|
| 90 | #define INT_PIN 7
|
---|
| 91 | #else
|
---|
| 92 | #define INT_PIN 0
|
---|
| 93 | #endif
|
---|
| 94 |
|
---|
| 95 | #define ENABLE 1 //For use in function parameters
|
---|
| 96 | #define DISABLE 0 //For use in function parameters
|
---|
| 97 | #define NO_MOTION 1 //Enables the no motion interrupt
|
---|
| 98 | #define SLOW_MOTION 0 //Enables the slow motion interrupt
|
---|
| 99 | #define ANDROID 1 //To set the Output Data Format to Android style
|
---|
| 100 |
|
---|
| 101 | #if defined(ARDUINO_SAM_DUE)
|
---|
| 102 | #define I2C Wire1 //Define which I2C bus is used. Wire1 for the Arduino Due
|
---|
| 103 | #else
|
---|
| 104 | #define I2C Wire //Or Wire
|
---|
| 105 | #endif
|
---|
| 106 |
|
---|
| 107 | #define INIT_PERIOD 600 //Initialization period set to 600ms
|
---|
| 108 | #define RESET_PERIOD 300 //Reset period set to 300ms
|
---|
| 109 | #define POST_INIT_PERIOD 50 //Post initialization delay of 50ms
|
---|
| 110 | #define MANUAL 1 //To manually call the update data functions
|
---|
| 111 | #define AUTO 0 //To automatically call the update data functions
|
---|
| 112 | class NAxisMotion {
|
---|
| 113 | private:
|
---|
| 114 | bool dataUpdateMode; //Variable to store the mode of updating data
|
---|
| 115 | struct bno055_t myBNO; //Structure that stores the device information
|
---|
| 116 | struct bno055_accel_float_t accelData; //Structure that holds the accelerometer data
|
---|
| 117 | struct bno055_mag_float_t magData; //Structure that holds the magnetometer data
|
---|
| 118 | struct bno055_gyro_float_t gyroData; //Structure that holds the gyroscope data
|
---|
| 119 | struct bno055_quaternion_t quatData; //Structure that holds the quaternion data
|
---|
| 120 | struct bno055_euler_float_t eulerData; //Structure that holds the euler data
|
---|
| 121 | struct bno055_linear_accel_float_t linearAccelData; //Structure that holds the linear acceleration data
|
---|
| 122 | struct bno055_gravity_float_t gravAccelData; //Structure that holds the gravity acceleration data
|
---|
| 123 | struct bno055_calib_stat_t calibStatus; //Structure to hold the calibration status
|
---|
| 124 | struct bno055_accel_stat_t accelStatus; //Structure to hold the status of the accelerometer configurations
|
---|
| 125 | public:
|
---|
| 126 | //Function Declarations
|
---|
| 127 | /*******************************************************************************************
|
---|
| 128 | *Description: Constructor of the class with the default initialization
|
---|
| 129 | *Input Parameters: None
|
---|
| 130 | *Return Parameter: None
|
---|
| 131 | *******************************************************************************************/
|
---|
| 132 | NAxisMotion();
|
---|
| 133 |
|
---|
| 134 | /*******************************************************************************************
|
---|
| 135 | *Description: Function with the bare minimum initialization
|
---|
| 136 | *Input Parameters: None
|
---|
| 137 | *Return Parameter: None
|
---|
| 138 | *******************************************************************************************/
|
---|
| 139 | void initSensor(unsigned int address = 0x28);
|
---|
| 140 |
|
---|
| 141 | /*******************************************************************************************
|
---|
| 142 | *Description: This function is used to reset the BNO055
|
---|
| 143 | *Input Parameters: None
|
---|
| 144 | *Return Parameter: None
|
---|
| 145 | *******************************************************************************************/
|
---|
| 146 | void resetSensor(unsigned int address);
|
---|
| 147 |
|
---|
| 148 | /*******************************************************************************************
|
---|
| 149 | *Description: This function is used to set the operation mode of the BNO055
|
---|
| 150 | *Input Parameters:
|
---|
| 151 | * byte operationMode: To assign which operation mode the device has to
|
---|
| 152 | * ---------------------------------------------------
|
---|
| 153 | * Constant Definition Constant Value Comment
|
---|
| 154 | * ---------------------------------------------------
|
---|
| 155 | * OPERATION_MODE_CONFIG 0x00 Configuration Mode
|
---|
| 156 | * (Transient Mode)
|
---|
| 157 | * OPERATION_MODE_ACCONLY 0x01 Accelerometer only
|
---|
| 158 | * OPERATION_MODE_MAGONLY 0x02 Magnetometer only
|
---|
| 159 | * OPERATION_MODE_GYRONLY 0x03 Gyroscope only
|
---|
| 160 | * OPERATION_MODE_ACCMAG 0x04 Accelerometer and Magnetometer only
|
---|
| 161 | * OPERATION_MODE_ACCGYRO 0x05 Accelerometer and Gyroscope only
|
---|
| 162 | * OPERATION_MODE_MAGGYRO 0x06 Magnetometer and Gyroscope only
|
---|
| 163 | * OPERATION_MODE_AMG 0x07 Accelerometer, Magnetometer and
|
---|
| 164 | * Gyroscope (without fusion)
|
---|
| 165 | * OPERATION_MODE_IMUPLUS 0x08 Inertial Measurement Unit
|
---|
| 166 | * (Accelerometer and Gyroscope
|
---|
| 167 | * Sensor Fusion Mode)
|
---|
| 168 | * OPERATION_MODE_COMPASS 0x09 Tilt Compensated Compass
|
---|
| 169 | * (Accelerometer and Magnetometer
|
---|
| 170 | * Sensor Fusion Mode)
|
---|
| 171 | * OPERATION_MODE_M4G 0x0A Magnetometer and Accelerometer Sensor
|
---|
| 172 | * Fusion Mode
|
---|
| 173 | * OPERATION_MODE_NDOF_FMC_OFF 0x0B 9 Degrees of Freedom Sensor Fusion
|
---|
| 174 | * with Fast Magnetometer Calibration Off
|
---|
| 175 | * OPERATION_MODE_NDOF 0x0C 9 Degrees of Freedom Sensor Fusion
|
---|
| 176 | *Return Parameter: None
|
---|
| 177 | *******************************************************************************************/
|
---|
| 178 | void setOperationMode(byte operationMode);
|
---|
| 179 |
|
---|
| 180 | /*******************************************************************************************
|
---|
| 181 | *Description: This function is used to set the power mode
|
---|
| 182 | *Input Parameters:
|
---|
| 183 | * byte powerMode: To assign the power mode the device has to switch to
|
---|
| 184 | * --------------------------------------
|
---|
| 185 | * Constant Definition Constant Value
|
---|
| 186 | * --------------------------------------
|
---|
| 187 | * POWER_MODE_NORMAL 0x00
|
---|
| 188 | * POWER_MODE_LOWPOWER 0x01
|
---|
| 189 | * POWER_MODE_SUSPEND 0x02
|
---|
| 190 | *Return Parameter:
|
---|
| 191 | *******************************************************************************************/
|
---|
| 192 | void setPowerMode(byte powerMode);
|
---|
| 193 |
|
---|
| 194 | /*******************************************************************************************
|
---|
| 195 | *Description: This function is used to update the accelerometer data in m/s2
|
---|
| 196 | *Input Parameters: None
|
---|
| 197 | *Return Parameter: None
|
---|
| 198 | *******************************************************************************************/
|
---|
| 199 | void updateAccel(void);
|
---|
| 200 |
|
---|
| 201 | /*******************************************************************************************
|
---|
| 202 | *Description: This function is used to update the magnetometer data in microTesla
|
---|
| 203 | *Input Parameters: None
|
---|
| 204 | *Return Parameter: None
|
---|
| 205 | *******************************************************************************************/
|
---|
| 206 | void updateMag(void);
|
---|
| 207 |
|
---|
| 208 | /*******************************************************************************************
|
---|
| 209 | *Description: This function is used to update the gyroscope data in deg/s
|
---|
| 210 | *Input Parameters: None
|
---|
| 211 | *Return Parameter: None
|
---|
| 212 | *******************************************************************************************/
|
---|
| 213 | void updateGyro(void);
|
---|
| 214 |
|
---|
| 215 | /*******************************************************************************************
|
---|
| 216 | *Description: This function is used to update the quaternion data
|
---|
| 217 | *Input Parameters: None
|
---|
| 218 | *Return Parameter: None
|
---|
| 219 | *******************************************************************************************/
|
---|
| 220 | void updateQuat(void);
|
---|
| 221 |
|
---|
| 222 | /*******************************************************************************************
|
---|
| 223 | *Description: This function is used to update the euler data
|
---|
| 224 | *Input Parameters: None
|
---|
| 225 | *Return Parameter: None
|
---|
| 226 | *******************************************************************************************/
|
---|
| 227 | void updateEuler(void);
|
---|
| 228 |
|
---|
| 229 | /*******************************************************************************************
|
---|
| 230 | *Description: This function is used to update the linear acceleration data in m/s2
|
---|
| 231 | *Input Parameters: None
|
---|
| 232 | *Return Parameter: None
|
---|
| 233 | *******************************************************************************************/
|
---|
| 234 | void updateLinearAccel(void);
|
---|
| 235 |
|
---|
| 236 | /*******************************************************************************************
|
---|
| 237 | *Description: This function is used to update the gravity acceleration data in m/s2
|
---|
| 238 | *Input Parameters: None
|
---|
| 239 | *Return Parameter: None
|
---|
| 240 | *******************************************************************************************/
|
---|
| 241 | void updateGravAccel(void);
|
---|
| 242 |
|
---|
| 243 | /*******************************************************************************************
|
---|
| 244 | *Description: This function is used to update the calibration status
|
---|
| 245 | *Input Parameters: None
|
---|
| 246 | *Return Parameter: None
|
---|
| 247 | *******************************************************************************************/
|
---|
| 248 | void updateCalibStatus(void);
|
---|
| 249 |
|
---|
| 250 | /*******************************************************************************************
|
---|
| 251 | *Description: This function is used to write the accelerometer configurations
|
---|
| 252 | *Input Parameters:
|
---|
| 253 | * uint8_t range: To assign the range of the accelerometer
|
---|
| 254 | * --------------------------------------
|
---|
| 255 | * Constant Definition Constant Value
|
---|
| 256 | * --------------------------------------
|
---|
| 257 | * ACCEL_RANGE_2G 0X00
|
---|
| 258 | * ACCEL_RANGE_4G 0X01
|
---|
| 259 | * ACCEL_RANGE_8G 0X02
|
---|
| 260 | * ACCEL_RANGE_16G 0X03
|
---|
| 261 | * uint8_t bandwidth: To assign the filter bandwidth of the accelerometer
|
---|
| 262 | * --------------------------------------
|
---|
| 263 | * Constant Definition Constant Value
|
---|
| 264 | * --------------------------------------
|
---|
| 265 | * ACCEL_BW_7_81HZ 0x00
|
---|
| 266 | * ACCEL_BW_15_63HZ 0x01
|
---|
| 267 | * ACCEL_BW_31_25HZ 0x02
|
---|
| 268 | * ACCEL_BW_62_5HZ 0X03
|
---|
| 269 | * ACCEL_BW_125HZ 0X04
|
---|
| 270 | * ACCEL_BW_250HZ 0X05
|
---|
| 271 | * ACCEL_BW_500HZ 0X06
|
---|
| 272 | * ACCEL_BW_1000HZ 0X07
|
---|
| 273 | * uint8_t powerMode: To assign the power mode of the accelerometer
|
---|
| 274 | * --------------------------------------
|
---|
| 275 | * Constant Definition Constant Value
|
---|
| 276 | * --------------------------------------
|
---|
| 277 | * ACCEL_NORMAL 0X00
|
---|
| 278 | * ACCEL_SUSPEND 0X01
|
---|
| 279 | * ACCEL_LOWPOWER_1 0X02
|
---|
| 280 | * ACCEL_STANDBY 0X03
|
---|
| 281 | * ACCEL_LOWPOWER_2 0X04
|
---|
| 282 | * ACCEL_DEEPSUSPEND 0X05
|
---|
| 283 | *Return Parameter: None
|
---|
| 284 | *******************************************************************************************/
|
---|
| 285 | void writeAccelConfig(uint8_t range, uint8_t bandwidth, uint8_t powerMode);
|
---|
| 286 |
|
---|
| 287 | /*******************************************************************************************
|
---|
| 288 | *Description: This function is used to update the accelerometer configurations
|
---|
| 289 | *Input Parameters: None
|
---|
| 290 | *Return Parameter: None
|
---|
| 291 | *******************************************************************************************/
|
---|
| 292 | void updateAccelConfig(void);
|
---|
| 293 |
|
---|
| 294 | /*******************************************************************************************
|
---|
| 295 | *Description: This function is used to control which axis of the accelerometer triggers the
|
---|
| 296 | * interrupt
|
---|
| 297 | *Input Parameters:
|
---|
| 298 | * bool xStatus: To know whether the x axis has to trigger the interrupt
|
---|
| 299 | * ---------------------------------------------------
|
---|
| 300 | * Constant Definition Constant Value Comment
|
---|
| 301 | * ---------------------------------------------------
|
---|
| 302 | * ENABLE 1 Enables interrupts from that axis
|
---|
| 303 | * DISABLE 0 Disables interrupts from that axis
|
---|
| 304 | * bool yStatus: To know whether the x axis has to trigger the interrupt
|
---|
| 305 | * ---------------------------------------------------
|
---|
| 306 | * Constant Definition Constant Value Comment
|
---|
| 307 | * ---------------------------------------------------
|
---|
| 308 | * ENABLE 1 Enables interrupts from that axis
|
---|
| 309 | * DISABLE 0 Disables interrupts from that axis
|
---|
| 310 | * bool zStatus: To know whether the x axis has to trigger the interrupt
|
---|
| 311 | * ---------------------------------------------------
|
---|
| 312 | * Constant Definition Constant Value Comment
|
---|
| 313 | * ---------------------------------------------------
|
---|
| 314 | * ENABLE 1 Enables interrupts from that axis
|
---|
| 315 | * DISABLE 0 Disables interrupts from that axis
|
---|
| 316 | *Return Parameter: None
|
---|
| 317 | *******************************************************************************************/
|
---|
| 318 | void accelInterrupts(bool xStatus, bool yStatus, bool zStatus);
|
---|
| 319 |
|
---|
| 320 | /*******************************************************************************************
|
---|
| 321 | *Description: This function is used to reset the interrupt line
|
---|
| 322 | *Input Parameters: None
|
---|
| 323 | *Return Parameter: None
|
---|
| 324 | *******************************************************************************************/
|
---|
| 325 | void resetInterrupt(void);
|
---|
| 326 |
|
---|
| 327 | /*******************************************************************************************
|
---|
| 328 | *Description: This function is used to enable the any motion interrupt based on the
|
---|
| 329 | * accelerometer
|
---|
| 330 | *Input Parameters:
|
---|
| 331 | * uint8_t threshold: The threshold that triggers the any motion interrupt
|
---|
| 332 | * The threshold should be entered as an integer. The corresponding value of
|
---|
| 333 | * the threshold depends on the range that has been set on the
|
---|
| 334 | * accelerometer. Below is a table showing the value of 1LSB in
|
---|
| 335 | * corresponding units.
|
---|
| 336 | * Resolution:
|
---|
| 337 | * ACCEL_RANGE_2G, 1LSB = 3.91mg = ~0.03835m/s2
|
---|
| 338 | * ACCEL_RANGE_4G, 1LSB = 7.81mg = ~0.07661m/s2
|
---|
| 339 | * ACCEL_RANGE_8G, 1LSB = 15.6mg = ~0.15303m/s2
|
---|
| 340 | * ACCEL_RANGE_16G, 1LSB = 31.3mg = ~0.30705m/s2
|
---|
| 341 | * Maximum:
|
---|
| 342 | * ACCEL_RANGE_2G, 1LSB = 996mg = ~9.77076m/s2,
|
---|
| 343 | * ACCEL_RANGE_4G, 1LSB = 1.99g = ~19.5219m/s2
|
---|
| 344 | * ACCEL_RANGE_8G, 1LSB = 3.98g = ~39.0438m/s2
|
---|
| 345 | * ACCEL_RANGE_16G, 1LSB = 7.97g = ~97.1857m/s2
|
---|
| 346 | * uint8_t duration: The duration for which the desired threshold exist
|
---|
| 347 | * The time difference between the successive acceleration signals depends
|
---|
| 348 | * on the selected bandwidth and equates to 1/(2*bandwidth).
|
---|
| 349 | * In order to suppress false triggers, the interrupt is only generated (cleared)
|
---|
| 350 | * if a certain number N of consecutive slope data points is larger (smaller)
|
---|
| 351 | * than the slope 'threshold'. This number is set by the 'duration'.
|
---|
| 352 | * It is N = duration + 1.
|
---|
| 353 | * Resolution:
|
---|
| 354 | * ACCEL_BW_7_81HZ, 1LSB = 64ms
|
---|
| 355 | * ACCEL_BW_15_63HZ, 1LSB = 32ms
|
---|
| 356 | * ACCEL_BW_31_25HZ, 1LSB = 16ms
|
---|
| 357 | * ACCEL_BW_62_5HZ, 1LSB = 8ms
|
---|
| 358 | * ACCEL_BW_125HZ, 1LSB = 4ms
|
---|
| 359 | * ACCEL_BW_250HZ, 1LSB = 2ms
|
---|
| 360 | * ACCEL_BW_500HZ, 1LSB = 1ms
|
---|
| 361 | * ACCEL_BW_1000HZ, 1LSB = 0.5ms
|
---|
| 362 | *Return Parameter: None
|
---|
| 363 | *******************************************************************************************/
|
---|
| 364 | void enableAnyMotion(uint8_t threshold, uint8_t duration);
|
---|
| 365 |
|
---|
| 366 | /*******************************************************************************************
|
---|
| 367 | *Description: This function is used to disable the any motion interrupt
|
---|
| 368 | *Input Parameters: None
|
---|
| 369 | *Return Parameter: None
|
---|
| 370 | *******************************************************************************************/
|
---|
| 371 | void disableAnyMotion(void);
|
---|
| 372 |
|
---|
| 373 |
|
---|
| 374 | /*******************************************************************************************
|
---|
| 375 | *Description: This function is used to enable the slow or no motion interrupt based on the
|
---|
| 376 | * accelerometer
|
---|
| 377 | *Input Parameters:
|
---|
| 378 | * uint8_t threshold: The threshold that triggers the no motion interrupt
|
---|
| 379 | * The threshold should be entered as an integer. The corresponding value of
|
---|
| 380 | * the threshold depends on the range that has been set on the
|
---|
| 381 | * accelerometer. Below is a table showing the value of 1LSB in
|
---|
| 382 | * corresponding units.
|
---|
| 383 | * Resolution:
|
---|
| 384 | * ACCEL_RANGE_2G, 1LSB = 3.91mg = ~0.03835m/s2
|
---|
| 385 | * ACCEL_RANGE_4G, 1LSB = 7.81mg = ~0.07661m/s2
|
---|
| 386 | * ACCEL_RANGE_8G, 1LSB = 15.6mg = ~0.15303m/s2
|
---|
| 387 | * ACCEL_RANGE_16G, 1LSB = 31.3mg = ~0.30705m/s2
|
---|
| 388 | * Maximum:
|
---|
| 389 | * ACCEL_RANGE_2G, 1LSB = 996mg = ~9.77076m/s2,
|
---|
| 390 | * ACCEL_RANGE_4G, 1LSB = 1.99g = ~19.5219m/s2
|
---|
| 391 | * ACCEL_RANGE_8G, 1LSB = 3.98g = ~39.0438m/s2
|
---|
| 392 | * ACCEL_RANGE_16G, 1LSB = 7.97g = ~97.1857m/s2
|
---|
| 393 | * uint8_t duration: The duration for which the desired threshold should be surpassed
|
---|
| 394 | * The time difference between the successive acceleration signals depends
|
---|
| 395 | * on the selected bandwidth and equates to 1/(2*bandwidth).
|
---|
| 396 | * In order to suppress false triggers, the interrupt is only generated (cleared)
|
---|
| 397 | * if a certain number N of consecutive slope data points is larger (smaller)
|
---|
| 398 | * than the slope 'threshold'. This number is set by the 'duration'.
|
---|
| 399 | * It is N = duration + 1.
|
---|
| 400 | * Resolution:
|
---|
| 401 | * ACCEL_BW_7_81HZ, 1LSB = 64ms
|
---|
| 402 | * ACCEL_BW_15_63HZ, 1LSB = 32ms
|
---|
| 403 | * ACCEL_BW_31_25HZ, 1LSB = 16ms
|
---|
| 404 | * ACCEL_BW_62_5HZ, 1LSB = 8ms
|
---|
| 405 | * ACCEL_BW_125HZ, 1LSB = 4ms
|
---|
| 406 | * ACCEL_BW_250HZ, 1LSB = 2ms
|
---|
| 407 | * ACCEL_BW_500HZ, 1LSB = 1ms
|
---|
| 408 | * ACCEL_BW_1000HZ, 1LSB = 0.5ms
|
---|
| 409 | * bool motion: To trigger either a Slow motion or a No motion interrupt
|
---|
| 410 | * ---------------------------------------------------
|
---|
| 411 | * Constant Definition Constant Value Comment
|
---|
| 412 | * ---------------------------------------------------
|
---|
| 413 | * NO_MOTION 1 Enables the no motion interrupt
|
---|
| 414 | * SLOW_MOTION 0 Enables the slow motion interrupt
|
---|
| 415 | *Return Parameter: None
|
---|
| 416 | *******************************************************************************************/
|
---|
| 417 | void enableSlowNoMotion(uint8_t threshold, uint8_t duration, bool motion);
|
---|
| 418 |
|
---|
| 419 | /*******************************************************************************************
|
---|
| 420 | *Description: This function is used to disable the slow or no motion interrupt
|
---|
| 421 | *Input Parameters: None
|
---|
| 422 | *Return Parameter: None
|
---|
| 423 | *******************************************************************************************/
|
---|
| 424 | void disableSlowNoMotion(void);
|
---|
| 425 |
|
---|
| 426 | /*******************************************************************************************
|
---|
| 427 | *Description: This function is used to change the mode of updating the local data
|
---|
| 428 | *Input Parameters: None
|
---|
| 429 | *Return Parameter: None
|
---|
| 430 | *******************************************************************************************/
|
---|
| 431 | void setUpdateMode(bool updateMode);
|
---|
| 432 |
|
---|
| 433 | /*******************************************************************************************
|
---|
| 434 | *Description: This function is used to return the x-axis of the accelerometer data
|
---|
| 435 | *Input Parameters: None
|
---|
| 436 | *Return Parameter:
|
---|
| 437 | * float: X-axis accelerometer data in m/s2
|
---|
| 438 | *******************************************************************************************/
|
---|
| 439 | float readAccelX(void);
|
---|
| 440 |
|
---|
| 441 | /*******************************************************************************************
|
---|
| 442 | *Description: This function is used to return the y-axis of the accelerometer data
|
---|
| 443 | *Input Parameters: None
|
---|
| 444 | *Return Parameter:
|
---|
| 445 | * float: Y-axis accelerometer data in m/s2
|
---|
| 446 | *******************************************************************************************/
|
---|
| 447 | float readAccelY(void);
|
---|
| 448 |
|
---|
| 449 | /*******************************************************************************************
|
---|
| 450 | *Description: This function is used to return the z-axis of the accelerometer data
|
---|
| 451 | *Input Parameters: None
|
---|
| 452 | *Return Parameter:
|
---|
| 453 | * float: Z-axis accelerometer data in m/s2
|
---|
| 454 | *******************************************************************************************/
|
---|
| 455 | float readAccelZ(void);
|
---|
| 456 |
|
---|
| 457 | /*******************************************************************************************
|
---|
| 458 | *Description: This function is used to return the x-axis of the gyroscope data
|
---|
| 459 | *Input Parameters: None
|
---|
| 460 | *Return Parameter:
|
---|
| 461 | * float: X-axis gyroscope data in deg/s
|
---|
| 462 | *******************************************************************************************/
|
---|
| 463 | float readGyroX(void);
|
---|
| 464 |
|
---|
| 465 | /*******************************************************************************************
|
---|
| 466 | *Description: This function is used to return the y-axis of the gyroscope data
|
---|
| 467 | *Input Parameters: None
|
---|
| 468 | *Return Parameter:
|
---|
| 469 | * float: Y-axis gyroscope data in deg/s
|
---|
| 470 | *******************************************************************************************/
|
---|
| 471 | float readGyroY(void);
|
---|
| 472 |
|
---|
| 473 | /*******************************************************************************************
|
---|
| 474 | *Description: This function is used to return the z-axis of the gyroscope data
|
---|
| 475 | *Input Parameters: None
|
---|
| 476 | *Return Parameter:
|
---|
| 477 | * float: Z-axis gyroscope data in deg/s
|
---|
| 478 | *******************************************************************************************/
|
---|
| 479 | float readGyroZ(void);
|
---|
| 480 |
|
---|
| 481 | /*******************************************************************************************
|
---|
| 482 | *Description: This function is used to return the x-axis of the magnetometer data
|
---|
| 483 | *Input Parameters: None
|
---|
| 484 | *Return Parameter:
|
---|
| 485 | * float: X-axis magnetometer data in µT
|
---|
| 486 | *******************************************************************************************/
|
---|
| 487 | float readMagX(void);
|
---|
| 488 |
|
---|
| 489 | /*******************************************************************************************
|
---|
| 490 | *Description: This function is used to return the y-axis of the magnetometer data
|
---|
| 491 | *Input Parameters: None
|
---|
| 492 | *Return Parameter:
|
---|
| 493 | * float: Y-axis magnetometer data in µT
|
---|
| 494 | *******************************************************************************************/
|
---|
| 495 | float readMagY(void);
|
---|
| 496 |
|
---|
| 497 | /*******************************************************************************************
|
---|
| 498 | *Description: This function is used to return the z-axis of the magnetometer data
|
---|
| 499 | *Input Parameters: None
|
---|
| 500 | *Return Parameter:
|
---|
| 501 | * float: Z-axis magnetometer data in µT
|
---|
| 502 | *******************************************************************************************/
|
---|
| 503 | float readMagZ(void);
|
---|
| 504 |
|
---|
| 505 | /*******************************************************************************************
|
---|
| 506 | *Description: This function is used to return the w-axis of the quaternion data
|
---|
| 507 | *Input Parameters: None
|
---|
| 508 | *Return Parameter:
|
---|
| 509 | * int16_t: W-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
|
---|
| 510 | *******************************************************************************************/
|
---|
| 511 | int16_t readQuatW(void);
|
---|
| 512 |
|
---|
| 513 | /*******************************************************************************************
|
---|
| 514 | *Description: This function is used to return the x-axis of the quaternion data
|
---|
| 515 | *Input Parameters: None
|
---|
| 516 | *Return Parameter:
|
---|
| 517 | * int16_t: X-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
|
---|
| 518 | *******************************************************************************************/
|
---|
| 519 | int16_t readQuatX(void);
|
---|
| 520 |
|
---|
| 521 | /*******************************************************************************************
|
---|
| 522 | *Description: This function is used to return the y-axis of the quaternion data
|
---|
| 523 | *Input Parameters: None
|
---|
| 524 | *Return Parameter:
|
---|
| 525 | * int16_t: Y-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
|
---|
| 526 | *******************************************************************************************/
|
---|
| 527 | int16_t readQuatY(void);
|
---|
| 528 |
|
---|
| 529 | /*******************************************************************************************
|
---|
| 530 | *Description: This function is used to return the z-axis of the quaternion data
|
---|
| 531 | *Input Parameters: None
|
---|
| 532 | *Return Parameter:
|
---|
| 533 | * int16_t: Z-axis quaternion data multiplied by 1000 (for 3 decimal places accuracy)
|
---|
| 534 | *******************************************************************************************/
|
---|
| 535 | int16_t readQuatZ(void);
|
---|
| 536 |
|
---|
| 537 | /*******************************************************************************************
|
---|
| 538 | *Description: This function is used to return the heading(yaw) of the euler data
|
---|
| 539 | *Input Parameters: None
|
---|
| 540 | *Return Parameter:
|
---|
| 541 | * float: Heading of the euler data
|
---|
| 542 | *******************************************************************************************/
|
---|
| 543 | float readEulerHeading(void);
|
---|
| 544 |
|
---|
| 545 | /*******************************************************************************************
|
---|
| 546 | *Description: This function is used to return the roll of the euler data
|
---|
| 547 | *Input Parameters: None
|
---|
| 548 | *Return Parameter:
|
---|
| 549 | * float: Roll of the euler data
|
---|
| 550 | *******************************************************************************************/
|
---|
| 551 | float readEulerRoll(void);
|
---|
| 552 |
|
---|
| 553 | /*******************************************************************************************
|
---|
| 554 | *Description: This function is used to return the pitch of the euler data
|
---|
| 555 | *Input Parameters: None
|
---|
| 556 | *Return Parameter:
|
---|
| 557 | * float: Pitch of the euler data
|
---|
| 558 | *******************************************************************************************/
|
---|
| 559 | float readEulerPitch(void);
|
---|
| 560 |
|
---|
| 561 | /*******************************************************************************************
|
---|
| 562 | *Description: This function is used to return the x-axis of the linear acceleration data
|
---|
| 563 | * (accelerometer data without the gravity vector)
|
---|
| 564 | *Input Parameters: None
|
---|
| 565 | *Return Parameter:
|
---|
| 566 | * float: X-axis Linear Acceleration data in m/s2
|
---|
| 567 | *******************************************************************************************/
|
---|
| 568 | float readLinearAccelX(void);
|
---|
| 569 |
|
---|
| 570 | /*******************************************************************************************
|
---|
| 571 | *Description: This function is used to return the y-axis of the linear acceleration data
|
---|
| 572 | * (accelerometer data without the gravity vector)
|
---|
| 573 | *Input Parameters: None
|
---|
| 574 | *Return Parameter:
|
---|
| 575 | * float: Y-axis Linear Acceleration data in m/s2
|
---|
| 576 | *******************************************************************************************/
|
---|
| 577 | float readLinearAccelY(void);
|
---|
| 578 |
|
---|
| 579 | /*******************************************************************************************
|
---|
| 580 | *Description: This function is used to return the z-axis of the linear acceleration data
|
---|
| 581 | * (accelerometer data without the gravity vector)
|
---|
| 582 | *Input Parameters: None
|
---|
| 583 | *Return Parameter:
|
---|
| 584 | * float: Z-axis Linear Acceleration data in m/s2
|
---|
| 585 | *******************************************************************************************/
|
---|
| 586 | float readLinearAccelZ(void);
|
---|
| 587 |
|
---|
| 588 | /*******************************************************************************************
|
---|
| 589 | *Description: This function is used to return the x-axis of the gravity acceleration data
|
---|
| 590 | * (accelerometer data with only the gravity vector)
|
---|
| 591 | *Input Parameters: None
|
---|
| 592 | *Return Parameter:
|
---|
| 593 | * float: X-axis Gravity Acceleration data in m/s2
|
---|
| 594 | *******************************************************************************************/
|
---|
| 595 | float readGravAccelX(void);
|
---|
| 596 |
|
---|
| 597 | /*******************************************************************************************
|
---|
| 598 | *Description: This function is used to return the y-axis of the gravity acceleration data
|
---|
| 599 | * (accelerometer data with only the gravity vector)
|
---|
| 600 | *Input Parameters: None
|
---|
| 601 | *Return Parameter:
|
---|
| 602 | * float: Y-axis Gravity Acceleration data in m/s2
|
---|
| 603 | *******************************************************************************************/
|
---|
| 604 | float readGravAccelY(void);
|
---|
| 605 |
|
---|
| 606 | /*******************************************************************************************
|
---|
| 607 | *Description: This function is used to return the z-axis of the gravity acceleration data
|
---|
| 608 | * (accelerometer data with only the gravity vector)
|
---|
| 609 | *Input Parameters: None
|
---|
| 610 | *Return Parameter:
|
---|
| 611 | * float: Z-axis Gravity Acceleration data in m/s2
|
---|
| 612 | *******************************************************************************************/
|
---|
| 613 | float readGravAccelZ(void);
|
---|
| 614 |
|
---|
| 615 | /*******************************************************************************************
|
---|
| 616 | *Description: This function is used to return the accelerometer calibration status
|
---|
| 617 | *Input Parameters: None
|
---|
| 618 | *Return Parameter:
|
---|
| 619 | * uint8_t: Accelerometer calibration status, 0-3 (0 - low, 3 - high)
|
---|
| 620 | *******************************************************************************************/
|
---|
| 621 | uint8_t readAccelCalibStatus(void);
|
---|
| 622 |
|
---|
| 623 | /*******************************************************************************************
|
---|
| 624 | *Description: This function is used to return the gyroscope calibration status
|
---|
| 625 | *Input Parameters: None
|
---|
| 626 | *Return Parameter:
|
---|
| 627 | * uint8_t: Gyroscope calibration status, 0-3 (0 - low, 3 - high)
|
---|
| 628 | *******************************************************************************************/
|
---|
| 629 | uint8_t readGyroCalibStatus(void);
|
---|
| 630 |
|
---|
| 631 | /*******************************************************************************************
|
---|
| 632 | *Description: This function is used to return the magnetometer calibration status
|
---|
| 633 | *Input Parameters: None
|
---|
| 634 | *Return Parameter:
|
---|
| 635 | * uint8_t: Magnetometer calibration status, 0-3 (0 - low, 3 - high)
|
---|
| 636 | *******************************************************************************************/
|
---|
| 637 | uint8_t readMagCalibStatus(void);
|
---|
| 638 |
|
---|
| 639 | /*******************************************************************************************
|
---|
| 640 | *Description: This function is used to return the system calibration status
|
---|
| 641 | *Input Parameters: None
|
---|
| 642 | *Return Parameter:
|
---|
| 643 | * uint8_t: System calibration status, 0-3 (0 - low, 3 - high)
|
---|
| 644 | *******************************************************************************************/
|
---|
| 645 | uint8_t readSystemCalibStatus(void);
|
---|
| 646 |
|
---|
| 647 | /*******************************************************************************************
|
---|
| 648 | *Description: This function is used to return the accelerometer range
|
---|
| 649 | *Input Parameters: None
|
---|
| 650 | *Return Parameter:
|
---|
| 651 | * uint8_t range: Range of the accelerometer
|
---|
| 652 | * --------------------------------------
|
---|
| 653 | * Constant Definition Constant Value
|
---|
| 654 | * --------------------------------------
|
---|
| 655 | * ACCEL_RANGE_2G 0X00
|
---|
| 656 | * ACCEL_RANGE_4G 0X01
|
---|
| 657 | * ACCEL_RANGE_8G 0X02
|
---|
| 658 | * ACCEL_RANGE_16G 0X03
|
---|
| 659 | *******************************************************************************************/
|
---|
| 660 | uint8_t readAccelRange(void);
|
---|
| 661 |
|
---|
| 662 | /*******************************************************************************************
|
---|
| 663 | *Description: This function is used to return the accelerometer bandwidth
|
---|
| 664 | *Input Parameters: None
|
---|
| 665 | *Return Parameter:
|
---|
| 666 | * uint8_t bandwidth: Bandwidth of the accelerometer
|
---|
| 667 | * --------------------------------------
|
---|
| 668 | * Constant Definition Constant Value
|
---|
| 669 | * --------------------------------------
|
---|
| 670 | * ACCEL_BW_7_81HZ 0x00
|
---|
| 671 | * ACCEL_BW_15_63HZ 0x01
|
---|
| 672 | * ACCEL_BW_31_25HZ 0x02
|
---|
| 673 | * ACCEL_BW_62_5HZ 0X03
|
---|
| 674 | * ACCEL_BW_125HZ 0X04
|
---|
| 675 | * ACCEL_BW_250HZ 0X05
|
---|
| 676 | * ACCEL_BW_500HZ 0X06
|
---|
| 677 | * ACCEL_BW_1000HZ 0X07
|
---|
| 678 | *******************************************************************************************/
|
---|
| 679 | uint8_t readAccelBandwidth(void);
|
---|
| 680 |
|
---|
| 681 | /*******************************************************************************************
|
---|
| 682 | *Description: This function is used to return the accelerometer power mode
|
---|
| 683 | *Input Parameters: None
|
---|
| 684 | *Return Parameter:
|
---|
| 685 | * uint8_t powerMode: Power mode of the accelerometer
|
---|
| 686 | * --------------------------------------
|
---|
| 687 | * Constant Definition Constant Value
|
---|
| 688 | * --------------------------------------
|
---|
| 689 | * ACCEL_NORMAL 0X00
|
---|
| 690 | * ACCEL_SUSPEND 0X01
|
---|
| 691 | * ACCEL_LOWPOWER_1 0X02
|
---|
| 692 | * ACCEL_STANDBY 0X03
|
---|
| 693 | * ACCEL_LOWPOWER_2 0X04
|
---|
| 694 | * ACCEL_DEEPSUSPEND 0X05
|
---|
| 695 | *******************************************************************************************/
|
---|
| 696 | uint8_t readAccelPowerMode(void);
|
---|
| 697 |
|
---|
| 698 |
|
---|
| 699 |
|
---|
| 700 | };
|
---|
| 701 |
|
---|
| 702 | /******************** Bridge Functions for the Sensor API to control the Arduino Hardware******************************************/
|
---|
| 703 | signed char BNO055_I2C_bus_read(unsigned char,unsigned char, unsigned char*, unsigned char);
|
---|
| 704 | signed char BNO055_I2C_bus_write(unsigned char ,unsigned char , unsigned char* , unsigned char );
|
---|
| 705 | void _delay(u_32);
|
---|
| 706 |
|
---|
| 707 | #endif __NAXISMOTION_H__
|
---|