summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRosa Chow <rchow@invensense.com>2011-10-13 16:22:32 -0700
committerMathias Agopian <mathias@google.com>2011-10-14 17:44:22 -0700
commit7f7785f89f4e04c27f0bb6cb11776778305f3c39 (patch)
treefb230529e3711abfd9afa960688b80f11af93c3e
parent940175667037620fe3f15d82ad23025293bca22e (diff)
downloadandroid_hardware_invensense-7f7785f89f4e04c27f0bb6cb11776778305f3c39.tar.gz
android_hardware_invensense-7f7785f89f4e04c27f0bb6cb11776778305f3c39.tar.bz2
android_hardware_invensense-7f7785f89f4e04c27f0bb6cb11776778305f3c39.zip
SensorHAL: Handle the error flag for overflow or underflow
Invensense libmllite needs to be notified when either overflow or underflow happens in raw values. When HAL requires to measure hardware offset, coil init will be triggered. Change-Id: I9076b3928ae5a26230ddd308c3a238a4721c1f87
-rw-r--r--mlsdk/mllite/compass.c3
-rw-r--r--mlsdk/mllite/ml.h1
-rw-r--r--mlsdk/mllite/mlsupervisor.c17
3 files changed, 21 insertions, 0 deletions
diff --git a/mlsdk/mllite/compass.c b/mlsdk/mllite/compass.c
index 387c3f9..798cb9f 100644
--- a/mlsdk/mllite/compass.c
+++ b/mlsdk/mllite/compass.c
@@ -300,6 +300,9 @@ inv_error_t inv_get_compass_data(long *data)
data[ii] =
((long)((signed char)tmp[2 * ii + 1]) << 8) + tmp[2 * ii];
}
+
+ inv_obj.compass_overunder = (int)tmp[6];
+
} else {
#if defined CONFIG_MPU_SENSORS_MPU6050A2 || \
defined CONFIG_MPU_SENSORS_MPU6050B1
diff --git a/mlsdk/mllite/ml.h b/mlsdk/mllite/ml.h
index 4d35fd7..838cd49 100644
--- a/mlsdk/mllite/ml.h
+++ b/mlsdk/mllite/ml.h
@@ -379,6 +379,7 @@ struct inv_obj_t {
long pressure;
inv_error_t (*external_slave_callback)(struct inv_obj_t *);
int compass_accuracy;
+ int compass_overunder;
unsigned short flags[8];
unsigned short suspend;
diff --git a/mlsdk/mllite/mlsupervisor.c b/mlsdk/mllite/mlsupervisor.c
index 8a23ab6..017907f 100644
--- a/mlsdk/mllite/mlsupervisor.c
+++ b/mlsdk/mllite/mlsupervisor.c
@@ -56,9 +56,11 @@
static unsigned long lastCompassTime = 0;
static unsigned long polltime = 0;
+static unsigned long coiltime = 0;
static int accCount = 0;
static int compassCalStableCount = 0;
static int compassCalCount = 0;
+static int coiltimerstart = 0;
static yas_filter_if_s f;
static yas_filter_handle_t handle;
@@ -422,6 +424,21 @@ inv_error_t inv_accel_compass_supervisor(void)
inv_obj.compass_calibrated_data[i] =
(long) (tmp64 / inv_obj.compass_sens);
}
+ //Additions:
+ if (inv_obj.compass_overunder) {
+ if (coiltimerstart == 0) {
+ coiltimerstart = 1;
+ coiltime = ctime;
+ }
+ }
+ if (coiltimerstart == 1) {
+ if (ctime - coiltime > 3000) {
+ inv_obj.flags[INV_COMPASS_OFFSET_VALID] = 0;
+ inv_set_compass_offset();
+ inv_reset_compass_calibration();
+ coiltimerstart = 0;
+ }
+ }
}
if (inv_obj.external_slave_callback) {
result = inv_obj.external_slave_callback(&inv_obj);