galileo: Add support for Etimer and Ctimer libraries

This patch adds support for the Etimer and Ctimer libraries. To support
the Etimer library, we should poll the etimer process every time the
system clock is updated. To do this more efficiently, by taking advantage
of etimer_next_expiration_time() API, we poll the etimer process only
when an 'Event Timer' has expired.

We don't need any platform specific support in order to enable the Ctimer
library since it relies completely on Etimer.

The others timer libraries (Timer and Stime) don't required any specific
platform support as well since they rely on the system Clock module only.
This commit is contained in:
Jesus Sanchez-Palencia 2015-07-03 19:21:21 -03:00
parent eafcba5e7a
commit 7c871871de
2 changed files with 10 additions and 0 deletions

View File

@ -29,6 +29,7 @@
*/
#include "sys/clock.h"
#include "sys/etimer.h"
#include "contiki-conf.h"
#include "drivers/rtc.h"
@ -69,7 +70,14 @@ static volatile clock_time_t tick_count = 0;
static void
update_ticks(void)
{
clock_time_t expire = etimer_next_expiration_time();
tick_count++;
/* Notify etimer library if the next event timer has expired */
if(expire != 0 && tick_count >= expire) {
etimer_request_poll();
}
}
/*---------------------------------------------------------------------------*/
void

View File

@ -41,6 +41,8 @@ main(void)
ENABLE_IRQ();
process_init();
process_start(&etimer_process, NULL);
ctimer_init();
autostart_start(autostart_processes);
while(1) {