diff options
author | Vic Yang <victoryang@chromium.org> | 2013-04-14 20:24:45 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-04-15 20:40:03 -0700 |
commit | 12df5c4923632262573e7cf63d977cf881016206 (patch) | |
tree | fb16c7ae7b9b037135e73b8e15d432f83dd2814d /test | |
parent | 216bb93128c2477d2c4053110e0b0df4ddd0b40f (diff) | |
download | chrome-ec-12df5c4923632262573e7cf63d977cf881016206.tar.gz |
Fix timer_calib test
BUG=chrome-os-partner:18598
TEST=Run on Spring
BRANCH=None
Change-Id: I55057ee7727858b040ea23ed8802ab7022cc63ac
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48091
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/timer_calib.c | 63 | ||||
-rw-r--r-- | test/timer_calib.tasklist | 2 |
2 files changed, 38 insertions, 27 deletions
diff --git a/test/timer_calib.c b/test/timer_calib.c index 86da6479ff..e64cc6a769 100644 --- a/test/timer_calib.c +++ b/test/timer_calib.c @@ -6,9 +6,10 @@ */ #include "common.h" -#include "uart.h" +#include "console.h" #include "task.h" #include "timer.h" +#include "util.h" uint32_t difftime(timestamp_t t0, timestamp_t t1) { @@ -20,35 +21,45 @@ int timer_calib_task(void *data) timestamp_t t0, t1; unsigned d; - uart_printf("\n=== Timer calibration ===\n"); - - t0 = get_time(); - t1 = get_time(); - uart_printf("- back-to-back get_time : %d us\n", difftime(t0, t1)); - - /* Sleep for 5 seconds */ - uart_printf("- sleep 1s :\n "); - uart_flush_output(); - uart_printf("Go..."); - t0 = get_time(); - usleep(1000000); - t1 = get_time(); - uart_printf("done. delay = %d us\n", difftime(t0, t1)); - - /* try small usleep */ - uart_printf("- short sleep :\n"); - uart_flush_output(); - for (d=128 ; d > 0; d = d / 2) { + while (1) { + task_wait_event(-1); + + ccprintf("\n=== Timer calibration ===\n"); + + t0 = get_time(); + t1 = get_time(); + ccprintf("- back-to-back get_time : %d us\n", difftime(t0, t1)); + + /* Sleep for 5 seconds */ + ccprintf("- sleep 1s :\n "); + cflush(); + ccprintf("Go..."); t0 = get_time(); - usleep(d); + usleep(1000000); t1 = get_time(); - uart_printf(" %d us => %d us\n", d, difftime(t0, t1)); - uart_flush_output(); + ccprintf("done. delay = %d us\n", difftime(t0, t1)); + + /* try small usleep */ + ccprintf("- short sleep :\n"); + cflush(); + for (d = 128; d > 0; d = d / 2) { + t0 = get_time(); + usleep(d); + t1 = get_time(); + ccprintf(" %d us => %d us\n", d, difftime(t0, t1)); + cflush(); + } + + ccprintf("Done.\n"); } - uart_printf("Done.\n"); - /* sleep forever */ - task_wait_event(-1); + return EC_SUCCESS; +} +static int command_run_test(int argc, char **argv) +{ + task_wake(TASK_ID_TESTTMR); return EC_SUCCESS; } +DECLARE_CONSOLE_COMMAND(runtest, command_run_test, + NULL, NULL, NULL); diff --git a/test/timer_calib.tasklist b/test/timer_calib.tasklist index d330db29d8..b99c0016c7 100644 --- a/test/timer_calib.tasklist +++ b/test/timer_calib.tasklist @@ -15,4 +15,4 @@ * 's' is the stack size in bytes; must be a multiple of 8 */ #define CONFIG_TEST_TASK_LIST \ - TASK_TEST(TESTTMR, timer_calib_task, (void *)'T', TASK_STACK_SIZE) \ + TASK_TEST(TESTTMR, timer_calib_task, NULL, TASK_STACK_SIZE) |