From 04de0d4c61a352de05a4f8b9980b479cc8e636f0 Mon Sep 17 00:00:00 2001 From: Myles Watson Date: Fri, 9 Jan 2015 14:30:44 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/239968 Reviewed-by: Randall Spangler Reviewed-by: Alec Berg --- common/timer.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'common/timer.c') 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(); -- cgit v1.2.1