Different and hopefully correct low power management.

This commit is contained in:
bg- 2006-08-17 15:42:42 +00:00
parent 20bac141ca
commit fbd527bc8f
3 changed files with 44 additions and 14 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.2 2006/08/11 13:37:21 bg- Exp $
# $Id: Makefile,v 1.3 2006/08/17 15:42:42 bg- Exp $
#
# This makefile requires GNU make!
@ -18,7 +18,7 @@ SRCDIRS = dev ../../cpu/msp430 ${addprefix $(CORE)/,sys dev net lib loader} ../
MCU=msp430x1611
ARCH=msp430.o leds.o leds-arch.o watchdog.o lpm.o light.o button.o spi.o ds2411.o rom.o xmem.o
ARCH=msp430.o leds.o leds-arch.o watchdog.o light.o button.o spi.o ds2411.o rom.o xmem.o
SYSTEM=process.o procinit.o service.o clock.o etimer.o timer.o \
elfloader.o symtab.o
UIP=uip.o uiplib.o tcpip.o uip-fw.o uip-fw-service.o uipbuf.o \

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)$Id: dhclient.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
* @(#)$Id: dhclient.c,v 1.3 2006/08/17 15:42:42 bg- Exp $
*/
/*
@ -52,6 +52,8 @@
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include "contiki.h"
/* Also IP output. */
@ -61,7 +63,6 @@
#include "dev/slip.h"
#include "dev/cc2420.h"
#include "dev/lpm.h"
#include "dev/ds2411.h"
#include "dev/leds.h"
#include "dev/light.h"
@ -100,7 +101,7 @@ main(int argc, char **argv)
leds_toggle(LEDS_RED | LEDS_GREEN | LEDS_BLUE);
slip_arch_init(); /* Must come before first printf */
printf("Starting %s "
"($Id: dhclient.c,v 1.2 2006/08/09 16:13:40 bg- Exp $)\n", __FILE__);
"($Id: dhclient.c,v 1.3 2006/08/17 15:42:42 bg- Exp $)\n", __FILE__);
ds2411_init();
sensors_light_init();
cc2420_init();
@ -141,13 +142,21 @@ main(int argc, char **argv)
* This is the scheduler loop.
*/
printf("process_run()...\n");
lpm_on();
while (1) {
do {
/* Reset watchdog. */
} while(process_run() > 0);
/* Idle processing. */
LPM_SLEEP();
/*
* Idle processing.
*/
int s = splhigh(); /* Disable interrupts. */
if(process_nevents() != 0) {
splx(s); /* Re-enable interrupts. */
} else {
/* Re-enable interrupts and go to sleep atomically. */
_BIS_SR(GIE | SCG0 | CPUOFF); /* LPM1 sleep. */
}
}
return 0;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)$Id: gateway.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
* @(#)$Id: gateway.c,v 1.3 2006/08/17 15:42:42 bg- Exp $
*/
/*
@ -56,6 +56,8 @@
#include <stdio.h>
#include <string.h>
#include <io.h>
#include "contiki.h"
/* Also IP output. */
@ -64,7 +66,6 @@
#include "dev/slip.h"
#include "dev/cc2420.h"
#include "dev/lpm.h"
#include "dev/ds2411.h"
#include "dev/leds.h"
#include "dev/light.h"
@ -83,6 +84,18 @@
#include "net/psock.h"
void *force_psock_inclusion = &psock_init;
void *force_button_inclusion = &button_init;
#if 0
int
force_float_inclusion()
{
extern int __fixsfsi;
extern int __floatsisf;
extern int __mulsf3;
extern int __subsf3;
return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
}
#endif
void uip_log(char *msg) { puts(msg); }
@ -110,7 +123,7 @@ main(int argc, char **argv)
leds_toggle(LEDS_RED | LEDS_GREEN | LEDS_BLUE);
slip_arch_init(); /* Must come before first printf */
printf("Starting %s "
"($Id: gateway.c,v 1.2 2006/08/09 16:13:40 bg- Exp $)\n", __FILE__);
"($Id: gateway.c,v 1.3 2006/08/17 15:42:42 bg- Exp $)\n", __FILE__);
ds2411_init();
sensors_light_init();
cc2420_init();
@ -156,13 +169,21 @@ main(int argc, char **argv)
* This is the scheduler loop.
*/
printf("process_run()...\n");
lpm_on();
while (1) {
do {
/* Reset watchdog. */
} while(process_run() > 0);
/* Idle processing. */
LPM_SLEEP();
/*
* Idle processing.
*/
int s = splhigh(); /* Disable interrupts. */
if(process_nevents() != 0) {
splx(s); /* Re-enable interrupts. */
} else {
/* Re-enable interrupts and go to sleep atomically. */
_BIS_SR(GIE | SCG0 | CPUOFF); /* LPM1 sleep. */
}
}
return 0;