IMU LSM9DS1 Library

Dependencies:   PinDetect mbed

Dependents:   Latch9DOF_LSM9DS1

Fork of LSM9DS1_Library by Jason Mar

Files at this revision

API Documentation at this revision

Comitter:
afmiee
Date:
Fri Jul 15 22:37:51 2016 +0000
Parent:
1:87d535bf8c53
Child:
3:585984c4a4b1
Commit message:
Made some minor changes to library to compile

Changed in this revision

LSM9DS1.cpp Show annotated file Show diff for this revision Revisions of this file
LSM9DS1.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
--- a/LSM9DS1.cpp	Mon Oct 26 16:14:04 2015 +0000
+++ b/LSM9DS1.cpp	Fri Jul 15 22:37:51 2016 +0000
@@ -24,19 +24,11 @@
 #include "LSM9DS1.h"
 #include "LSM9DS1_Registers.h"
 #include "LSM9DS1_Types.h"
-//#include <Wire.h> // Wire library is used for I2C
-//#include <SPI.h>  // SPI library is used for...SPI.
-
-//#if defined(ARDUINO) && ARDUINO >= 100
-//  #include "Arduino.h"
-//#else
-//  #include "WProgram.h"
-//#endif
 
 #define LSM9DS1_COMMUNICATION_TIMEOUT 1000
 
 float magSensitivity[4] = {0.00014, 0.00029, 0.00043, 0.00058};
-extern Serial pc;
+extern Serial debug;
 
 LSM9DS1::LSM9DS1(PinName sda, PinName scl, uint8_t xgAddr, uint8_t mAddr)
     :i2c(sda, scl)
@@ -170,7 +162,7 @@
     // each device. Store those in a variable so we can return them.
     uint8_t mTest = mReadByte(WHO_AM_I_M);      // Read the gyro WHO_AM_I
     uint8_t xgTest = xgReadByte(WHO_AM_I_XG);   // Read the accel/mag WHO_AM_I
-    pc.printf("%x, %x, %x, %x\n\r", mTest, xgTest, _xgAddress, _mAddress);
+    debug.printf("%x, %x, %x, %x\n\r", mTest, xgTest, _xgAddress, _mAddress);
     uint16_t whoAmICombined = (xgTest << 8) | mTest;
     
     if (whoAmICombined != ((WHO_AM_I_AG_RSP << 8) | WHO_AM_I_M_RSP))
--- a/LSM9DS1.h	Mon Oct 26 16:14:04 2015 +0000
+++ b/LSM9DS1.h	Fri Jul 15 22:37:51 2016 +0000
@@ -312,7 +312,8 @@
     *    Any OR'd combination of ZIEN, YIEN, XIEN
     *  - activeLow = Interrupt active configuration
     *    Can be either INT_ACTIVE_HIGH or INT_ACTIVE_LOW
-    */  - latch: latch gyroscope interrupt request.
+    *  - latch: latch gyroscope interrupt request.
+    */
     void configMagInt(uint8_t generator, h_lactive activeLow, bool latch = true);
     
     /** configMagThs() -- Configure the threshold of a gyroscope axis
--- a/main.cpp	Mon Oct 26 16:14:04 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#include "LSM9DS1.h"
-
-DigitalOut myled(LED1);
-Serial pc(USBTX, USBRX);
-
-int main() {
-    //LSM9DS1 lol(p9, p10, 0x6B, 0x1E);
-    LSM9DS1 lol(p9, p10, 0xD6, 0x3C);
-    lol.begin();
-    if (!lol.begin()) {
-        pc.printf("Failed to communicate with LSM9DS1.\n");
-    }
-    lol.calibrate();
-    while(1) {
-        lol.readTemp();
-        lol.readMag();
-        lol.readGyro();
-        
-        //pc.printf("%d %d %d %d %d %d %d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz), lol.ax, lol.ay, lol.az, lol.mx, lol.my, lol.mz);
-        //pc.printf("%d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz));
-        pc.printf("gyro: %d %d %d\n\r", lol.gx, lol.gy, lol.gz);
-        pc.printf("accel: %d %d %d\n\r", lol.ax, lol.ay, lol.az);
-        pc.printf("mag: %d %d %d\n\n\r", lol.mx, lol.my, lol.mz);
-        myled = 1;
-        wait(2);
-        myled = 0;
-        wait(2);
-    }
-}