* Deal with numerical overflows.
This commit is contained in:
parent
f0a14fbeae
commit
b065b27759
1 changed files with 5 additions and 3 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: clock.c,v 1.1 2006/06/17 22:41:21 adamdunkels Exp $
|
* @(#)$Id: clock.c,v 1.2 2006/08/17 15:25:46 bg- Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@
|
||||||
/* #define INTERVAL (307200ULL / CLOCK_SECOND) */
|
/* #define INTERVAL (307200ULL / CLOCK_SECOND) */
|
||||||
#define INTERVAL (4096ULL / CLOCK_SECOND)
|
#define INTERVAL (4096ULL / CLOCK_SECOND)
|
||||||
|
|
||||||
|
#define MAX_TICKS (~((clock_time_t)0) / 2)
|
||||||
|
|
||||||
static volatile clock_time_t count = 0;
|
static volatile clock_time_t count = 0;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
interrupt(TIMERA1_VECTOR) timera1 (void) {
|
interrupt(TIMERA1_VECTOR) timera1 (void) {
|
||||||
|
@ -53,8 +55,8 @@ interrupt(TIMERA1_VECTOR) timera1 (void) {
|
||||||
TACCR1 += INTERVAL;
|
TACCR1 += INTERVAL;
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if(etimer_pending() && count >= etimer_next_expiration_time()) {
|
if(etimer_pending()
|
||||||
/* if(etimer_pending()) { */
|
&& (etimer_next_expiration_time() - count) >= MAX_TICKS) {
|
||||||
etimer_request_poll();
|
etimer_request_poll();
|
||||||
LPM_AWAKE();
|
LPM_AWAKE();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue