From 5f4dbf9ca9ba32bfeefa3dbab412867dc63f0892 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jul 2008 12:32:13 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@328 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'test/test.c') diff --git a/test/test.c b/test/test.c index f9a185d03..5f78c8526 100644 --- a/test/test.c +++ b/test/test.c @@ -167,22 +167,27 @@ void test_cpu_pulse(systime_t ms) { systime_t test_wait_tick(void) { - systime_t time = chSysGetTime() + 1; - if (time) { - while (chSysGetTime() < time) { -#if defined(WIN32) - ChkIntSources(); -#endif - } - } - else { - while (chSysGetTime() > time) { -#if defined(WIN32) - ChkIntSources(); -#endif - } - } - return time; + chThdSleep(1); + return chSysGetTime(); +} + +/* + * Timer utils. + */ +static VirtualTimer vt; +bool_t test_timer_done; + +static void tmr(void *p) { + + test_timer_done = TRUE; +} + +void test_start_timer(systime_t time) { + + test_timer_done = FALSE; + chSysLock(); + chVTSetI(&vt, time, tmr, NULL); + chSysUnlock(); } /* -- cgit v1.2.3