From 28a563a24bd4f278e5d5833a7dafc147d8fb4947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Tue, 26 Nov 2013 22:45:38 +0100 Subject: [PATCH] cc2538: clock: Request an etimer poll in clock_adjust() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During PM1+, the hardware timer used to implement the Contiki clock is frozen, so clock_adjust() needs to be called when exiting those modes in order to compensate for the clock ticks missed while the timer was frozen. Doing so changes the Contiki clock time, so etimer_request_poll() needs to be called in order to inform the etimer library that an etimer might have expired. Note that waiting for the next clock ISR to call etimer_request_poll() is unreliable because the system might go back to sleep beforehand. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/clock.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpu/cc2538/clock.c b/cpu/cc2538/clock.c index d818362a9..20297e993 100644 --- a/cpu/cc2538/clock.c +++ b/cpu/cc2538/clock.c @@ -197,6 +197,14 @@ clock_adjust(clock_time_t ticks) /* Re-Start the SysTick */ REG(SYSTICK_STCTRL) |= SYSTICK_STCTRL_ENABLE; + + /* + * Inform the etimer library that the system clock has changed and that an + * etimer might have expired. + */ + if(etimer_pending()) { + etimer_request_poll(); + } } /*---------------------------------------------------------------------------*/ /**