diff --git a/common/motion_sense.c b/common/motion_sense.c index 4855a68d93..4e7f63ea83 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -505,13 +505,6 @@ void motion_sense_task(void) ts_end_task = get_time(); #ifdef CONFIG_ACCEL_FIFO - /* - * If ODR of any sensor changed, insert a timestamp to be ease - * calculation of each events. - */ - if (event & TASK_EVENT_MOTION_ODR_CHANGE) - motion_sense_insert_timestamp(); - /* * Ask the host to flush the queue if * - a flush event has been queued. @@ -519,6 +512,7 @@ void motion_sense_task(void) * - we haven't done it for a while. */ if (fifo_flush_needed || + event & TASK_EVENT_MOTION_ODR_CHANGE || queue_space(&motion_sense_fifo) < CONFIG_ACCEL_FIFO_THRES || (ts_end_task.val - ts_last_int.val) > accel_interval) { if (!fifo_flush_needed) diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index 3afa3e6bd7..e2b6daddeb 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -797,8 +797,16 @@ static int load_fifo(struct motion_sensor_t *s) if (s->type != MOTIONSENSE_TYPE_ACCEL) return EC_SUCCESS; - if (!(data->flags & (BMI160_FIFO_ALL_MASK << BMI160_FIFO_FLAG_OFFSET))) + if (!(data->flags & + (BMI160_FIFO_ALL_MASK << BMI160_FIFO_FLAG_OFFSET))) { + /* + * Flush potiential left over: + * + * When sensor is resumed, we don't want to read old data. + */ + raw_write8(s->addr, BMI160_CMD_REG, BMI160_CMD_FIFO_FLUSH); return EC_SUCCESS; + } do { enum fifo_state state = FIFO_HEADER;