Added energy estimation, embryo for possible future drift configuration

This commit is contained in:
adamdunkels 2007-05-22 20:59:47 +00:00
parent 9a5bac6282
commit 432d242a3c

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rtimer-arch.c,v 1.3 2007/04/07 05:45:08 adamdunkels Exp $
* $Id: rtimer-arch.c,v 1.4 2007/05/22 20:59:47 adamdunkels Exp $
*/
/**
@ -41,6 +41,7 @@
#include <io.h>
#include <signal.h>
#include "lib/energest.h"
#include "sys/rtimer.h"
#define DEBUG 0
@ -51,11 +52,15 @@
#define PRINTF(...)
#endif
static rtimer_clock_t offset;
/*---------------------------------------------------------------------------*/
interrupt(TIMERB1_VECTOR) timerb1 (void) {
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(TBIV == 2) {
rtimer_run_next();
}
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
/*---------------------------------------------------------------------------*/
void
@ -63,19 +68,18 @@ rtimer_arch_init(void)
{
dint();
/* Select SMCLK (2.4576MHz), clear TAR */
/* TACTL = TASSEL1 | TACLR | ID_3; */
offset = 0;
/* Select SMCLK (2.4576MHz), clear TAR; This makes the rtimer count
the number of processor cycles executed by the CPU. */
//TBCTL = TBSSEL1 | TBCLR;
/* Select ACLK 32768Hz clock, divide by 8 */
TBCTL = TBSSEL0 | TBCLR | ID_3;
/* Initialize ccr1 to create the X ms interval. */
/* CCR1 interrupt enabled, interrupt occurs when timer equals CCR1. */
TBCCTL1 = CCIE;
/* Interrupt after X ms. */
/* TBCCR1 = INTERVAL;*/
/* Start Timer_A in continuous mode. */
/* Start Timer_B in continuous mode. */
TBCTL |= MC1;
BCSCTL1 &= ~(DIVA1 + DIVA0); /* remove /8 divisor from ACLK again */
@ -88,12 +92,18 @@ void
rtimer_arch_schedule(rtimer_clock_t t)
{
PRINTF("rtimer_arch_schedule time %u\n", t);
TBCCR1 = t;
TBCCR1 = t + offset;
}
/*---------------------------------------------------------------------------*/
rtimer_clock_t
/*rtimer_clock_t
rtimer_arch_now(void)
{
return TBR;
return TBR + offset;
}*/
/*---------------------------------------------------------------------------*/
void
rtimer_arch_set(rtimer_clock_t t)
{
offset = t - TBR;
}
/*---------------------------------------------------------------------------*/