8000 SensorHAL: Handle the error flag for overflow or underflow · arrdalan/dfv_android_invensense@7f7785f · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f7785f

Browse files
rchow-invnpixelflinger
authored andcommitted
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
1 parent 9401756 commit 7f7785f

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

mlsdk/mllite/compass.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ inv_error_t inv_get_compass_data(long *data)
300300
data[ii] =
301301
((long)((signed char)tmp[2 * ii + 1]) << 8) + tmp[2 * ii];
302302
}
303+
304+
inv_obj.compass_overunder = (int)tmp[6];
305+
303306
} else {
304307
#if defined CONFIG_MPU_SENSORS_MPU6050A2 || \
305308
defined CONFIG_MPU_SENSORS_MPU6050B1

mlsdk/mllite/ml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ struct inv_obj_t {
379379
long pressure;
380380
inv_error_t (*external_slave_callback)(struct inv_obj_t *);
381381
int compass_accuracy;
382+
int compass_overunder;
382383

383384
unsigned short flags[8];
384385
unsigned short suspend;

mlsdk/mllite/mlsupervisor.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@
5656

5757
static unsigned long lastCompassTime = 0;
5858
static unsigned long polltime = 0;
59+
static unsigned long coiltime = 0;
5960
static int accCount = 0;
6061
static int compassCalStableCount = 0;
6162
static int compassCalCount = 0;
63+
static int coiltimerstart = 0;
6264

6365
static yas_filter_if_s f;
6466
static yas_filter_handle_t handle;
@@ -422,6 +424,21 @@ inv_error_t inv_accel_compass_supervisor(void)
422424
inv_obj.compass_calibrated_data[i] =
423425
(long) (tmp64 / inv_obj.compass_sens);
424426
}
427+
//Additions:
428+
if (inv_obj.compass_overunder) {
429+
if (coiltimerstart == 0) {
430+
coiltimerstart = 1;
431+
coiltime = ctime;
432+
}
433+
}
434+
if (coiltimerstart == 1) {
435+
if (ctime - coiltime > 3000) {
436+
inv_obj.flags[INV_COMPASS_OFFSET_VALID] = 0;
437+
inv_set_compass_offset();
438+
inv_reset_compass_calibration();
439+
coiltimerstart = 0;
440+
}
441+
}
425442
}
426443
if (inv_obj.external_slave_callback) {
427444
result = inv_obj.external_slave_callback(&inv_obj);

0 commit comments

Comments
 (0)
0