1

Dependents:   OCE360_Project

Committer:
mikekelly99
Date:
Thu Dec 03 14:22:54 2020 +0000
Revision:
0:cec0f89e2c48
1;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mikekelly99 0:cec0f89e2c48 1 /******************************************************************************
mikekelly99 0:cec0f89e2c48 2 SFE_LSM9DS1.h
mikekelly99 0:cec0f89e2c48 3 SFE_LSM9DS1 Library Header File
mikekelly99 0:cec0f89e2c48 4 Jim Lindblom @ SparkFun Electronics
mikekelly99 0:cec0f89e2c48 5 Original Creation Date: February 27, 2015
mikekelly99 0:cec0f89e2c48 6 https://github.com/sparkfun/LSM9DS1_Breakout
mikekelly99 0:cec0f89e2c48 7
mikekelly99 0:cec0f89e2c48 8 This file prototypes the LSM9DS1 class, implemented in SFE_LSM9DS1.cpp. In
mikekelly99 0:cec0f89e2c48 9 addition, it defines every register in the LSM9DS1 (both the Gyro and Accel/
mikekelly99 0:cec0f89e2c48 10 Magnetometer registers).
mikekelly99 0:cec0f89e2c48 11
mikekelly99 0:cec0f89e2c48 12 Development environment specifics:
mikekelly99 0:cec0f89e2c48 13 IDE: Arduino 1.6.0
mikekelly99 0:cec0f89e2c48 14 Hardware Platform: Arduino Uno
mikekelly99 0:cec0f89e2c48 15 LSM9DS1 Breakout Version: 1.0
mikekelly99 0:cec0f89e2c48 16
mikekelly99 0:cec0f89e2c48 17 This code is beerware; if you see me (or any other SparkFun employee) at the
mikekelly99 0:cec0f89e2c48 18 local, and you've found our code helpful, please buy us a round!
mikekelly99 0:cec0f89e2c48 19
mikekelly99 0:cec0f89e2c48 20 Distributed as-is; no warranty is given.
mikekelly99 0:cec0f89e2c48 21 ******************************************************************************/
mikekelly99 0:cec0f89e2c48 22 #ifndef __SparkFunLSM9DS1_H__
mikekelly99 0:cec0f89e2c48 23 #define __SparkFunLSM9DS1_H__
mikekelly99 0:cec0f89e2c48 24
mikekelly99 0:cec0f89e2c48 25 //#if defined(ARDUINO) && ARDUINO >= 100
mikekelly99 0:cec0f89e2c48 26 // #include "Arduino.h"
mikekelly99 0:cec0f89e2c48 27 //#else
mikekelly99 0:cec0f89e2c48 28 // #include "WProgram.h"
mikekelly99 0:cec0f89e2c48 29 // #include "pins_arduino.h"
mikekelly99 0:cec0f89e2c48 30 //#endif
mikekelly99 0:cec0f89e2c48 31
mikekelly99 0:cec0f89e2c48 32 #include "mbed.h"
mikekelly99 0:cec0f89e2c48 33 #include <stdint.h>
mikekelly99 0:cec0f89e2c48 34 #include "LSM9DS1_Registers.h"
mikekelly99 0:cec0f89e2c48 35 #include "LSM9DS1_Types.h"
mikekelly99 0:cec0f89e2c48 36
mikekelly99 0:cec0f89e2c48 37 #define LSM9DS1_AG_ADDR(sa0) ((sa0) == 0 ? 0x6A : 0x6B)
mikekelly99 0:cec0f89e2c48 38 #define LSM9DS1_M_ADDR(sa1) ((sa1) == 0 ? 0x1C : 0x1E)
mikekelly99 0:cec0f89e2c48 39
mikekelly99 0:cec0f89e2c48 40 enum lsm9ds1_axis {
mikekelly99 0:cec0f89e2c48 41 X_AXIS,
mikekelly99 0:cec0f89e2c48 42 Y_AXIS,
mikekelly99 0:cec0f89e2c48 43 Z_AXIS,
mikekelly99 0:cec0f89e2c48 44 ALL_AXIS
mikekelly99 0:cec0f89e2c48 45 };
mikekelly99 0:cec0f89e2c48 46
mikekelly99 0:cec0f89e2c48 47 class LSM9DS1
mikekelly99 0:cec0f89e2c48 48 {
mikekelly99 0:cec0f89e2c48 49 public:
mikekelly99 0:cec0f89e2c48 50 IMUSettings settings;
mikekelly99 0:cec0f89e2c48 51
mikekelly99 0:cec0f89e2c48 52 // We'll store the gyro, accel, and magnetometer readings in a series of
mikekelly99 0:cec0f89e2c48 53 // public class variables. Each sensor gets three variables -- one for each
mikekelly99 0:cec0f89e2c48 54 // axis. Call readGyro(), readAccel(), and readMag() first, before using
mikekelly99 0:cec0f89e2c48 55 // these variables!
mikekelly99 0:cec0f89e2c48 56 // These values are the RAW signed 16-bit readings from the sensors.
mikekelly99 0:cec0f89e2c48 57 int16_t gx, gy, gz; // x, y, and z axis readings of the gyroscope
mikekelly99 0:cec0f89e2c48 58 int16_t ax, ay, az; // x, y, and z axis readings of the accelerometer
mikekelly99 0:cec0f89e2c48 59 int16_t mx, my, mz; // x, y, and z axis readings of the magnetometer
mikekelly99 0:cec0f89e2c48 60 int16_t temperature; // Chip temperature
mikekelly99 0:cec0f89e2c48 61 float gBias[3], aBias[3], mBias[3];
mikekelly99 0:cec0f89e2c48 62 int16_t gBiasRaw[3], aBiasRaw[3], mBiasRaw[3];
mikekelly99 0:cec0f89e2c48 63
mikekelly99 0:cec0f89e2c48 64 // LSM9DS1 -- LSM9DS1 class constructor
mikekelly99 0:cec0f89e2c48 65 // The constructor will set up a handful of private variables, and set the
mikekelly99 0:cec0f89e2c48 66 // communication mode as well.
mikekelly99 0:cec0f89e2c48 67 /**Input:
mikekelly99 0:cec0f89e2c48 68 * - interface = Either IMU_MODE_SPI or IMU_MODE_I2C, whichever you're using
mikekelly99 0:cec0f89e2c48 69 * to talk to the IC.
mikekelly99 0:cec0f89e2c48 70 * - xgAddr = If IMU_MODE_I2C, this is the I2C address of the accel/gyroscope.
mikekelly99 0:cec0f89e2c48 71 * If IMU_MODE_SPI, this is the chip select pin of the gyro (CS_AG)
mikekelly99 0:cec0f89e2c48 72 * - mAddr = If IMU_MODE_I2C, this is the I2C address of the magnetometer.
mikekelly99 0:cec0f89e2c48 73 * If IMU_MODE_SPI, this is the cs pin of the magnetometer (CS_M)
mikekelly99 0:cec0f89e2c48 74
mikekelly99 0:cec0f89e2c48 75 */
mikekelly99 0:cec0f89e2c48 76 LSM9DS1(PinName sda, PinName scl, uint8_t xgAddr, uint8_t mAddr);
mikekelly99 0:cec0f89e2c48 77 //LSM9DS1(interface_mode interface, uint8_t xgAddr, uint8_t mAddr);
mikekelly99 0:cec0f89e2c48 78 //LSM9DS1();
mikekelly99 0:cec0f89e2c48 79
mikekelly99 0:cec0f89e2c48 80
mikekelly99 0:cec0f89e2c48 81 /** begin() -- Initialize the gyro, accelerometer, and magnetometer.
mikekelly99 0:cec0f89e2c48 82 *This will set up the scale and output rate of each sensor. The values set
mikekelly99 0:cec0f89e2c48 83 * in the IMUSettings struct will take effect after calling this function.
mikekelly99 0:cec0f89e2c48 84 */
mikekelly99 0:cec0f89e2c48 85 uint16_t begin();
mikekelly99 0:cec0f89e2c48 86
mikekelly99 0:cec0f89e2c48 87 void calibrate(bool autoCalc = true);
mikekelly99 0:cec0f89e2c48 88 void calibrateMag(bool loadIn = true);
mikekelly99 0:cec0f89e2c48 89 void magOffset(uint8_t axis, int16_t offset);
mikekelly99 0:cec0f89e2c48 90
mikekelly99 0:cec0f89e2c48 91 /** accelAvailable() -- Polls the accelerometer status register to check
mikekelly99 0:cec0f89e2c48 92 * if new data is available.
mikekelly99 0:cec0f89e2c48 93 * Output: 1 - New data available
mikekelly99 0:cec0f89e2c48 94 * 0 - No new data available
mikekelly99 0:cec0f89e2c48 95 */
mikekelly99 0:cec0f89e2c48 96 uint8_t accelAvailable();
mikekelly99 0:cec0f89e2c48 97
mikekelly99 0:cec0f89e2c48 98 /** gyroAvailable() -- Polls the gyroscope status register to check
mikekelly99 0:cec0f89e2c48 99 * if new data is available.
mikekelly99 0:cec0f89e2c48 100 * Output: 1 - New data available
mikekelly99 0:cec0f89e2c48 101 * 0 - No new data available
mikekelly99 0:cec0f89e2c48 102 */
mikekelly99 0:cec0f89e2c48 103 uint8_t gyroAvailable();
mikekelly99 0:cec0f89e2c48 104
mikekelly99 0:cec0f89e2c48 105 /** gyroAvailable() -- Polls the temperature status register to check
mikekelly99 0:cec0f89e2c48 106 * if new data is available.
mikekelly99 0:cec0f89e2c48 107 * Output: 1 - New data available
mikekelly99 0:cec0f89e2c48 108 * 0 - No new data available
mikekelly99 0:cec0f89e2c48 109 */
mikekelly99 0:cec0f89e2c48 110 uint8_t tempAvailable();
mikekelly99 0:cec0f89e2c48 111
mikekelly99 0:cec0f89e2c48 112 /** magAvailable() -- Polls the accelerometer status register to check
mikekelly99 0:cec0f89e2c48 113 * if new data is available.
mikekelly99 0:cec0f89e2c48 114 * Input:
mikekelly99 0:cec0f89e2c48 115 * - axis can be either X_AXIS, Y_AXIS, Z_AXIS, to check for new data
mikekelly99 0:cec0f89e2c48 116 * on one specific axis. Or ALL_AXIS (default) to check for new data
mikekelly99 0:cec0f89e2c48 117 * on all axes.
mikekelly99 0:cec0f89e2c48 118 * Output: 1 - New data available
mikekelly99 0:cec0f89e2c48 119 * 0 - No new data available
mikekelly99 0:cec0f89e2c48 120 */
mikekelly99 0:cec0f89e2c48 121 uint8_t magAvailable(lsm9ds1_axis axis = ALL_AXIS);
mikekelly99 0:cec0f89e2c48 122
mikekelly99 0:cec0f89e2c48 123 /** readGyro() -- Read the gyroscope output registers.
mikekelly99 0:cec0f89e2c48 124 * This function will read all six gyroscope output registers.
mikekelly99 0:cec0f89e2c48 125 * The readings are stored in the class' gx, gy, and gz variables. Read
mikekelly99 0:cec0f89e2c48 126 * those _after_ calling readGyro().
mikekelly99 0:cec0f89e2c48 127 */
mikekelly99 0:cec0f89e2c48 128 void readGyro();
mikekelly99 0:cec0f89e2c48 129
mikekelly99 0:cec0f89e2c48 130 /** int16_t readGyro(axis) -- Read a specific axis of the gyroscope.
mikekelly99 0:cec0f89e2c48 131 * [axis] can be any of X_AXIS, Y_AXIS, or Z_AXIS.
mikekelly99 0:cec0f89e2c48 132 * Input:
mikekelly99 0:cec0f89e2c48 133 * - axis: can be either X_AXIS, Y_AXIS, or Z_AXIS.
mikekelly99 0:cec0f89e2c48 134 * Output:
mikekelly99 0:cec0f89e2c48 135 * A 16-bit signed integer with sensor data on requested axis.
mikekelly99 0:cec0f89e2c48 136 */
mikekelly99 0:cec0f89e2c48 137 int16_t readGyro(lsm9ds1_axis axis);
mikekelly99 0:cec0f89e2c48 138
mikekelly99 0:cec0f89e2c48 139 /** readAccel() -- Read the accelerometer output registers.
mikekelly99 0:cec0f89e2c48 140 * This function will read all six accelerometer output registers.
mikekelly99 0:cec0f89e2c48 141 * The readings are stored in the class' ax, ay, and az variables. Read
mikekelly99 0:cec0f89e2c48 142 * those _after_ calling readAccel().
mikekelly99 0:cec0f89e2c48 143 */
mikekelly99 0:cec0f89e2c48 144 void readAccel();
mikekelly99 0:cec0f89e2c48 145
mikekelly99 0:cec0f89e2c48 146 /** int16_t readAccel(axis) -- Read a specific axis of the accelerometer.
mikekelly99 0:cec0f89e2c48 147 * [axis] can be any of X_AXIS, Y_AXIS, or Z_AXIS.
mikekelly99 0:cec0f89e2c48 148 * Input:
mikekelly99 0:cec0f89e2c48 149 * - axis: can be either X_AXIS, Y_AXIS, or Z_AXIS.
mikekelly99 0:cec0f89e2c48 150 * Output:
mikekelly99 0:cec0f89e2c48 151 * A 16-bit signed integer with sensor data on requested axis.
mikekelly99 0:cec0f89e2c48 152 */
mikekelly99 0:cec0f89e2c48 153 int16_t readAccel(lsm9ds1_axis axis);
mikekelly99 0:cec0f89e2c48 154
mikekelly99 0:cec0f89e2c48 155 /** readMag() -- Read the magnetometer output registers.
mikekelly99 0:cec0f89e2c48 156 * This function will read all six magnetometer output registers.
mikekelly99 0:cec0f89e2c48 157 * The readings are stored in the class' mx, my, and mz variables. Read
mikekelly99 0:cec0f89e2c48 158 * those _after_ calling readMag().
mikekelly99 0:cec0f89e2c48 159 */
mikekelly99 0:cec0f89e2c48 160 void readMag();
mikekelly99 0:cec0f89e2c48 161
mikekelly99 0:cec0f89e2c48 162 /** int16_t readMag(axis) -- Read a specific axis of the magnetometer.
mikekelly99 0:cec0f89e2c48 163 * [axis] can be any of X_AXIS, Y_AXIS, or Z_AXIS.
mikekelly99 0:cec0f89e2c48 164 * Input:
mikekelly99 0:cec0f89e2c48 165 * - axis: can be either X_AXIS, Y_AXIS, or Z_AXIS.
mikekelly99 0:cec0f89e2c48 166 * Output:
mikekelly99 0:cec0f89e2c48 167 * A 16-bit signed integer with sensor data on requested axis.
mikekelly99 0:cec0f89e2c48 168 */
mikekelly99 0:cec0f89e2c48 169 int16_t readMag(lsm9ds1_axis axis);
mikekelly99 0:cec0f89e2c48 170
mikekelly99 0:cec0f89e2c48 171 /** readTemp() -- Read the temperature output register.
mikekelly99 0:cec0f89e2c48 172 * This function will read two temperature output registers.
mikekelly99 0:cec0f89e2c48 173 * The combined readings are stored in the class' temperature variables. Read
mikekelly99 0:cec0f89e2c48 174 * those _after_ calling readTemp().
mikekelly99 0:cec0f89e2c48 175 */
mikekelly99 0:cec0f89e2c48 176 void readTemp();
mikekelly99 0:cec0f89e2c48 177
mikekelly99 0:cec0f89e2c48 178 /** calcGyro() -- Convert from RAW signed 16-bit value to degrees per second
mikekelly99 0:cec0f89e2c48 179 * This function reads in a signed 16-bit value and returns the scaled
mikekelly99 0:cec0f89e2c48 180 * DPS. This function relies on gScale and gRes being correct.
mikekelly99 0:cec0f89e2c48 181 * Input:
mikekelly99 0:cec0f89e2c48 182 * - gyro = A signed 16-bit raw reading from the gyroscope.
mikekelly99 0:cec0f89e2c48 183 */
mikekelly99 0:cec0f89e2c48 184 float calcGyro(int16_t gyro);
mikekelly99 0:cec0f89e2c48 185
mikekelly99 0:cec0f89e2c48 186 /** calcAccel() -- Convert from RAW signed 16-bit value to gravity (g's).
mikekelly99 0:cec0f89e2c48 187 * This function reads in a signed 16-bit value and returns the scaled
mikekelly99 0:cec0f89e2c48 188 * g's. This function relies on aScale and aRes being correct.
mikekelly99 0:cec0f89e2c48 189 * Input:
mikekelly99 0:cec0f89e2c48 190 * - accel = A signed 16-bit raw reading from the accelerometer.
mikekelly99 0:cec0f89e2c48 191 */
mikekelly99 0:cec0f89e2c48 192 float calcAccel(int16_t accel);
mikekelly99 0:cec0f89e2c48 193
mikekelly99 0:cec0f89e2c48 194 /** calcMag() -- Convert from RAW signed 16-bit value to Gauss (Gs)
mikekelly99 0:cec0f89e2c48 195 * This function reads in a signed 16-bit value and returns the scaled
mikekelly99 0:cec0f89e2c48 196 * Gs. This function relies on mScale and mRes being correct.
mikekelly99 0:cec0f89e2c48 197 * Input:
mikekelly99 0:cec0f89e2c48 198 * - mag = A signed 16-bit raw reading from the magnetometer.
mikekelly99 0:cec0f89e2c48 199 */
mikekelly99 0:cec0f89e2c48 200 float calcMag(int16_t mag);
mikekelly99 0:cec0f89e2c48 201
mikekelly99 0:cec0f89e2c48 202 /** setGyroScale() -- Set the full-scale range of the gyroscope.
mikekelly99 0:cec0f89e2c48 203 * This function can be called to set the scale of the gyroscope to
mikekelly99 0:cec0f89e2c48 204 * 245, 500, or 200 degrees per second.
mikekelly99 0:cec0f89e2c48 205 * Input:
mikekelly99 0:cec0f89e2c48 206 * - gScl = The desired gyroscope scale. Must be one of three possible
mikekelly99 0:cec0f89e2c48 207 * values from the gyro_scale.
mikekelly99 0:cec0f89e2c48 208 */
mikekelly99 0:cec0f89e2c48 209 void setGyroScale(uint16_t gScl);
mikekelly99 0:cec0f89e2c48 210
mikekelly99 0:cec0f89e2c48 211 /** setAccelScale() -- Set the full-scale range of the accelerometer.
mikekelly99 0:cec0f89e2c48 212 * This function can be called to set the scale of the accelerometer to
mikekelly99 0:cec0f89e2c48 213 * 2, 4, 6, 8, or 16 g's.
mikekelly99 0:cec0f89e2c48 214 * Input:
mikekelly99 0:cec0f89e2c48 215 * - aScl = The desired accelerometer scale. Must be one of five possible
mikekelly99 0:cec0f89e2c48 216 * values from the accel_scale.
mikekelly99 0:cec0f89e2c48 217 */
mikekelly99 0:cec0f89e2c48 218 void setAccelScale(uint8_t aScl);
mikekelly99 0:cec0f89e2c48 219
mikekelly99 0:cec0f89e2c48 220 /** setMagScale() -- Set the full-scale range of the magnetometer.
mikekelly99 0:cec0f89e2c48 221 * This function can be called to set the scale of the magnetometer to
mikekelly99 0:cec0f89e2c48 222 * 2, 4, 8, or 12 Gs.
mikekelly99 0:cec0f89e2c48 223 * Input:
mikekelly99 0:cec0f89e2c48 224 * - mScl = The desired magnetometer scale. Must be one of four possible
mikekelly99 0:cec0f89e2c48 225 * values from the mag_scale.
mikekelly99 0:cec0f89e2c48 226 */
mikekelly99 0:cec0f89e2c48 227 void setMagScale(uint8_t mScl);
mikekelly99 0:cec0f89e2c48 228
mikekelly99 0:cec0f89e2c48 229 /** setGyroODR() -- Set the output data rate and bandwidth of the gyroscope
mikekelly99 0:cec0f89e2c48 230 * Input:
mikekelly99 0:cec0f89e2c48 231 * - gRate = The desired output rate and cutoff frequency of the gyro.
mikekelly99 0:cec0f89e2c48 232 */
mikekelly99 0:cec0f89e2c48 233 void setGyroODR(uint8_t gRate);
mikekelly99 0:cec0f89e2c48 234
mikekelly99 0:cec0f89e2c48 235 // setAccelODR() -- Set the output data rate of the accelerometer
mikekelly99 0:cec0f89e2c48 236 // Input:
mikekelly99 0:cec0f89e2c48 237 // - aRate = The desired output rate of the accel.
mikekelly99 0:cec0f89e2c48 238 void setAccelODR(uint8_t aRate);
mikekelly99 0:cec0f89e2c48 239
mikekelly99 0:cec0f89e2c48 240 // setMagODR() -- Set the output data rate of the magnetometer
mikekelly99 0:cec0f89e2c48 241 // Input:
mikekelly99 0:cec0f89e2c48 242 // - mRate = The desired output rate of the mag.
mikekelly99 0:cec0f89e2c48 243 void setMagODR(uint8_t mRate);
mikekelly99 0:cec0f89e2c48 244
mikekelly99 0:cec0f89e2c48 245 // configInactivity() -- Configure inactivity interrupt parameters
mikekelly99 0:cec0f89e2c48 246 // Input:
mikekelly99 0:cec0f89e2c48 247 // - duration = Inactivity duration - actual value depends on gyro ODR
mikekelly99 0:cec0f89e2c48 248 // - threshold = Activity Threshold
mikekelly99 0:cec0f89e2c48 249 // - sleepOn = Gyroscope operating mode during inactivity.
mikekelly99 0:cec0f89e2c48 250 // true: gyroscope in sleep mode
mikekelly99 0:cec0f89e2c48 251 // false: gyroscope in power-down
mikekelly99 0:cec0f89e2c48 252 void configInactivity(uint8_t duration, uint8_t threshold, bool sleepOn);
mikekelly99 0:cec0f89e2c48 253
mikekelly99 0:cec0f89e2c48 254 // configAccelInt() -- Configure Accelerometer Interrupt Generator
mikekelly99 0:cec0f89e2c48 255 // Input:
mikekelly99 0:cec0f89e2c48 256 // - generator = Interrupt axis/high-low events
mikekelly99 0:cec0f89e2c48 257 // Any OR'd combination of ZHIE_XL, ZLIE_XL, YHIE_XL, YLIE_XL, XHIE_XL, XLIE_XL
mikekelly99 0:cec0f89e2c48 258 // - andInterrupts = AND/OR combination of interrupt events
mikekelly99 0:cec0f89e2c48 259 // true: AND combination
mikekelly99 0:cec0f89e2c48 260 // false: OR combination
mikekelly99 0:cec0f89e2c48 261 void configAccelInt(uint8_t generator, bool andInterrupts = false);
mikekelly99 0:cec0f89e2c48 262
mikekelly99 0:cec0f89e2c48 263 // configAccelThs() -- Configure the threshold of an accelereomter axis
mikekelly99 0:cec0f89e2c48 264 // Input:
mikekelly99 0:cec0f89e2c48 265 // - threshold = Interrupt threshold. Possible values: 0-255.
mikekelly99 0:cec0f89e2c48 266 // Multiply by 128 to get the actual raw accel value.
mikekelly99 0:cec0f89e2c48 267 // - axis = Axis to be configured. Either X_AXIS, Y_AXIS, or Z_AXIS
mikekelly99 0:cec0f89e2c48 268 // - duration = Duration value must be above or below threshold to trigger interrupt
mikekelly99 0:cec0f89e2c48 269 // - wait = Wait function on duration counter
mikekelly99 0:cec0f89e2c48 270 // true: Wait for duration samples before exiting interrupt
mikekelly99 0:cec0f89e2c48 271 // false: Wait function off
mikekelly99 0:cec0f89e2c48 272 void configAccelThs(uint8_t threshold, lsm9ds1_axis axis, uint8_t duration = 0, bool wait = 0);
mikekelly99 0:cec0f89e2c48 273
mikekelly99 0:cec0f89e2c48 274 // configGyroInt() -- Configure Gyroscope Interrupt Generator
mikekelly99 0:cec0f89e2c48 275 // Input:
mikekelly99 0:cec0f89e2c48 276 // - generator = Interrupt axis/high-low events
mikekelly99 0:cec0f89e2c48 277 // Any OR'd combination of ZHIE_G, ZLIE_G, YHIE_G, YLIE_G, XHIE_G, XLIE_G
mikekelly99 0:cec0f89e2c48 278 // - aoi = AND/OR combination of interrupt events
mikekelly99 0:cec0f89e2c48 279 // true: AND combination
mikekelly99 0:cec0f89e2c48 280 // false: OR combination
mikekelly99 0:cec0f89e2c48 281 // - latch: latch gyroscope interrupt request.
mikekelly99 0:cec0f89e2c48 282 void configGyroInt(uint8_t generator, bool aoi, bool latch);
mikekelly99 0:cec0f89e2c48 283
mikekelly99 0:cec0f89e2c48 284 // configGyroThs() -- Configure the threshold of a gyroscope axis
mikekelly99 0:cec0f89e2c48 285 // Input:
mikekelly99 0:cec0f89e2c48 286 // - threshold = Interrupt threshold. Possible values: 0-0x7FF.
mikekelly99 0:cec0f89e2c48 287 // Value is equivalent to raw gyroscope value.
mikekelly99 0:cec0f89e2c48 288 // - axis = Axis to be configured. Either X_AXIS, Y_AXIS, or Z_AXIS
mikekelly99 0:cec0f89e2c48 289 // - duration = Duration value must be above or below threshold to trigger interrupt
mikekelly99 0:cec0f89e2c48 290 // - wait = Wait function on duration counter
mikekelly99 0:cec0f89e2c48 291 // true: Wait for duration samples before exiting interrupt
mikekelly99 0:cec0f89e2c48 292 // false: Wait function off
mikekelly99 0:cec0f89e2c48 293 void configGyroThs(int16_t threshold, lsm9ds1_axis axis, uint8_t duration, bool wait);
mikekelly99 0:cec0f89e2c48 294
mikekelly99 0:cec0f89e2c48 295 // configInt() -- Configure INT1 or INT2 (Gyro and Accel Interrupts only)
mikekelly99 0:cec0f89e2c48 296 // Input:
mikekelly99 0:cec0f89e2c48 297 // - interrupt = Select INT1 or INT2
mikekelly99 0:cec0f89e2c48 298 // Possible values: XG_INT1 or XG_INT2
mikekelly99 0:cec0f89e2c48 299 // - generator = Or'd combination of interrupt generators.
mikekelly99 0:cec0f89e2c48 300 // Possible values: INT_DRDY_XL, INT_DRDY_G, INT1_BOOT (INT1 only), INT2_DRDY_TEMP (INT2 only)
mikekelly99 0:cec0f89e2c48 301 // INT_FTH, INT_OVR, INT_FSS5, INT_IG_XL (INT1 only), INT1_IG_G (INT1 only), INT2_INACT (INT2 only)
mikekelly99 0:cec0f89e2c48 302 // - activeLow = Interrupt active configuration
mikekelly99 0:cec0f89e2c48 303 // Can be either INT_ACTIVE_HIGH or INT_ACTIVE_LOW
mikekelly99 0:cec0f89e2c48 304 // - pushPull = Push-pull or open drain interrupt configuration
mikekelly99 0:cec0f89e2c48 305 // Can be either INT_PUSH_PULL or INT_OPEN_DRAIN
mikekelly99 0:cec0f89e2c48 306 void configInt(interrupt_select interupt, uint8_t generator,
mikekelly99 0:cec0f89e2c48 307 h_lactive activeLow = INT_ACTIVE_LOW, pp_od pushPull = INT_PUSH_PULL);
mikekelly99 0:cec0f89e2c48 308
mikekelly99 0:cec0f89e2c48 309 /** configMagInt() -- Configure Magnetometer Interrupt Generator
mikekelly99 0:cec0f89e2c48 310 * Input:
mikekelly99 0:cec0f89e2c48 311 * - generator = Interrupt axis/high-low events
mikekelly99 0:cec0f89e2c48 312 * Any OR'd combination of ZIEN, YIEN, XIEN
mikekelly99 0:cec0f89e2c48 313 * - activeLow = Interrupt active configuration
mikekelly99 0:cec0f89e2c48 314 * Can be either INT_ACTIVE_HIGH or INT_ACTIVE_LOW
mikekelly99 0:cec0f89e2c48 315 * - latch: latch gyroscope interrupt request.
mikekelly99 0:cec0f89e2c48 316 */
mikekelly99 0:cec0f89e2c48 317 void configMagInt(uint8_t generator, h_lactive activeLow, bool latch = true);
mikekelly99 0:cec0f89e2c48 318
mikekelly99 0:cec0f89e2c48 319 /** configMagThs() -- Configure the threshold of a gyroscope axis
mikekelly99 0:cec0f89e2c48 320 * Input:
mikekelly99 0:cec0f89e2c48 321 * - threshold = Interrupt threshold. Possible values: 0-0x7FF.
mikekelly99 0:cec0f89e2c48 322 * Value is equivalent to raw magnetometer value.
mikekelly99 0:cec0f89e2c48 323 */
mikekelly99 0:cec0f89e2c48 324 void configMagThs(uint16_t threshold);
mikekelly99 0:cec0f89e2c48 325
mikekelly99 0:cec0f89e2c48 326 //! getGyroIntSrc() -- Get contents of Gyroscope interrupt source register
mikekelly99 0:cec0f89e2c48 327 uint8_t getGyroIntSrc();
mikekelly99 0:cec0f89e2c48 328
mikekelly99 0:cec0f89e2c48 329 //! getGyroIntSrc() -- Get contents of accelerometer interrupt source register
mikekelly99 0:cec0f89e2c48 330 uint8_t getAccelIntSrc();
mikekelly99 0:cec0f89e2c48 331
mikekelly99 0:cec0f89e2c48 332 //! getGyroIntSrc() -- Get contents of magnetometer interrupt source register
mikekelly99 0:cec0f89e2c48 333 uint8_t getMagIntSrc();
mikekelly99 0:cec0f89e2c48 334
mikekelly99 0:cec0f89e2c48 335 //! getGyroIntSrc() -- Get status of inactivity interrupt
mikekelly99 0:cec0f89e2c48 336 uint8_t getInactivity();
mikekelly99 0:cec0f89e2c48 337
mikekelly99 0:cec0f89e2c48 338 /** sleepGyro() -- Sleep or wake the gyroscope
mikekelly99 0:cec0f89e2c48 339 * Input:
mikekelly99 0:cec0f89e2c48 340 * - enable: True = sleep gyro. False = wake gyro.
mikekelly99 0:cec0f89e2c48 341 */
mikekelly99 0:cec0f89e2c48 342 void sleepGyro(bool enable = true);
mikekelly99 0:cec0f89e2c48 343
mikekelly99 0:cec0f89e2c48 344 /** enableFIFO() - Enable or disable the FIFO
mikekelly99 0:cec0f89e2c48 345 * Input:
mikekelly99 0:cec0f89e2c48 346 * - enable: true = enable, false = disable.
mikekelly99 0:cec0f89e2c48 347 */
mikekelly99 0:cec0f89e2c48 348 void enableFIFO(bool enable = true);
mikekelly99 0:cec0f89e2c48 349
mikekelly99 0:cec0f89e2c48 350 /** setFIFO() - Configure FIFO mode and Threshold
mikekelly99 0:cec0f89e2c48 351 * Input:
mikekelly99 0:cec0f89e2c48 352 * - fifoMode: Set FIFO mode to off, FIFO (stop when full), continuous, bypass
mikekelly99 0:cec0f89e2c48 353 * Possible inputs: FIFO_OFF, FIFO_THS, FIFO_CONT_TRIGGER, FIFO_OFF_TRIGGER, FIFO_CONT
mikekelly99 0:cec0f89e2c48 354 * - fifoThs: FIFO threshold level setting
mikekelly99 0:cec0f89e2c48 355 * Any value from 0-0x1F is acceptable.
mikekelly99 0:cec0f89e2c48 356 */
mikekelly99 0:cec0f89e2c48 357 void setFIFO(fifoMode_type fifoMode, uint8_t fifoThs);
mikekelly99 0:cec0f89e2c48 358
mikekelly99 0:cec0f89e2c48 359 //! getFIFOSamples() - Get number of FIFO samples
mikekelly99 0:cec0f89e2c48 360 uint8_t getFIFOSamples();
mikekelly99 0:cec0f89e2c48 361
mikekelly99 0:cec0f89e2c48 362
mikekelly99 0:cec0f89e2c48 363 protected:
mikekelly99 0:cec0f89e2c48 364 // x_mAddress and gAddress store the I2C address or SPI chip select pin
mikekelly99 0:cec0f89e2c48 365 // for each sensor.
mikekelly99 0:cec0f89e2c48 366 uint8_t _mAddress, _xgAddress;
mikekelly99 0:cec0f89e2c48 367
mikekelly99 0:cec0f89e2c48 368 // gRes, aRes, and mRes store the current resolution for each sensor.
mikekelly99 0:cec0f89e2c48 369 // Units of these values would be DPS (or g's or Gs's) per ADC tick.
mikekelly99 0:cec0f89e2c48 370 // This value is calculated as (sensor scale) / (2^15).
mikekelly99 0:cec0f89e2c48 371 float gRes, aRes, mRes;
mikekelly99 0:cec0f89e2c48 372
mikekelly99 0:cec0f89e2c48 373 // _autoCalc keeps track of whether we're automatically subtracting off
mikekelly99 0:cec0f89e2c48 374 // accelerometer and gyroscope bias calculated in calibrate().
mikekelly99 0:cec0f89e2c48 375 bool _autoCalc;
mikekelly99 0:cec0f89e2c48 376
mikekelly99 0:cec0f89e2c48 377 // init() -- Sets up gyro, accel, and mag settings to default.
mikekelly99 0:cec0f89e2c48 378 // - interface - Sets the interface mode (IMU_MODE_I2C or IMU_MODE_SPI)
mikekelly99 0:cec0f89e2c48 379 // - xgAddr - Sets either the I2C address of the accel/gyro or SPI chip
mikekelly99 0:cec0f89e2c48 380 // select pin connected to the CS_XG pin.
mikekelly99 0:cec0f89e2c48 381 // - mAddr - Sets either the I2C address of the magnetometer or SPI chip
mikekelly99 0:cec0f89e2c48 382 // select pin connected to the CS_M pin.
mikekelly99 0:cec0f89e2c48 383 void init(interface_mode interface, uint8_t xgAddr, uint8_t mAddr);
mikekelly99 0:cec0f89e2c48 384
mikekelly99 0:cec0f89e2c48 385 // initGyro() -- Sets up the gyroscope to begin reading.
mikekelly99 0:cec0f89e2c48 386 // This function steps through all five gyroscope control registers.
mikekelly99 0:cec0f89e2c48 387 // Upon exit, the following parameters will be set:
mikekelly99 0:cec0f89e2c48 388 // - CTRL_REG1_G = 0x0F: Normal operation mode, all axes enabled.
mikekelly99 0:cec0f89e2c48 389 // 95 Hz ODR, 12.5 Hz cutoff frequency.
mikekelly99 0:cec0f89e2c48 390 // - CTRL_REG2_G = 0x00: HPF set to normal mode, cutoff frequency
mikekelly99 0:cec0f89e2c48 391 // set to 7.2 Hz (depends on ODR).
mikekelly99 0:cec0f89e2c48 392 // - CTRL_REG3_G = 0x88: Interrupt enabled on INT_G (set to push-pull and
mikekelly99 0:cec0f89e2c48 393 // active high). Data-ready output enabled on DRDY_G.
mikekelly99 0:cec0f89e2c48 394 // - CTRL_REG4_G = 0x00: Continuous update mode. Data LSB stored in lower
mikekelly99 0:cec0f89e2c48 395 // address. Scale set to 245 DPS. SPI mode set to 4-wire.
mikekelly99 0:cec0f89e2c48 396 // - CTRL_REG5_G = 0x00: FIFO disabled. HPF disabled.
mikekelly99 0:cec0f89e2c48 397 void initGyro();
mikekelly99 0:cec0f89e2c48 398
mikekelly99 0:cec0f89e2c48 399 // initAccel() -- Sets up the accelerometer to begin reading.
mikekelly99 0:cec0f89e2c48 400 // This function steps through all accelerometer related control registers.
mikekelly99 0:cec0f89e2c48 401 // Upon exit these registers will be set as:
mikekelly99 0:cec0f89e2c48 402 // - CTRL_REG0_XM = 0x00: FIFO disabled. HPF bypassed. Normal mode.
mikekelly99 0:cec0f89e2c48 403 // - CTRL_REG1_XM = 0x57: 100 Hz data rate. Continuous update.
mikekelly99 0:cec0f89e2c48 404 // all axes enabled.
mikekelly99 0:cec0f89e2c48 405 // - CTRL_REG2_XM = 0x00: 2g scale. 773 Hz anti-alias filter BW.
mikekelly99 0:cec0f89e2c48 406 // - CTRL_REG3_XM = 0x04: Accel data ready signal on INT1_XM pin.
mikekelly99 0:cec0f89e2c48 407 void initAccel();
mikekelly99 0:cec0f89e2c48 408
mikekelly99 0:cec0f89e2c48 409 // initMag() -- Sets up the magnetometer to begin reading.
mikekelly99 0:cec0f89e2c48 410 // This function steps through all magnetometer-related control registers.
mikekelly99 0:cec0f89e2c48 411 // Upon exit these registers will be set as:
mikekelly99 0:cec0f89e2c48 412 // - CTRL_REG4_XM = 0x04: Mag data ready signal on INT2_XM pin.
mikekelly99 0:cec0f89e2c48 413 // - CTRL_REG5_XM = 0x14: 100 Hz update rate. Low resolution. Interrupt
mikekelly99 0:cec0f89e2c48 414 // requests don't latch. Temperature sensor disabled.
mikekelly99 0:cec0f89e2c48 415 // - CTRL_REG6_XM = 0x00: 2 Gs scale.
mikekelly99 0:cec0f89e2c48 416 // - CTRL_REG7_XM = 0x00: Continuous conversion mode. Normal HPF mode.
mikekelly99 0:cec0f89e2c48 417 // - INT_CTRL_REG_M = 0x09: Interrupt active-high. Enable interrupts.
mikekelly99 0:cec0f89e2c48 418 void initMag();
mikekelly99 0:cec0f89e2c48 419
mikekelly99 0:cec0f89e2c48 420 // gReadByte() -- Reads a byte from a specified gyroscope register.
mikekelly99 0:cec0f89e2c48 421 // Input:
mikekelly99 0:cec0f89e2c48 422 // - subAddress = Register to be read from.
mikekelly99 0:cec0f89e2c48 423 // Output:
mikekelly99 0:cec0f89e2c48 424 // - An 8-bit value read from the requested address.
mikekelly99 0:cec0f89e2c48 425 uint8_t mReadByte(uint8_t subAddress);
mikekelly99 0:cec0f89e2c48 426
mikekelly99 0:cec0f89e2c48 427 // gReadBytes() -- Reads a number of bytes -- beginning at an address
mikekelly99 0:cec0f89e2c48 428 // and incrementing from there -- from the gyroscope.
mikekelly99 0:cec0f89e2c48 429 // Input:
mikekelly99 0:cec0f89e2c48 430 // - subAddress = Register to be read from.
mikekelly99 0:cec0f89e2c48 431 // - * dest = A pointer to an array of uint8_t's. Values read will be
mikekelly99 0:cec0f89e2c48 432 // stored in here on return.
mikekelly99 0:cec0f89e2c48 433 // - count = The number of bytes to be read.
mikekelly99 0:cec0f89e2c48 434 // Output: No value is returned, but the `dest` array will store
mikekelly99 0:cec0f89e2c48 435 // the data read upon exit.
mikekelly99 0:cec0f89e2c48 436 void mReadBytes(uint8_t subAddress, uint8_t * dest, uint8_t count);
mikekelly99 0:cec0f89e2c48 437
mikekelly99 0:cec0f89e2c48 438 // gWriteByte() -- Write a byte to a register in the gyroscope.
mikekelly99 0:cec0f89e2c48 439 // Input:
mikekelly99 0:cec0f89e2c48 440 // - subAddress = Register to be written to.
mikekelly99 0:cec0f89e2c48 441 // - data = data to be written to the register.
mikekelly99 0:cec0f89e2c48 442 void mWriteByte(uint8_t subAddress, uint8_t data);
mikekelly99 0:cec0f89e2c48 443
mikekelly99 0:cec0f89e2c48 444 // xmReadByte() -- Read a byte from a register in the accel/mag sensor
mikekelly99 0:cec0f89e2c48 445 // Input:
mikekelly99 0:cec0f89e2c48 446 // - subAddress = Register to be read from.
mikekelly99 0:cec0f89e2c48 447 // Output:
mikekelly99 0:cec0f89e2c48 448 // - An 8-bit value read from the requested register.
mikekelly99 0:cec0f89e2c48 449 uint8_t xgReadByte(uint8_t subAddress);
mikekelly99 0:cec0f89e2c48 450
mikekelly99 0:cec0f89e2c48 451 // xmReadBytes() -- Reads a number of bytes -- beginning at an address
mikekelly99 0:cec0f89e2c48 452 // and incrementing from there -- from the accelerometer/magnetometer.
mikekelly99 0:cec0f89e2c48 453 // Input:
mikekelly99 0:cec0f89e2c48 454 // - subAddress = Register to be read from.
mikekelly99 0:cec0f89e2c48 455 // - * dest = A pointer to an array of uint8_t's. Values read will be
mikekelly99 0:cec0f89e2c48 456 // stored in here on return.
mikekelly99 0:cec0f89e2c48 457 // - count = The number of bytes to be read.
mikekelly99 0:cec0f89e2c48 458 // Output: No value is returned, but the `dest` array will store
mikekelly99 0:cec0f89e2c48 459 // the data read upon exit.
mikekelly99 0:cec0f89e2c48 460 void xgReadBytes(uint8_t subAddress, uint8_t * dest, uint8_t count);
mikekelly99 0:cec0f89e2c48 461
mikekelly99 0:cec0f89e2c48 462 // xmWriteByte() -- Write a byte to a register in the accel/mag sensor.
mikekelly99 0:cec0f89e2c48 463 // Input:
mikekelly99 0:cec0f89e2c48 464 // - subAddress = Register to be written to.
mikekelly99 0:cec0f89e2c48 465 // - data = data to be written to the register.
mikekelly99 0:cec0f89e2c48 466 void xgWriteByte(uint8_t subAddress, uint8_t data);
mikekelly99 0:cec0f89e2c48 467
mikekelly99 0:cec0f89e2c48 468 // calcgRes() -- Calculate the resolution of the gyroscope.
mikekelly99 0:cec0f89e2c48 469 // This function will set the value of the gRes variable. gScale must
mikekelly99 0:cec0f89e2c48 470 // be set prior to calling this function.
mikekelly99 0:cec0f89e2c48 471 void calcgRes();
mikekelly99 0:cec0f89e2c48 472
mikekelly99 0:cec0f89e2c48 473 // calcmRes() -- Calculate the resolution of the magnetometer.
mikekelly99 0:cec0f89e2c48 474 // This function will set the value of the mRes variable. mScale must
mikekelly99 0:cec0f89e2c48 475 // be set prior to calling this function.
mikekelly99 0:cec0f89e2c48 476 void calcmRes();
mikekelly99 0:cec0f89e2c48 477
mikekelly99 0:cec0f89e2c48 478 // calcaRes() -- Calculate the resolution of the accelerometer.
mikekelly99 0:cec0f89e2c48 479 // This function will set the value of the aRes variable. aScale must
mikekelly99 0:cec0f89e2c48 480 // be set prior to calling this function.
mikekelly99 0:cec0f89e2c48 481 void calcaRes();
mikekelly99 0:cec0f89e2c48 482
mikekelly99 0:cec0f89e2c48 483 //////////////////////
mikekelly99 0:cec0f89e2c48 484 // Helper Functions //
mikekelly99 0:cec0f89e2c48 485 //////////////////////
mikekelly99 0:cec0f89e2c48 486 void constrainScales();
mikekelly99 0:cec0f89e2c48 487
mikekelly99 0:cec0f89e2c48 488 ///////////////////
mikekelly99 0:cec0f89e2c48 489 // SPI Functions //
mikekelly99 0:cec0f89e2c48 490 ///////////////////
mikekelly99 0:cec0f89e2c48 491 // initSPI() -- Initialize the SPI hardware.
mikekelly99 0:cec0f89e2c48 492 // This function will setup all SPI pins and related hardware.
mikekelly99 0:cec0f89e2c48 493 void initSPI();
mikekelly99 0:cec0f89e2c48 494
mikekelly99 0:cec0f89e2c48 495 // SPIwriteByte() -- Write a byte out of SPI to a register in the device
mikekelly99 0:cec0f89e2c48 496 // Input:
mikekelly99 0:cec0f89e2c48 497 // - csPin = The chip select pin of the slave device.
mikekelly99 0:cec0f89e2c48 498 // - subAddress = The register to be written to.
mikekelly99 0:cec0f89e2c48 499 // - data = Byte to be written to the register.
mikekelly99 0:cec0f89e2c48 500 void SPIwriteByte(uint8_t csPin, uint8_t subAddress, uint8_t data);
mikekelly99 0:cec0f89e2c48 501
mikekelly99 0:cec0f89e2c48 502 // SPIreadByte() -- Read a single byte from a register over SPI.
mikekelly99 0:cec0f89e2c48 503 // Input:
mikekelly99 0:cec0f89e2c48 504 // - csPin = The chip select pin of the slave device.
mikekelly99 0:cec0f89e2c48 505 // - subAddress = The register to be read from.
mikekelly99 0:cec0f89e2c48 506 // Output:
mikekelly99 0:cec0f89e2c48 507 // - The byte read from the requested address.
mikekelly99 0:cec0f89e2c48 508 uint8_t SPIreadByte(uint8_t csPin, uint8_t subAddress);
mikekelly99 0:cec0f89e2c48 509
mikekelly99 0:cec0f89e2c48 510 // SPIreadBytes() -- Read a series of bytes, starting at a register via SPI
mikekelly99 0:cec0f89e2c48 511 // Input:
mikekelly99 0:cec0f89e2c48 512 // - csPin = The chip select pin of a slave device.
mikekelly99 0:cec0f89e2c48 513 // - subAddress = The register to begin reading.
mikekelly99 0:cec0f89e2c48 514 // - * dest = Pointer to an array where we'll store the readings.
mikekelly99 0:cec0f89e2c48 515 // - count = Number of registers to be read.
mikekelly99 0:cec0f89e2c48 516 // Output: No value is returned by the function, but the registers read are
mikekelly99 0:cec0f89e2c48 517 // all stored in the *dest array given.
mikekelly99 0:cec0f89e2c48 518 void SPIreadBytes(uint8_t csPin, uint8_t subAddress,
mikekelly99 0:cec0f89e2c48 519 uint8_t * dest, uint8_t count);
mikekelly99 0:cec0f89e2c48 520
mikekelly99 0:cec0f89e2c48 521 ///////////////////
mikekelly99 0:cec0f89e2c48 522 // I2C Functions //
mikekelly99 0:cec0f89e2c48 523 ///////////////////
mikekelly99 0:cec0f89e2c48 524 // initI2C() -- Initialize the I2C hardware.
mikekelly99 0:cec0f89e2c48 525 // This function will setup all I2C pins and related hardware.
mikekelly99 0:cec0f89e2c48 526 void initI2C();
mikekelly99 0:cec0f89e2c48 527
mikekelly99 0:cec0f89e2c48 528 // I2CwriteByte() -- Write a byte out of I2C to a register in the device
mikekelly99 0:cec0f89e2c48 529 // Input:
mikekelly99 0:cec0f89e2c48 530 // - address = The 7-bit I2C address of the slave device.
mikekelly99 0:cec0f89e2c48 531 // - subAddress = The register to be written to.
mikekelly99 0:cec0f89e2c48 532 // - data = Byte to be written to the register.
mikekelly99 0:cec0f89e2c48 533 void I2CwriteByte(uint8_t address, uint8_t subAddress, uint8_t data);
mikekelly99 0:cec0f89e2c48 534
mikekelly99 0:cec0f89e2c48 535 // I2CreadByte() -- Read a single byte from a register over I2C.
mikekelly99 0:cec0f89e2c48 536 // Input:
mikekelly99 0:cec0f89e2c48 537 // - address = The 7-bit I2C address of the slave device.
mikekelly99 0:cec0f89e2c48 538 // - subAddress = The register to be read from.
mikekelly99 0:cec0f89e2c48 539 // Output:
mikekelly99 0:cec0f89e2c48 540 // - The byte read from the requested address.
mikekelly99 0:cec0f89e2c48 541 uint8_t I2CreadByte(uint8_t address, uint8_t subAddress);
mikekelly99 0:cec0f89e2c48 542
mikekelly99 0:cec0f89e2c48 543 // I2CreadBytes() -- Read a series of bytes, starting at a register via SPI
mikekelly99 0:cec0f89e2c48 544 // Input:
mikekelly99 0:cec0f89e2c48 545 // - address = The 7-bit I2C address of the slave device.
mikekelly99 0:cec0f89e2c48 546 // - subAddress = The register to begin reading.
mikekelly99 0:cec0f89e2c48 547 // - * dest = Pointer to an array where we'll store the readings.
mikekelly99 0:cec0f89e2c48 548 // - count = Number of registers to be read.
mikekelly99 0:cec0f89e2c48 549 // Output: No value is returned by the function, but the registers read are
mikekelly99 0:cec0f89e2c48 550 // all stored in the *dest array given.
mikekelly99 0:cec0f89e2c48 551 uint8_t I2CreadBytes(uint8_t address, uint8_t subAddress, uint8_t * dest, uint8_t count);
mikekelly99 0:cec0f89e2c48 552
mikekelly99 0:cec0f89e2c48 553 private:
mikekelly99 0:cec0f89e2c48 554 I2C i2c;
mikekelly99 0:cec0f89e2c48 555 };
mikekelly99 0:cec0f89e2c48 556
mikekelly99 0:cec0f89e2c48 557 #endif // SFE_LSM9DS1_H //