diff --git a/platform/msb430/contiki-conf.h b/platform/msb430/contiki-conf.h index 982462cb0..3bf86c7e6 100644 --- a/platform/msb430/contiki-conf.h +++ b/platform/msb430/contiki-conf.h @@ -4,6 +4,8 @@ #define HAVE_STDINT_H #include "msp430def.h" +#define ENERGEST_CONF_ON 1 + #define IRQ_PORT1 0x01 #define IRQ_PORT2 0x02 #define IRQ_ADC 0x03 diff --git a/platform/msb430/contiki-msb430-main.c b/platform/msb430/contiki-msb430-main.c index 92d9da6a7..385e5cb51 100644 --- a/platform/msb430/contiki-msb430-main.c +++ b/platform/msb430/contiki-msb430-main.c @@ -126,15 +126,19 @@ main(void) rtimer_init(); ctimer_init(); - /* System services */ - process_start(&etimer_process, NULL); - //process_start(&sensors_process, NULL); - - cc1020_init(cc1020_config_19200); - - // network configuration + energest_init(); 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 uip_init(); uip_sethostaddr(&slipif.ipaddr); @@ -163,7 +167,11 @@ main(void) for (;;) { while (process_run() > 0); if (process_nevents() == 0) { + ENERGEST_OFF(ENERGEST_TYPE_CPU); + ENERGEST_ON(ENERGEST_TYPE_LPM); LPM_SLEEP(); + ENERGEST_OFF(ENERGEST_TYPE_LPM); + ENERGEST_ON(ENERGEST_TYPE_CPU); } } diff --git a/platform/msb430/dev/cc1020.c b/platform/msb430/dev/cc1020.c index 51d5788b9..c93ebe3c8 100644 --- a/platform/msb430/dev/cc1020.c +++ b/platform/msb430/dev/cc1020.c @@ -163,6 +163,9 @@ cc1020_set_rx(void) cc1020_setupRX(RX_CURRENT); LNA_POWER_ON(); // enable amplifier + ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); + ENERGEST_ON(ENERGEST_TYPE_LISTEN); + // activate IE1 |= URXIE0; // enable interrupt } @@ -186,6 +189,9 @@ cc1020_set_tx(void) U0CTL |= SWRST; // UART to reset mode IFG1 &= ~UTXIFG0; // Reset IFG. + ENERGEST_OFF(ENERGEST_TYPE_LISTEN); + ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); + // configure driver cc1020_state = CC1020_TX; } @@ -286,6 +292,9 @@ cc1020_off(void) cc1020_setupPD(); // power down radio cc1020_state = CC1020_OFF; + ENERGEST_OFF(ENERGEST_TYPE_LISTEN); + ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); + return 1; }