Revert "bosch_bmi160: add support for host reporting of accel bias"

This reverts commit 97b440fd12f800a43b673b68510b53a41d7c1d54.

Merge conflict resolved by leaving BMI160 driver version set to 10.

Change-Id: Ifd83932e3678d31d68f97128d1cc950552ea978f
diff --git a/firmware/inc/algos/accel_cal.h b/firmware/inc/algos/accel_cal.h
index e3204a9..b2f818c 100644
--- a/firmware/inc/algos/accel_cal.h
+++ b/firmware/inc/algos/accel_cal.h
@@ -162,11 +162,7 @@
 void accelCalDestroy(struct accelCal_t *acc);
 
 // Ensures that the offset is only updated during Sensor power down.
-bool accelCalUpdateBias(struct accelCal_t *acc,
-                        float *x, float *y, float *z);
-
-void accelCalBiasSet(struct accelCal_t *acc,
-                     float x, float y, float z);
+void accelCalUpdateBias(struct accelCal_t *acc);
 
 void accelCalBiasRemove(struct accelCal_t *acc,
                         float *x, float *y, float *z);
diff --git a/firmware/src/algos/accel_cal.c b/firmware/src/algos/accel_cal.c
index a1db612..953074f 100644
--- a/firmware/src/algos/accel_cal.c
+++ b/firmware/src/algos/accel_cal.c
@@ -444,33 +444,11 @@
     return eigen_pass;
 }
 
