diff options
Diffstat (limited to 'common/motion_sense.c')
-rw-r--r-- | common/motion_sense.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 9ed0ab92da..21b36a1e7d 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -245,9 +245,18 @@ void motion_sense_task(void) set_present(lpc_status); - /* Initialize sampling interval. */ - accel_interval_ms = chipset_in_state(CHIPSET_STATE_ON) ? - accel_interval_ap_on_ms : SUSPEND_SAMPLING_INTERVAL; + if (chipset_in_state(CHIPSET_STATE_ON)) { + /* Update the sensor current active state to S0. */ + for (i = 0; i < motion_sensor_count; ++i) { + sensor = &motion_sensors[i]; + sensor->active = SENSOR_ACTIVE_S0; + } + + accel_interval_ms = accel_interval_ap_on_ms; + } else { + /* sensor->active already initializes to SENSOR_ACTIVE_S5 */ + accel_interval_ms = SUSPEND_SAMPLING_INTERVAL; + } while (1) { ts0 = get_time(); @@ -681,6 +690,7 @@ static int command_accel_read_xyz(int argc, char **argv) sensor = &motion_sensors[id]; while ((n == -1) || (n-- > 0)) { + x = y = z = 0; sensor->drv->read(sensor, &x, &y, &z); ccprintf("Current raw data %d: %-5d %-5d %-5d\n", id, x, y, z); ccprintf("Last calib. data %d: %-5d %-5d %-5d\n", id, |