summaryrefslogtreecommitdiff
path: root/include/motion_sense_fifo.h
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2019-07-15 11:40:47 -0600
committerCommit Bot <commit-bot@chromium.org>2019-08-23 00:25:33 +0000
commita2e7b77b3b62d9f663eb1f916fe9ab36bef06dbe (patch)
tree0508e2e77f23ba861090a53d1b99306fe9ad3046 /include/motion_sense_fifo.h
parent3a2044d812f26a1ac0302a5eeb66eaf9433e78ba (diff)
downloadchrome-ec-a2e7b77b3b62d9f663eb1f916fe9ab36bef06dbe.tar.gz
common: Move fifo logic out of motion_sense.c
This change is needed to allow better testing of the fifo behavior. Additionally, motion_sense_fifo.c will only be compiled if CONFIG_ACCEL_FIFO is defined. This behaviour requires a few small changes to several boards and baseboards to make sure that we only define CONFIG_ACCEL_FIFO when the MOTIONSENSE task is present (some times that may be only in one section RW or RO). BUG=b:137758297 BRANCH=None TEST=buildall and ran CTS on arcada Change-Id: I2f7e4e436ba9568a35b7a0b2c8d53a73f198ba73 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704163 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Alexandru M Stan <amstan@chromium.org>
Diffstat (limited to 'include/motion_sense_fifo.h')
-rw-r--r--include/motion_sense_fifo.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/include/motion_sense_fifo.h b/include/motion_sense_fifo.h
new file mode 100644
index 0000000000..f0d5f853dd
--- /dev/null
+++ b/include/motion_sense_fifo.h
@@ -0,0 +1,70 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_MOTION_SENSE_FIFO_H
+#define __CROS_EC_MOTION_SENSE_FIFO_H
+
+#include "motion_sense.h"
+#include "task.h"
+
+extern struct queue motion_sense_fifo;
+extern int wake_up_needed;
+extern int fifo_int_enabled;
+extern int fifo_queue_count;
+extern int motion_sense_fifo_lost;
+
+enum motion_sense_async_event {
+ ASYNC_EVENT_FLUSH = MOTIONSENSE_SENSOR_FLAG_FLUSH |
+ MOTIONSENSE_SENSOR_FLAG_TIMESTAMP,
+ ASYNC_EVENT_ODR = MOTIONSENSE_SENSOR_FLAG_ODR |
+ MOTIONSENSE_SENSOR_FLAG_TIMESTAMP,
+};
+
+/**
+ * Stage data to the fifo, including a timestamp. This data will not be
+ * available to the AP until motion_sense_fifo_commit_data is called.
+ *
+ * @param data data to insert in the FIFO
+ * @param sensor sensor the data comes from
+ * @param valid_data data should be copied into the public sensor vector
+ * @param time accurate time (ideally measured in an interrupt) the sample
+ * was taken at
+ */
+void motion_sense_fifo_stage_data(struct ec_response_motion_sensor_data *data,
+ struct motion_sensor_t *sensor,
+ int valid_data,
+ uint32_t time);
+
+/**
+ * Commits all staged data to the fifo. If multiple readings were placed using
+ * the same timestamps, they will be spread out.
+ */
+void motion_sense_fifo_commit_data(void);
+
+/**
+ * Insert an async event into the fifo.
+ *
+ * @param sensor Pointer to the sensor generating the event.
+ * @param evt The event to insert.
+ */
+void motion_sense_insert_async_event(struct motion_sensor_t *sensor,
+ enum motion_sense_async_event evt);
+
+/**
+ * Stage a timestamp into the fifo.
+ *
+ * @param timestamp The timestamp to stage.
+ */
+void motion_sense_fifo_stage_timestamp(uint32_t timestamp);
+
+/**
+ * Get information about the fifo.
+ *
+ * @param fifo_info The struct to store the info.
+ */
+void motion_sense_get_fifo_info(
+ struct ec_response_motion_sense_fifo_info *fifo_info);
+
+#endif /* __CROS_EC_MOTION_SENSE_FIFO_H */