LSM9DS1 IMU sensor driver

Dependents:   LSM_imu Izu_2019

Revision:
2:2ba419ea901e
Parent:
0:622e8874902e
--- a/LSM9DS1.cpp	Mon Oct 19 13:56:52 2015 +0000
+++ b/LSM9DS1.cpp	Sat Mar 02 15:15:14 2019 +0000
@@ -398,4 +398,30 @@
             mRes = 16.0 / 32768.0;
             break;
     }
+}
+
+bool LSM9DS1::whoAmI(){
+    uint8_t resultXG,resultM ,whoAmIAddressXG=WHO_AM_I_XG,whoAmIAddressM=WHO_AM_I_M;
+    
+    //acc gyro
+    i2c.start();
+    i2c.write(xgAddress);
+    i2c.write(whoAmIAddressXG);
+    i2c.write(xgAddress | 1);
+    resultXG = i2c.read(whoAmIAddressXG);
+    i2c.stop();
+    
+    //magn
+    i2c.start();
+    i2c.write(xgAddress);
+    i2c.write(whoAmIAddressM);
+    i2c.write(xgAddress | 1);
+    resultM = i2c.read(whoAmIAddressM);
+    i2c.stop();
+    
+    uint16_t combinedResult = (resultXG << 8) | resultM;
+    if(combinedResult!=((whoAmIAddressXG << 8) | whoAmIAddressM))
+        return true;
+    else
+        return false;
 }
\ No newline at end of file