lsm6ds3 library working on mbed-os 5

Dependents:   STM32_LOGGER

Revision:
1:924c7dea286e
Parent:
0:46630122dec9
Child:
2:ed14e6196255
--- a/LSM6DS3.cpp	Thu Jun 16 20:07:13 2016 +0000
+++ b/LSM6DS3.cpp	Mon Jun 20 19:15:31 2016 +0000
@@ -52,7 +52,7 @@
 {
     char cmd[4] = {
         CTRL2_G,
-        gScale | G_ODR_119_BW_14,
+        gScale | G_ODR_104,
         0,          // Default data out and int out
         0           // Default power mode and high pass settings
     };
@@ -66,7 +66,7 @@
     char cmd[4] = {
         CTRL1_XL,
         0x38,       // Enable all axis and don't decimate data in out Registers
-        (A_ODR_119 << 5) | (aScale << 3) | (A_BW_AUTO_SCALE),   // 119 Hz ODR, set scale, and auto BW
+        (A_ODR_104 << 5) | (aScale << 3) | (A_BW_AUTO_SCALE),   // 119 Hz ODR, set scale, and auto BW
         0           // Default resolution mode and filtering settings
     };
 
@@ -238,6 +238,24 @@
         CTRL2_G,
         0
     };
+    
+    // Set low power based on ODR, else keep sensor on high performance
+    if(gRate == G_ODR_13_BW_0 | gRate == G_ODR_26_BW_2 | gRate == G_ODR_52_BW_16) {
+        char cmdLow[2] ={
+            CTRL7_G,
+            1
+        };
+        
+        i2c.write(xgAddress, cmdLow, 2);
+    }
+    else {
+        char cmdLow[2] ={
+            CTRL7_G,
+            0
+        };
+        
+        i2c.write(xgAddress, cmdLow, 2);
+    }
 
     // Write the address we are going to read from and don't end the transaction
     i2c.write(xgAddress, cmd, 1, true);
@@ -260,6 +278,24 @@
         CTRL1_XL,
         0
     };
+    
+    // Set low power based on ODR, else keep sensor on high performance
+    if(aRate == A_ODR_13 | aRate == A_ODR_26 | aRate == A_ODR_52) {
+        char cmdLow[2] ={
+            CTRL6_C,
+            1
+        };
+        
+        i2c.write(xgAddress, cmdLow, 2);
+    }
+    else {
+        char cmdLow[2] ={
+            CTRL6_C,
+            0
+        };
+        
+        i2c.write(xgAddress, cmdLow, 2);
+    }
 
     // Write the address we are going to read from and don't end the transaction
     i2c.write(xgAddress, cmd, 1, true);