-// Updating the new bias and save to pointers. Return true if the bias changed.
-bool accelCalUpdateBias(struct accelCal_t *acc, float *x, float *y, float *z) {
-  *x = acc->x_bias_new;
-  *y = acc->y_bias_new;
-  *z = acc->z_bias_new;
-
-  // Check to see if the bias changed since last call to accelCalUpdateBias.
-  // Compiler does not allow us to use "==" and "!=" when comparing floats, so
-  // just use "<" and ">".
-  if ((acc->x_bias < acc->x_bias_new) || (acc->x_bias > acc->x_bias_new) ||
-      (acc->y_bias < acc->y_bias_new) || (acc->y_bias > acc->y_bias_new) ||
-      (acc->z_bias < acc->z_bias_new) || (acc->z_bias > acc->z_bias_new)) {
-    acc->x_bias = acc->x_bias_new;
-    acc->y_bias = acc->y_bias_new;
-    acc->z_bias = acc->z_bias_new;
-    return true;
-  }
-
-  return false;
-}
-
-// Set the (initial) bias.
-void accelCalBiasSet(struct accelCal_t *acc,
-                        float x, float y, float z) {
-  acc->x_bias = acc->x_bias_new = x;
-  acc->y_bias = acc->y_bias_new = y;
-  acc->z_bias = acc->z_bias_new = z;
+// Updating the new bias.
+void accelCalUpdateBias(struct accelCal_t *acc) {
+  acc->x_bias = acc->x_bias_new;
+  acc->y_bias = acc->y_bias_new;
+  acc->z_bias = acc->z_bias_new;
 }
 
 // Removing the bias.
diff --git a/firmware/src/drivers/bosch_bmi160/bosch_bmi160.c b/firmware/src/drivers/bosch_bmi160/bosch_bmi160.c
index e444d7f..0a47040 100644
--- a/firmware/src/drivers/bosch_bmi160/bosch_bmi160.c
+++ b/firmware/src/drivers/bosch_bmi160/bosch_bmi160.c
@@ -602,11 +602,6 @@
     .flags1 = SENSOR_INFO_FLAGS1_BIAS, \
     .biasType = bias
 
-#define DEC_INFO_RATE_RAW_BIAS(name, rates, type, axis, inter, samples, raw, scale, bias) \
-    DEC_INFO_RATE_RAW(name, rates, type, axis, inter, samples, raw, scale), \
-    .flags1 = SENSOR_INFO_FLAGS1_RAW | SENSOR_INFO_FLAGS1_BIAS, \
-    .biasType = bias
-
 typedef struct BMI160Task _Task;
 #define TASK  _Task* const _task
 
@@ -658,14 +653,8 @@
 
 static const struct SensorInfo mSensorInfo[NUM_OF_SENSOR] =
 {
-#ifdef ACCEL_CAL_ENABLED
-    { DEC_INFO_RATE_RAW_BIAS("Accelerometer", AccRates, SENS_TYPE_ACCEL, NUM_AXIS_THREE,
-            NANOHUB_INT_NONWAKEUP, 3000, SENS_TYPE_ACCEL_RAW, 1.0/kScale_acc,
-            SENS_TYPE_ACCEL_BIAS) },
-#else
     { DEC_INFO_RATE_RAW("Accelerometer", AccRates, SENS_TYPE_ACCEL, NUM_AXIS_THREE,
             NANOHUB_INT_NONWAKEUP, 3000, SENS_TYPE_ACCEL_RAW, 1.0/kScale_acc) },
-#endif
     { DEC_INFO_RATE_BIAS("Gyroscope", GyrRates, SENS_TYPE_GYRO, NUM_AXIS_THREE,
             NANOHUB_INT_NONWAKEUP, 20, SENS_TYPE_GYRO_BIAS) },
 #ifdef MAG_SLAVE_PRESENT
@@ -2575,23 +2564,15 @@
 
 static bool accCfgData(void *data, void *cookie)
 {
-    struct CfgData {
-        int32_t hw[3];
-        float sw[3];
-    };
-    struct CfgData *values = data;
+    int32_t *values = data;
 
-    mTask.sensors[ACC].offset[0] = values->hw[0];
-    mTask.sensors[ACC].offset[1] = values->hw[1];
-    mTask.sensors[ACC].offset[2] = values->hw[2];
+    mTask.sensors[ACC].offset[0] = values[0];
+    mTask.sensors[ACC].offset[1] = values[1];
+    mTask.sensors[ACC].offset[2] = values[2];
     mTask.sensors[ACC].offset_enable = true;
 
-#ifdef ACCEL_CAL_ENABLED
-    accelCalBiasSet(&mTask.acc, values->sw[0], values->sw[1], values->sw[2]);
-#endif
-
     INFO_PRINT("accCfgData: data=%02lx, %02lx, %02lx\n",
-            values->hw[0] & 0xFF, values->hw[1] & 0xFF, values->hw[2] & 0xFF);
+            values[0] & 0xFF, values[1] & 0xFF, values[2] & 0xFF);
 
     if (!saveCalibration()) {
         mTask.pending_calibration_save = true;
@@ -3195,11 +3176,6 @@
     int16_t temperature16;
     int i;
     bool returnIdle = false;
-#ifdef ACCEL_CAL_ENABLED
-    bool accelCalNewBiasAvailable;
-    struct TripleAxisDataPoint *sample;
-    float accelCalBiasX, accelCalBiasY, accelCalBiasZ;
-#endif
 
     switch (GET_STATE()) {
     case SENSOR_BOOT:
@@ -3270,32 +3246,7 @@
         // "The bias and scale calibration must only be updated while the sensor is deactivated,
         // so as to avoid causing jumps in values during streaming."
         if (mSensor->idx == ACC) {
-            accelCalNewBiasAvailable = accelCalUpdateBias(&mTask.acc, &accelCalBiasX, &accelCalBiasY, &accelCalBiasZ);
-            // notify HAL about new accel bias calibration
-            if (accelCalNewBiasAvailable) {
-                if (mSensor->data_evt->samples[0].firstSample.numSamples > 0) {
-                    // flush existing samples so the bias appears after them
-                    flushData(mSensor,
-                            EVENT_TYPE_BIT_DISCARDABLE | sensorGetMyEventType(mSensorInfo[ACC].sensorType));
-
-                    // try to allocate another data event and break if unsuccessful
-                    if (!allocateDataEvt(mSensor, sensorGetTime())) {
-                        break;
-                    }
-                }
-
-                mSensor->data_evt->samples[0].firstSample.biasCurrent = true;
-                mSensor->data_evt->samples[0].firstSample.biasPresent = 1;
-                mSensor->data_evt->samples[0].firstSample.biasSample =
-                        mSensor->data_evt->samples[0].firstSample.numSamples;
-                sample = &mSensor->data_evt->samples[mSensor->data_evt->samples[0].firstSample.numSamples++];
-                sample->x = accelCalBiasX;
-                sample->y = accelCalBiasY;
-                sample->z = accelCalBiasZ;
-                flushData(mSensor, sensorGetMyEventType(mSensorInfo[ACC].biasType));
-
-                allocateDataEvt(mSensor, sensorGetTime());
-            }
+          accelCalUpdateBias(&mTask.acc);
         }
 #endif
         break;