22 #ifndef __SparkFunLSM9DS1_H__
23 #define __SparkFunLSM9DS1_H__
25 #if defined(ARDUINO) && ARDUINO >= 100
29 #include "pins_arduino.h"
32 #include "LSM9DS1_Registers.h"
33 #include "LSM9DS1_Types.h"
35 #define LSM9DS1_AG_ADDR(sa0) ((sa0) == 0 ? 0x6A : 0x6B)
36 #define LSM9DS1_M_ADDR(sa1) ((sa1) == 0 ? 0x1C : 0x1E)
59 float gBias[3], aBias[3], mBias[3];
60 int16_t gBiasRaw[3], aBiasRaw[3], mBiasRaw[3];
72 LSM9DS1(interface_mode interface, uint8_t xgAddr, uint8_t mAddr);
80 void calibrate(
bool autoCalc =
true);
81 void calibrateMag(
bool loadIn =
true);
82 void magOffset(uint8_t axis, int16_t offset);
88 uint8_t accelAvailable();
94 uint8_t gyroAvailable();
100 uint8_t tempAvailable();
110 uint8_t magAvailable(lsm9ds1_axis axis = ALL_AXIS);
124 int16_t readGyro(lsm9ds1_axis axis);
138 int16_t readAccel(lsm9ds1_axis axis);
152 int16_t readMag(lsm9ds1_axis axis);
165 float calcGyro(int16_t gyro);
172 float calcAccel(int16_t accel);
179 float calcMag(int16_t mag);
187 void setGyroScale(uint16_t gScl);
195 void setAccelScale(uint8_t aScl);
203 void setMagScale(uint8_t mScl);
208 void setGyroODR(uint8_t gRate);
213 void setAccelODR(uint8_t aRate);
218 void setMagODR(uint8_t mRate);
227 void configInactivity(uint8_t duration, uint8_t threshold,
bool sleepOn);
236 void configAccelInt(uint8_t generator,
bool andInterrupts =
false);
247 void configAccelThs(uint8_t threshold, lsm9ds1_axis axis, uint8_t duration = 0,
bool wait = 0);
257 void configGyroInt(uint8_t generator,
bool aoi,
bool latch);
268 void configGyroThs(int16_t threshold, lsm9ds1_axis axis, uint8_t duration,
bool wait);
281 void configInt(interrupt_select interupt, uint8_t generator,
282 h_lactive activeLow = INT_ACTIVE_LOW, pp_od pushPull = INT_PUSH_PULL);
291 void configMagInt(uint8_t generator, h_lactive activeLow,
bool latch =
true);
297 void configMagThs(uint16_t threshold);
300 uint8_t getGyroIntSrc();
303 uint8_t getAccelIntSrc();
306 uint8_t getMagIntSrc();
309 uint8_t getInactivity();
314 void sleepGyro(
bool enable =
true);
319 void enableFIFO(
bool enable =
true);
327 void setFIFO(fifoMode_type fifoMode, uint8_t fifoThs);
330 uint8_t getFIFOSamples();
336 uint8_t _mAddress, _xgAddress;
341 float gRes, aRes, mRes;
353 void init(interface_mode interface, uint8_t xgAddr, uint8_t mAddr);
395 uint8_t mReadByte(uint8_t subAddress);
406 uint8_t mReadBytes(uint8_t subAddress, uint8_t * dest, uint8_t count);
412 void mWriteByte(uint8_t subAddress, uint8_t data);
419 uint8_t xgReadByte(uint8_t subAddress);
430 uint8_t xgReadBytes(uint8_t subAddress, uint8_t * dest, uint8_t count);
436 void xgWriteByte(uint8_t subAddress, uint8_t data);
456 void constrainScales();
470 void SPIwriteByte(uint8_t csPin, uint8_t subAddress, uint8_t data);
478 uint8_t SPIreadByte(uint8_t csPin, uint8_t subAddress);
488 uint8_t SPIreadBytes(uint8_t csPin, uint8_t subAddress,
489 uint8_t * dest, uint8_t count);
503 void I2CwriteByte(uint8_t address, uint8_t subAddress, uint8_t data);
511 uint8_t I2CreadByte(uint8_t address, uint8_t subAddress);
521 uint8_t I2CreadBytes(uint8_t address, uint8_t subAddress, uint8_t * dest, uint8_t count);
524 #endif // SFE_LSM9DS1_H //
Definition: SparkFunLSM9DS1.h:45
uint16_t begin()
Definition: SparkFunLSM9DS1.cpp:153
Definition: LSM9DS1_Types.h:240