mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
improve test_hwtimer usefulness
make the delays noticeable for humans use HWTIMER_TICKS macro for platform independency
This commit is contained in:
parent
944be85124
commit
de3f8a1ae5
@ -16,16 +16,16 @@ int main(void)
|
||||
|
||||
puts("Initializing hwtimer [OK].");
|
||||
|
||||
#define BASE_DELAY 100000UL
|
||||
#define DELTA_DELAY 10000UL
|
||||
#define BASE_DELAY (1000UL * 1000UL)
|
||||
#define DELTA_DELAY (100UL * 1000UL)
|
||||
#define MSGLEN 12 // == strlen("callback %2i")
|
||||
char msg[MSGLEN * ARCH_MAXTIMERS]; // == [callback 1\0callback 2\0...]
|
||||
unsigned long delay = BASE_DELAY + (ARCH_MAXTIMERS * DELTA_DELAY);
|
||||
unsigned long delay = BASE_DELAY + ((ARCH_MAXTIMERS-1) * DELTA_DELAY);
|
||||
|
||||
/* make the first timer first to fire so timers do not run out linearly */
|
||||
char *msgn = msg;
|
||||
snprintf(msgn, MSGLEN, "callback %2x", 1);
|
||||
hwtimer_set(BASE_DELAY, callback, (void*) msgn);
|
||||
hwtimer_set(HWTIMER_TICKS(BASE_DELAY), callback, (void*) msgn);
|
||||
printf("set %s\n", msgn);
|
||||
|
||||
/* set up to ARCH_MAXTIMERS-1 because hwtimer_wait below also
|
||||
@ -34,7 +34,7 @@ int main(void)
|
||||
msgn = msg + (i*MSGLEN);
|
||||
delay -= DELTA_DELAY;
|
||||
snprintf(msgn, MSGLEN, "callback %2x", i+1);
|
||||
hwtimer_set(delay, callback, (void*) msgn);
|
||||
hwtimer_set(HWTIMER_TICKS(delay), callback, (void*) msgn);
|
||||
printf("set %s\n", msgn);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user