diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-09-02 10:50:50 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-03 04:47:44 +0000 |
commit | 27dbf8f5812d9af1760d299521cee9f825e5013e (patch) | |
tree | 8c7f4287e3da0e52c6ae3c7f258c2cef751e73f5 | |
parent | 386ada84e9464b0c3ec76cf64129e40a2f0c9131 (diff) | |
download | chrome-ec-27dbf8f5812d9af1760d299521cee9f825e5013e.tar.gz |
accel: fix bug, initialize accels every time we boot out of G3
This makes sure that we initialize all accelerometers when we leave
G3 because some accelerometers are not powered in G3.
Also, changed some of the print statements in motion_sense.c to
help in debugging.
BUG=none
BRANCH=none
TEST=tested on samus. verified if you go back and forth between
G3 and S0 that the lid accelerometer is always initialized by
using accelread command to verify that data is being updated.
Change-Id: I73effda4e6b04a629851e6c310d53b044c4aad42
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/215943
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
-rw-r--r-- | common/motion_sense.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index b6afa2e91f..18aa5aa45e 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -21,6 +21,7 @@ /* Console output macros */ #define CPUTS(outstr) cputs(CC_MOTION_SENSE, outstr) #define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_MOTION_SENSE, format, ## args) /* Minimum time in between running motion sense task loop. */ #define MIN_MOTION_SENSE_WAIT_TIME (1 * MSEC) @@ -199,6 +200,7 @@ static void clock_chipset_shutdown(void) accel_interval_ms = accel_interval_ap_suspend_ms; for (i = 0; i < motion_sensor_count; i++) { sensor = &motion_sensors[i]; + sensor->state = SENSOR_NOT_INITIALIZED; sensor->power = SENSOR_POWER_OFF; } } @@ -335,6 +337,7 @@ void motion_sense_task(void) for (i = 0; i < motion_sensor_count; ++i) { sensor = &motion_sensors[i]; + sensor->state = SENSOR_NOT_INITIALIZED; if ((LOCATION_BASE == sensor->location) && (SENSOR_ACCELEROMETER == sensor->type)) accel_base = sensor; @@ -406,15 +409,17 @@ void motion_sense_task(void) #ifdef CONFIG_CMD_LID_ANGLE if (accel_disp) { + CPRINTF("[%T "); for (i = 0; i < motion_sensor_count; ++i) { sensor = &motion_sensors[i]; - CPRINTS("%s=%-5d, %-5d, %-5d", sensor->name, + CPRINTF("%s=%-5d, %-5d, %-5d ", sensor->name, sensor->raw_xyz[X], sensor->raw_xyz[Y], sensor->raw_xyz[Z]); } - CPRINTS("a=%-6.1d r=%d", (int)(10*lid_angle_deg), + CPRINTF("a=%-6.1d r=%d", (int)(10*lid_angle_deg), lid_angle_is_reliable); + CPRINTF("]\n"); } #endif update_sense_data(lpc_status, lpc_data, &sample_id); @@ -854,7 +859,9 @@ static int command_accel_read_xyz(int argc, char **argv) while ((n == -1) || (n-- > 0)) { sensor->drv->read(sensor, &x, &y, &z); - ccprintf("XYZ:%d %d %d %d\n", id, 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, + sensor->xyz[X], sensor->xyz[Y], sensor->xyz[Z]); task_wait_event(MIN_MOTION_SENSE_WAIT_TIME); } return EC_SUCCESS; |