Added energy estimation

This commit is contained in:
adamdunkels 2007-05-22 20:59:11 +00:00
parent 9277197506
commit 9a5bac6282
4 changed files with 43 additions and 31 deletions

View File

@ -1,32 +1,32 @@
/* /*
* Copyright (c) 2006, Swedish Institute of Computer Science * Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)$Id: cc2420_uart0.c,v 1.2 2006/08/17 15:41:13 bg- Exp $ * @(#)$Id: cc2420_uart0.c,v 1.3 2007/05/22 20:59:11 adamdunkels Exp $
*/ */
#include <io.h> #include <io.h>
@ -41,13 +41,16 @@
interrupt(PORT1_VECTOR) interrupt(PORT1_VECTOR)
__fifop_interrupt(void) __fifop_interrupt(void)
{ {
if(__cc2420_intr()) ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(__cc2420_intr()) {
LPM4_EXIT; LPM4_EXIT;
}
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
void void
__cc2420_arch_init(void) __cc2420_arch_init(void)
{ {
spi_init(); spi_init();
P4DIR |= BV(CSN) | BV(VREG_EN) | BV(RESET_N); P4DIR |= BV(CSN) | BV(VREG_EN) | BV(RESET_N);

View File

@ -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.6 2007/04/02 16:32:20 joxe Exp $ * @(#)$Id: clock.c,v 1.7 2007/05/22 20:59:27 adamdunkels Exp $
*/ */
@ -37,6 +37,7 @@
#include "contiki-conf.h" #include "contiki-conf.h"
#include "lib/energest.h"
#include "sys/clock.h" #include "sys/clock.h"
#include "sys/etimer.h" #include "sys/etimer.h"
@ -50,6 +51,7 @@ 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);
if(TAIV == 2) { if(TAIV == 2) {
TACCR1 += INTERVAL; TACCR1 += INTERVAL;
last_tar = TAR; last_tar = TAR;
@ -61,6 +63,7 @@ interrupt(TIMERA1_VECTOR) timera1 (void) {
LPM4_EXIT; LPM4_EXIT;
} }
} }
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
clock_time_t clock_time_t

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)$Id: uart1.c,v 1.1 2007/03/15 21:37:19 adamdunkels Exp $ * @(#)$Id: uart1.c,v 1.2 2007/05/22 21:01:51 adamdunkels Exp $
*/ */
/* /*
@ -36,6 +36,7 @@
#include <io.h> #include <io.h>
#include <signal.h> #include <signal.h>
#include "lib/energest.h"
#include "dev/uart1.h" #include "dev/uart1.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -110,6 +111,7 @@ uart1_init(unsigned long ubr)
interrupt(UART1RX_VECTOR) interrupt(UART1RX_VECTOR)
uart1_interrupt(void) uart1_interrupt(void)
{ {
ENERGEST_ON(ENERGEST_TYPE_IRQ);
/* Check status register for receive errors. */ /* Check status register for receive errors. */
if(URCTL1 & RXERR) { if(URCTL1 & RXERR) {
volatile unsigned dummy; volatile unsigned dummy;
@ -119,5 +121,6 @@ uart1_interrupt(void)
LPM4_EXIT; LPM4_EXIT;
}*/ }*/
} }
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)$Id: slip_uart1.c,v 1.6 2007/03/29 23:43:59 adamdunkels Exp $ * @(#)$Id: slip_uart1.c,v 1.7 2007/05/22 21:00:27 adamdunkels Exp $
*/ */
/* /*
@ -136,12 +136,15 @@ slip_arch_init(unsigned long ubr)
interrupt(UART1RX_VECTOR) interrupt(UART1RX_VECTOR)
__uart1_intr() __uart1_intr()
{ {
ENERGEST_ON(ENERGEST_TYPE_IRQ);
/* Check status register for receive errors. */ /* Check status register for receive errors. */
if (URCTL1 & RXERR) { if(URCTL1 & RXERR) {
volatile unsigned dummy; volatile unsigned dummy;
dummy = RXBUF1; /* Clear error flags by forcing a dummy read. */ dummy = RXBUF1; /* Clear error flags by forcing a dummy read. */
} else { } else {
if(slip_input_byte(RXBUF1)) if(slip_input_byte(RXBUF1)) {
LPM4_EXIT; LPM4_EXIT;
}
} }
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }