Library for Bosch Sensortech BMI160 IMU

Fork of BMI160 by Justin Jordan

Revision:
12:64931a80340d
Parent:
10:9e219f2f1fb3
Child:
14:646eb94fa2eb
diff -r 24602ff07e9f -r 64931a80340d bmi160.cpp
--- a/bmi160.cpp	Tue Dec 20 01:29:56 2016 +0000
+++ b/bmi160.cpp	Tue Dec 20 18:38:42 2016 +0000
@@ -66,38 +66,19 @@
 
 
 //*****************************************************************************
-int32_t BMI160::getTemperature(float *temp)
+int32_t setAccConfig(const AccConfig &config)
 {
+    int32_t rtnVal = -1;
     uint8_t data[2];
-    uint16_t rawTemp;
     
-    int32_t rtnVal = readBlock(TEMPERATURE_0, TEMPERATURE_1, data);
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        rawTemp = ((data[1] << 8) | data[0]);
-        if(rawTemp & 0x8000)
-        {
-            *temp = (23.0F - ((0x10000 - rawTemp)/512.0F));
-        }
-        else
-        {
-            *temp = ((rawTemp/512.0F) + 23.0F);
-        }
-    }
+    
     
     return rtnVal;
 }
 
 
 //*****************************************************************************
-int32_t BMI160::getSensorDataAndTime(uint8_t *data)
-{
-    return readBlock(DATA_0, SENSORTIME_2, data);
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getAccAxis(SensorAxis axis, AxisData &data, AccConfig accConfig)
+int32_t BMI160::getAccAxis(SensorAxis axis, AxisData &data, AccRange range)
 {
     uint8_t localData[2];
     int32_t rtnVal;
@@ -124,7 +105,7 @@
     if(rtnVal == RTN_NO_ERROR)
     {
         data.raw = ((localData[1] << 8) | localData[0]);
-        switch(accConfig.range)
+        switch(range)
         {
             //magic numbers are typical values for LSB/g from EC table
             case SENS_2G:
@@ -150,7 +131,7 @@
     
 
 //*****************************************************************************    
-int32_t BMI160::getAccXYZ(SensorData &data, AccConfig accConfig)
+int32_t BMI160::getAccXYZ(SensorData &data, AccRange range)
 {
     uint8_t localData[6];
     int32_t rtnVal = readBlock(DATA_14, DATA_19, localData);
@@ -161,7 +142,7 @@
         data.yAxis.raw = ((localData[3] << 8) | localData[2]);
         data.zAxis.raw = ((localData[5] << 8) | localData[4]);
         
-        switch(accConfig.range)
+        switch(range)
         {
             //magic numbers are typical values for LSB/g from EC table
             case SENS_2G:
@@ -208,3 +189,26 @@
     return rtnVal;
 }
 
+
+//*****************************************************************************
+int32_t BMI160::getTemperature(float *temp)
+{
+    uint8_t data[2];
+    uint16_t rawTemp;
+    
+    int32_t rtnVal = readBlock(TEMPERATURE_0, TEMPERATURE_1, data);
+    if(rtnVal == RTN_NO_ERROR)
+    {
+        rawTemp = ((data[1] << 8) | data[0]);
+        if(rawTemp & 0x8000)
+        {
+            *temp = (23.0F - ((0x10000 - rawTemp)/512.0F));
+        }
+        else
+        {
+            *temp = ((rawTemp/512.0F) + 23.0F);
+        }
+    }
+    
+    return rtnVal;
+}