summaryrefslogtreecommitdiff
path: root/common/timer.c
diff options
context:
space:
mode:
authorMyles Watson <mylesgw@chromium.org>2015-01-09 14:30:44 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-14 03:16:29 +0000
commit04de0d4c61a352de05a4f8b9980b479cc8e636f0 (patch)
tree259d16ac540f45c1cbcaf26dbe2a1eed2d83e03b /common/timer.c
parent16eaf5cfded677cf18c095037c4d35932cdcd274 (diff)
downloadchrome-ec-04de0d4c61a352de05a4f8b9980b479cc8e636f0.tar.gz
common: Add a forcetime console command
BUG=chrome-os-partner:35312 BRANCH=none TEST=make buildall -j I added a debug message to nrf51/hwtimer.c to show when the timer overflowed. "forcetime 4 0xfffff000" overflows to 5.00000000 in 4096 microseconds. Define CONFIG_CMD_FORCETIME to enable it. Change-Id: I30835d038ef8cd639565ffb7a638979d95d0a684 Signed-off-by: Myles Watson <mylesgw@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239968 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/timer.c')
-rw-r--r--common/timer.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/common/timer.c b/common/timer.c
index 96e582575c..0764fb7e1b 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -256,6 +256,34 @@ DECLARE_CONSOLE_COMMAND(waitms, command_wait,
"Busy-wait for msec",
NULL);
+#ifdef CONFIG_CMD_FORCETIME
+static int command_force_time(int argc, char **argv)
+{
+ char *e;
+ timestamp_t new;
+
+ if (argc < 3)
+ return EC_ERROR_PARAM_COUNT;
+
+ new.le.hi = strtoi(argv[1], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM1;
+
+ new.le.lo = strtoi(argv[2], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM2;
+
+ ccprintf("Time: 0x%016lx = %.6ld s\n", new.val, new.val);
+ force_time(new);
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(forcetime, command_force_time,
+ "hi lo",
+ "Force current time",
+ NULL);
+#endif
+
static int command_get_time(int argc, char **argv)
{
timestamp_t ts = get_time();