summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/timer_calib.c63
-rw-r--r--test/timer_calib.tasklist2
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)