Moved sensors setup to contiki-sky-platform.c and common make rules to Makefile.common for easier reuse in similar platforms

This commit is contained in:
nifi 2010-05-03 13:51:11 +00:00
parent 6c86398778
commit bf198ec695
4 changed files with 216 additions and 177 deletions

View file

@ -0,0 +1,162 @@
# $Id: Makefile.common,v 1.1 2010/05/03 13:51:11 nifi Exp $
ARCH=spi.c ds2411.c xmem.c i2c.c node-id.c sensors.c cfs-coffee.c \
cc2420.c cc2420-aes.c cc2420-arch.c cc2420-arch-sfd.c \
sky-sensors.c uip-ipchksum.c \
checkpoint-arch.c #slip.c slip_uart1.c
CONTIKI_TARGET_DIRS = . dev apps net
ifndef CONTIKI_TARGET_MAIN
CONTIKI_TARGET_MAIN = contiki-sky-main.c
endif
ifdef UIP_CONF_IPV6
CFLAGS += -DWITH_UIP6=1
endif
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) $(CONTIKI_TARGET_MAIN)
MCU=msp430x1611
include $(CONTIKI)/cpu/msp430/Makefile.msp430
contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
# $(AR) rcf $@ $^
NUMPAR=20
IHEXFILE=tmpimage.ihex
# Check if we are running under Windows
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
USBDEVPREFIX=/dev/com
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-windows
MOTELIST = $(CONTIKI)/tools/sky/motelist-windows
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/tmote-bsl.exe),1,0)
ifeq ($(TMOTE_BSL), 1)
NUMPAR = 1
BSL = $(CONTIKI)/tools/sky/tmote-bsl
MOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ )
else
BSL = $(CONTIKI)/tools/sky/msp430-bsl-windows --telosb
BSL_FILETYPE = -I
MOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ | \
perl -ne 'print $$1 - 1 . " " if(/COM(\d+)/);')
endif
CMOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ | \
perl -ne 'print $$1 . " " if(/COM(\d+)/);')
endif
endif
# If we are not running under Windows, we assume Linux
ifndef MOTELIST
USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST = $(CONTIKI)/tools/sky/motelist-linux
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/tmote-bsl-linux),1,0)
ifeq ($(TMOTE_BSL), 1)
PATH := $(PATH):$(CONTIKI)/tools/sky
BSL = $(CONTIKI)/tools/sky/tmote-bsl-linux
NUMPAR = 1
else
BSL = $(CONTIKI)/tools/sky/msp430-bsl-linux --telosb
BSL_FILETYPE = -I
endif
MOTES = $(shell $(MOTELIST) 2>&- | grep USB | \
cut -f 4 -d \ | \
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
CMOTES=$(MOTES)
endif
sky-motelist:
$(MOTELIST)
sky-motes:
@echo $(MOTES)
ifdef MOTE
%.upload: %.ihex
cp $< $(IHEXFILE)
$(MAKE) sky-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
else # MOTE
%.upload: %.ihex
cp $< $(IHEXFILE)
$(MAKE) sky-reset sky-upload
endif # MOTE
upload-ihex:
ifdef FILE
@echo Uploading $(FILE)
cp $(FILE) $(IHEXFILE)
ifdef MOTE
$(MAKE) sky-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
else # MOTE
$(MAKE) sky-reset sky-upload
endif # MOTE
else
@echo Example: $(MAKE) upload-ihex FILE=myfile.ihex
endif
sky-upload: sky-reset
$(MAKE) -j $(NUMPAR) sky-upload-sequence
sky-upload-sequence: $(foreach PORT, $(MOTES), sky-u.$(subst /,-,$(PORT)))
@echo Done
sky-reset:
$(MAKE) -k -j $(NUMPAR) sky-reset-sequence
sky-reset-sequence: $(foreach PORT, $(MOTES), sky-r.$(subst /,-,$(PORT)))
@echo Done
sky-u.%:
@echo +++++ Erasing $(subst -,/,$*); \
$(BSL) -c $(subst -,/,$*) -e && sleep 2 ; \
echo +++++ Programming $(subst -,/,$*) ; \
$(BSL) -c $(subst -,/,$*) $(BSL_FILETYPE) -p $(IHEXFILE) && sleep 2 ; \
echo +++++ Resetting $(subst -,/,$*) ; \
$(BSL) -c $(subst -,/,$*) -r
sky-r.%:
$(BSL) -c $(subst -,/,$*) -r
sizeplot:
msp430-size $(OBJECTDIR)/*.o | $(CONTIKI)/tools/sky/check-size > size-data
gnuplot $(CONTIKI)/tools/sky/plot-size
gv size.pdf
winslip:
ifdef INTERFACE
$(CONTIKI)/tools/wpcapslip/wpcapslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) $(INTERFACE) 172.16.0.0 255.255.0.0
else
@echo "Usage: \"$(MAKE) $@ INTERFACE=<the IP address of a local network interface>\""
@echo "Use the \"ipconfig\" command to find out the IP addresses of the local interfaces"
endif
linslip: $(CONTIKI)/tools/tunslip
$(CONTIKI)/tools/tunslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) 172.16.0.0 255.255.0.0
$(CONTIKI)/tools/tunslip:
(cd $(CONTIKI)/tools; $(MAKE) tunslip)
ifdef MOTE
serialdump:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) | $(CONTIKI)/tools/timestamp | tee serialdump-`date +%Y%m%d-%H%M`
serialview:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) | $(CONTIKI)/tools/timestamp
login:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES))
else
serialdump:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES)) | $(CONTIKI)/tools/timestamp | tee serialdump-`date +%Y%m%d-%H%M`
serialview:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES)) | $(CONTIKI)/tools/timestamp
login:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES))
endif

View file

@ -1,167 +1,7 @@
# $Id: Makefile.sky,v 1.37 2010/03/10 11:46:57 fros4943 Exp $
# $Id: Makefile.sky,v 1.38 2010/05/03 13:51:11 nifi Exp $
CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c \
sht11.c sht11-sensor.c light-sensor.c battery-sensor.c \
button-sensor.c radio-sensor.c
ARCH=msp430.c leds.c watchdog.c spi.c ds2411.c \
xmem.c i2c.c sht11.c light-sensor.c acc-sensor.c battery-sensor.c \
cc2420.c cc2420-aes.c cc2420-arch.c cc2420-arch-sfd.c sht11-sensor.c \
node-id.c sensors.c button-sensor.c cfs-coffee.c sky-sensors.c\
radio-sensor.c uart1.c uip-ipchksum.c ext-sensor.c\
checkpoint-arch.c #slip.c slip_uart1.c
#ext-sensor.c irq.c \
CONTIKI_TARGET_DIRS = . dev apps net
ifndef CONTIKI_TARGET_MAIN
CONTIKI_TARGET_MAIN = contiki-sky-main.c
endif
ifdef UIP_CONF_IPV6
CFLAGS += -DWITH_UIP6=1
endif
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) $(CONTIKI_TARGET_MAIN)
MCU=msp430x1611
include $(CONTIKI)/cpu/msp430/Makefile.msp430
contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
# $(AR) rcf $@ $^
NUMPAR=20
IHEXFILE=tmpimage.ihex
# Check if we are running under Windows
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
USBDEVPREFIX=/dev/com
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-windows
MOTELIST = $(CONTIKI)/tools/sky/motelist-windows
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/tmote-bsl.exe),1,0)
ifeq ($(TMOTE_BSL), 1)
NUMPAR = 1
BSL = $(CONTIKI)/tools/sky/tmote-bsl
MOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ )
else
BSL = $(CONTIKI)/tools/sky/msp430-bsl-windows --telosb
BSL_FILETYPE = -I
MOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ | \
perl -ne 'print $$1 - 1 . " " if(/COM(\d+)/);')
endif
CMOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ | \
perl -ne 'print $$1 . " " if(/COM(\d+)/);')
endif
endif
# If we are not running under Windows, we assume Linux
ifndef MOTELIST
USBDEVPREFIX=
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
MOTELIST = $(CONTIKI)/tools/sky/motelist-linux
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/tmote-bsl-linux),1,0)
ifeq ($(TMOTE_BSL), 1)
PATH := $(PATH):$(CONTIKI)/tools/sky
BSL = $(CONTIKI)/tools/sky/tmote-bsl-linux
NUMPAR = 1
else
BSL = $(CONTIKI)/tools/sky/msp430-bsl-linux --telosb
BSL_FILETYPE = -I
endif
MOTES = $(shell $(MOTELIST) 2>&- | grep USB | \
cut -f 4 -d \ | \
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
CMOTES=$(MOTES)
endif
sky-motelist:
$(MOTELIST)
sky-motes:
@echo $(MOTES)
ifdef MOTE
%.upload: %.ihex
cp $< $(IHEXFILE)
$(MAKE) sky-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
else # MOTE
%.upload: %.ihex
cp $< $(IHEXFILE)
$(MAKE) sky-reset sky-upload
endif # MOTE
upload-ihex:
ifdef FILE
echo Uploading $(FILE)
cp $(FILE) $(IHEXFILE)
ifdef MOTE
$(MAKE) sky-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
else # MOTE
$(MAKE) sky-reset sky-upload
endif # MOTE
else
@echo Example: $(MAKE) upload-ihex FILE=myfile.ihex
endif
sky-upload: sky-reset
$(MAKE) -j $(NUMPAR) sky-upload-sequence
sky-upload-sequence: $(foreach PORT, $(MOTES), sky-u.$(subst /,-,$(PORT)))
@echo Done
sky-reset:
$(MAKE) -k -j $(NUMPAR) sky-reset-sequence
sky-reset-sequence: $(foreach PORT, $(MOTES), sky-r.$(subst /,-,$(PORT)))
@echo Done
sky-u.%:
@echo +++++ Erasing $(subst -,/,$*); \
$(BSL) -c $(subst -,/,$*) -e && sleep 2 ; \
echo +++++ Programming $(subst -,/,$*) ; \
$(BSL) -c $(subst -,/,$*) $(BSL_FILETYPE) -p $(IHEXFILE) && sleep 2 ; \
echo +++++ Resetting $(subst -,/,$*) ; \
$(BSL) -c $(subst -,/,$*) -r
sky-r.%:
$(BSL) -c $(subst -,/,$*) -r
sizeplot:
msp430-size $(OBJECTDIR)/*.o | $(CONTIKI)/tools/sky/check-size > size-data
gnuplot $(CONTIKI)/tools/sky/plot-size
gv size.pdf
winslip:
ifdef INTERFACE
$(CONTIKI)/tools/wpcapslip/wpcapslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) $(INTERFACE) 172.16.0.0 255.255.0.0
else
@echo "Usage: \"$(MAKE) $@ INTERFACE=<the IP address of a local network interface>\""
@echo "Use the \"ipconfig\" command to find out the IP addresses of the local interfaces"
endif
linslip: $(CONTIKI)/tools/tunslip
$(CONTIKI)/tools/tunslip -s $(USBDEVPREFIX)$(firstword $(CMOTES)) 172.16.0.0 255.255.0.0
$(CONTIKI)/tools/tunslip:
(cd $(CONTIKI)/tools; $(MAKE) tunslip)
ifdef MOTE
serialdump:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) | $(CONTIKI)/tools/timestamp | tee serialdump-`date +%Y%m%d-%H%M`
serialview:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) | $(CONTIKI)/tools/timestamp
login:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES))
else
serialdump:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES)) | $(CONTIKI)/tools/timestamp | tee serialdump-`date +%Y%m%d-%H%M`
serialview:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES)) | $(CONTIKI)/tools/timestamp
login:
$(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES))
endif
include $(CONTIKI)/platform/sky/Makefile.common

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)$Id: contiki-sky-main.c,v 1.80 2010/05/01 13:07:31 joxe Exp $
* @(#)$Id: contiki-sky-main.c,v 1.81 2010/05/03 13:51:11 nifi Exp $
*/
#include <signal.h>
@ -41,14 +41,12 @@
#include "dev/ds2411.h"
#include "dev/leds.h"
#include "dev/serial-line.h"
#include "dev/sht11.h"
#include "dev/slip.h"
#include "dev/uart1.h"
#include "dev/watchdog.h"
#include "dev/xmem.h"
#include "lib/random.h"
#include "net/netstack.h"
#include "net/mac/frame802154.h"
#if WITH_UIP6
#include "net/uip-ds6.h"
@ -62,14 +60,6 @@
#include "sys/autostart.h"
#include "sys/profile.h"
#include "dev/battery-sensor.h"
#include "dev/button-sensor.h"
#include "dev/light-sensor.h"
#include "dev/sht11-sensor.h"
SENSORS(&button_sensor);
#if UIP_CONF_ROUTER
#ifndef UIP_ROUTER_MODULE
@ -113,6 +103,8 @@ static uint8_t is_gateway;
#include "experiment-setup.h"
#endif
void init_platform(void);
/*---------------------------------------------------------------------------*/
#if 0
int
@ -251,10 +243,11 @@ main(int argc, char **argv)
*/
process_init();
process_start(&etimer_process, NULL);
process_start(&sensors_process, NULL);
ctimer_init();
init_platform();
set_rime_addr();
cc2420_init();

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2010, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 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
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* 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
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
* Author: Niclas Finne <nfi@sics.se>, Joakim Eriksson <joakime@sics.se>
*
* $Id: contiki-sky-platform.c,v 1.1 2010/05/03 13:51:11 nifi Exp $
*/
#include "dev/button-sensor.h"
SENSORS(&button_sensor);
void
init_platform(void)
{
process_start(&sensors_process, NULL);
}