mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #546 from LudwigOrtmann/test_hwtimer
improve test_hwtimer usefulness
This commit is contained in:
commit
7f69a6a122
@ -16,16 +16,16 @@ int main(void)
|
|||||||
|
|
||||||
puts("Initializing hwtimer [OK].");
|
puts("Initializing hwtimer [OK].");
|
||||||
|
|
||||||
#define BASE_DELAY 100000UL
|
#define BASE_DELAY (1000UL * 1000UL)
|
||||||
#define DELTA_DELAY 10000UL
|
#define DELTA_DELAY (1000UL * 1000UL)
|
||||||
#define MSGLEN 12 // == strlen("callback %2i")
|
#define MSGLEN 12 // == strlen("callback %2i")
|
||||||
char msg[MSGLEN * ARCH_MAXTIMERS]; // == [callback 1\0callback 2\0...]
|
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 */
|
/* make the first timer first to fire so timers do not run out linearly */
|
||||||
char *msgn = msg;
|
char *msgn = msg;
|
||||||
snprintf(msgn, MSGLEN, "callback %2x", 1);
|
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);
|
printf("set %s\n", msgn);
|
||||||
|
|
||||||
/* set up to ARCH_MAXTIMERS-1 because hwtimer_wait below also
|
/* set up to ARCH_MAXTIMERS-1 because hwtimer_wait below also
|
||||||
@ -34,7 +34,7 @@ int main(void)
|
|||||||
msgn = msg + (i*MSGLEN);
|
msgn = msg + (i*MSGLEN);
|
||||||
delay -= DELTA_DELAY;
|
delay -= DELTA_DELAY;
|
||||||
snprintf(msgn, MSGLEN, "callback %2x", i+1);
|
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);
|
printf("set %s\n", msgn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user