Added energy estimation, disabled IRQs for A/D converting as it used close to 100% CPU time

This commit is contained in:
adamdunkels 2007-05-22 21:01:32 +00:00
parent 3872d004bc
commit 00b1e371cf
1 changed files with 9 additions and 3 deletions

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: irq.c,v 1.2 2007/03/21 23:23:43 adamdunkels Exp $ * @(#)$Id: irq.c,v 1.3 2007/05/22 21:01:32 adamdunkels Exp $
*/ */
#include "lib/sensors.h" #include "lib/sensors.h"
#include "dev/irq.h" #include "dev/irq.h"
@ -45,28 +45,34 @@ static unsigned char adcflags;
interrupt(PORT1_VECTOR) interrupt(PORT1_VECTOR)
irq_p1(void) irq_p1(void)
{ {
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(sensors_handle_irq(IRQ_PORT1)) { if(sensors_handle_irq(IRQ_PORT1)) {
LPM4_EXIT; LPM4_EXIT;
} }
P1IFG = 0x00; P1IFG = 0x00;
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
interrupt(PORT2_VECTOR) interrupt(PORT2_VECTOR)
irq_p2(void) irq_p2(void)
{ {
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(sensors_handle_irq(IRQ_PORT2)) { if(sensors_handle_irq(IRQ_PORT2)) {
LPM4_EXIT; LPM4_EXIT;
} }
P2IFG = 0x00; P2IFG = 0x00;
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
interrupt (ADC_VECTOR) interrupt (ADC_VECTOR)
irq_adc(void) irq_adc(void)
{ {
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(sensors_handle_irq(IRQ_ADC)) { if(sensors_handle_irq(IRQ_ADC)) {
LPM4_EXIT; LPM4_EXIT;
} }
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
@ -110,8 +116,8 @@ sethilo(void)
interrupt for each sequence of conversions. */ interrupt for each sequence of conversions. */
for(c = 0; c < 8; c++) { for(c = 0; c < 8; c++) {
if(adcflags & (128 >> c)) { if(adcflags & (128 >> c)) {
ADC12IE |= 128 >> c; /*ADC12IE |= 128 >> c;*/
ADC12MCTL_NO(7 - c) |= EOS; /* ADC12MCTL_NO(7 - c) |= EOS;*/
break; break;
} }
} }