support for delayed interrupts
earlier TACCR1 could be set to already passed time if timer A interrupts was delayed
This commit is contained in:
parent
2d0225b0e4
commit
5f63995265
1 changed files with 11 additions and 4 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.8 2007/09/03 19:22:37 joxe Exp $
|
* @(#)$Id: clock.c,v 1.9 2007/10/04 14:14:58 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,15 +47,22 @@
|
||||||
|
|
||||||
#define MAX_TICKS (~((clock_time_t)0) / 2)
|
#define MAX_TICKS (~((clock_time_t)0) / 2)
|
||||||
|
|
||||||
|
#define LT(a,b) ((signed short)((a)-(b)) < 0)
|
||||||
|
|
||||||
static volatile clock_time_t count = 0;
|
static volatile clock_time_t count = 0;
|
||||||
static unsigned short last_tar = 0;
|
static unsigned short last_tar = 0;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
interrupt(TIMERA1_VECTOR) timera1 (void) {
|
interrupt(TIMERA1_VECTOR) timera1 (void) {
|
||||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||||
if(TAIV == 2) {
|
if(TAIV == 2) {
|
||||||
TACCR1 += INTERVAL;
|
/* Make sure interrupt time is future */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
TACCR1 += INTERVAL;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
while (LT(TACCR1, TAR+INTERVAL));
|
||||||
last_tar = TAR;
|
last_tar = TAR;
|
||||||
++count;
|
|
||||||
|
|
||||||
if(etimer_pending()
|
if(etimer_pending()
|
||||||
&& (etimer_next_expiration_time() - count - 1) > MAX_TICKS) {
|
&& (etimer_next_expiration_time() - count - 1) > MAX_TICKS) {
|
||||||
|
|
Loading…
Reference in a new issue