Limited support for energy estimation.

This commit is contained in:
nvt-se 2007-12-10 12:49:08 +00:00
parent b1e1f07f64
commit 486ea95b4f
3 changed files with 26 additions and 7 deletions

View File

@ -4,6 +4,8 @@
#define HAVE_STDINT_H #define HAVE_STDINT_H
#include "msp430def.h" #include "msp430def.h"
#define ENERGEST_CONF_ON 1
#define IRQ_PORT1 0x01 #define IRQ_PORT1 0x01
#define IRQ_PORT2 0x02 #define IRQ_PORT2 0x02
#define IRQ_ADC 0x03 #define IRQ_ADC 0x03

View File

@ -126,15 +126,19 @@ main(void)
rtimer_init(); rtimer_init();
ctimer_init(); ctimer_init();
/* System services */ energest_init();
process_start(&etimer_process, NULL);
//process_start(&sensors_process, NULL);
cc1020_init(cc1020_config_19200);
// network configuration
node_id_restore(); node_id_restore();
/* System services */
process_start(&etimer_process, NULL);
#if 0
process_start(&sensors_process, NULL);
#endif
/* Radio driver */
cc1020_init(cc1020_config_19200);
/* Network configuration */
#if WITH_UIP #if WITH_UIP
uip_init(); uip_init();
uip_sethostaddr(&slipif.ipaddr); uip_sethostaddr(&slipif.ipaddr);
@ -163,7 +167,11 @@ main(void)
for (;;) { for (;;) {
while (process_run() > 0); while (process_run() > 0);
if (process_nevents() == 0) { if (process_nevents() == 0) {
ENERGEST_OFF(ENERGEST_TYPE_CPU);
ENERGEST_ON(ENERGEST_TYPE_LPM);
LPM_SLEEP(); LPM_SLEEP();
ENERGEST_OFF(ENERGEST_TYPE_LPM);
ENERGEST_ON(ENERGEST_TYPE_CPU);
} }
} }

View File

@ -163,6 +163,9 @@ cc1020_set_rx(void)
cc1020_setupRX(RX_CURRENT); cc1020_setupRX(RX_CURRENT);
LNA_POWER_ON(); // enable amplifier LNA_POWER_ON(); // enable amplifier
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
// activate // activate
IE1 |= URXIE0; // enable interrupt IE1 |= URXIE0; // enable interrupt
} }
@ -186,6 +189,9 @@ cc1020_set_tx(void)
U0CTL |= SWRST; // UART to reset mode U0CTL |= SWRST; // UART to reset mode
IFG1 &= ~UTXIFG0; // Reset IFG. IFG1 &= ~UTXIFG0; // Reset IFG.
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
// configure driver // configure driver
cc1020_state = CC1020_TX; cc1020_state = CC1020_TX;
} }
@ -286,6 +292,9 @@ cc1020_off(void)
cc1020_setupPD(); // power down radio cc1020_setupPD(); // power down radio
cc1020_state = CC1020_OFF; cc1020_state = CC1020_OFF;
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
return 1; return 1;
} }