summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-10-16 16:10:04 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-29 02:08:04 +0000
commit1d69d0f3876f61f066e3fed61aca5be338dfb656 (patch)
tree352abd3ee83fe81b3be4f905a21cfbe2b15f7880
parent35746c59e2bb1bf8e63841eb44e9f78f014c80f0 (diff)
downloadchrome-ec-1d69d0f3876f61f066e3fed61aca5be338dfb656.tar.gz
common: motion: move read fifo console command
Move command in _fifo.c, as the fifo data structure is a static in this file. BUG=none BRANCH=none TEST=Add CONFIG_CMD_ACCEL_FIFO to baseboard volteer, check it compiles. Change-Id: I6f9efafeaf450309ce48182396f3398fa4276d46 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2485909 Reviewed-by: Yuval Peress <peress@chromium.org>
-rw-r--r--common/motion_sense.c32
-rw-r--r--common/motion_sense_fifo.c34
2 files changed, 34 insertions, 32 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 9564012abe..f75332fafe 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -1810,38 +1810,6 @@ DECLARE_CONSOLE_COMMAND(accelinfo, command_display_accel_info,
" and set calculation frequency.");
#endif /* CONFIG_CMD_ACCEL_INFO */
-#ifdef CONFIG_CMD_ACCEL_FIFO
-static int motion_sense_read_fifo(int argc, char **argv)
-{
- int count, i;
- struct ec_response_motion_sensor_data v;
-
- if (argc < 1)
- return EC_ERROR_PARAM_COUNT;
-
- /* Limit the amount of data to avoid saturating the UART buffer */
- count = MIN(queue_count(&motion_sense_fifo), 16);
- for (i = 0; i < count; i++) {
- queue_peek_units(&motion_sense_fifo, &v, i, 1);
- if (v.flags & (MOTIONSENSE_SENSOR_FLAG_TIMESTAMP |
- MOTIONSENSE_SENSOR_FLAG_FLUSH)) {
- uint64_t timestamp;
- memcpy(&timestamp, v.data, sizeof(v.data));
- ccprintf("Timestamp: 0x%016llx%s\n", timestamp,
- (v.flags & MOTIONSENSE_SENSOR_FLAG_FLUSH ?
- " - Flush" : ""));
- } else {
- ccprintf("%d %d: %-5d %-5d %-5d\n", i, v.sensor_num,
- v.data[X], v.data[Y], v.data[Z]);
- }
- }
- return EC_SUCCESS;
-}
-
-DECLARE_CONSOLE_COMMAND(fiforead, motion_sense_read_fifo,
- "id",
- "Read Fifo sensor");
-#endif /* defined(CONFIG_CMD_ACCEL_FIFO) */
#endif /* CONFIG_CMD_ACCELS */
#ifdef CONFIG_ACCEL_SPOOF_MODE
diff --git a/common/motion_sense_fifo.c b/common/motion_sense_fifo.c
index 2325de4c87..67fb196bc6 100644
--- a/common/motion_sense_fifo.c
+++ b/common/motion_sense_fifo.c
@@ -597,3 +597,37 @@ void motion_sense_fifo_reset(void)
motion_sense_fifo_init();
queue_init(&fifo);
}
+
+#ifdef CONFIG_CMD_ACCEL_FIFO
+static int motion_sense_read_fifo(int argc, char **argv)
+{
+ int count, i;
+ struct ec_response_motion_sensor_data v;
+
+ if (argc < 1)
+ return EC_ERROR_PARAM_COUNT;
+
+ /* Limit the amount of data to avoid saturating the UART buffer */
+ count = MIN(queue_count(&fifo), 16);
+ for (i = 0; i < count; i++) {
+ queue_peek_units(&fifo, &v, i, 1);
+ if (v.flags & (MOTIONSENSE_SENSOR_FLAG_TIMESTAMP |
+ MOTIONSENSE_SENSOR_FLAG_FLUSH)) {
+ uint64_t timestamp;
+
+ memcpy(&timestamp, v.data, sizeof(v.data));
+ ccprintf("Timestamp: 0x%016llx%s\n", timestamp,
+ (v.flags & MOTIONSENSE_SENSOR_FLAG_FLUSH ?
+ " - Flush" : ""));
+ } else {
+ ccprintf("%d %d: %-5d %-5d %-5d\n", i, v.sensor_num,
+ v.data[X], v.data[Y], v.data[Z]);
+ }
+ }
+ return EC_SUCCESS;
+}
+
+DECLARE_CONSOLE_COMMAND(fiforead, motion_sense_read_fifo,
+ "id",
+ "Read Fifo sensor");
+#endif /* defined(CONFIG_CMD_ACCEL_FIFO) */