Added a periodic timer to the hello-world example
This commit is contained in:
parent
3d0cd3b16f
commit
6b78522ebb
@ -46,10 +46,21 @@ AUTOSTART_PROCESSES(&hello_world_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(hello_world_process, ev, data)
|
||||
{
|
||||
static struct etimer timer;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Hello, world\n");
|
||||
|
||||
/* Setup a periodic timer that expires after 10 seconds. */
|
||||
etimer_set(&timer, CLOCK_SECOND * 10);
|
||||
|
||||
while(1) {
|
||||
printf("Hello, world\n");
|
||||
|
||||
/* Wait for the periodic timer to expire and then restart the timer. */
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
|
||||
etimer_reset(&timer);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user