Definition of Z1 Starter Platform in contiki/platforms + LEDs + Potentiometer
This commit is contained in:
parent
74836c344a
commit
44ce1699f2
16 changed files with 1290 additions and 127 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -8,3 +8,5 @@ obj_*
|
|||
*.a
|
||||
*pyc
|
||||
*.pyc
|
||||
symbols.c
|
||||
symbols.h
|
||||
|
|
|
@ -2,9 +2,9 @@ ifndef TARGET
|
|||
TARGET=z1
|
||||
endif
|
||||
|
||||
CONTIKI_PROJECT = test-phidgets blink test-adxl345 tmp102-test test-battery test-potent
|
||||
CONTIKI_PROJECT = test-phidgets blink test-adxl345 tmp102-test test-battery #test-potent
|
||||
CONTIKI_SOURCEFILES += cc2420-arch.c
|
||||
PROJECT_SOURCEFILES = i2cmaster.c tmp102.c adxl345.c battery-sensor.c sky-sensors.c potentiometer-sensor.c
|
||||
PROJECT_SOURCEFILES = i2cmaster.c tmp102.c adxl345.c battery-sensor.c sky-sensors.c #potentiometer-sensor.c
|
||||
APPS=serial-shell
|
||||
|
||||
|
||||
|
|
14
examples/z1sp/Makefile
Normal file
14
examples/z1sp/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
ifndef TARGET
|
||||
TARGET=z1sp
|
||||
endif
|
||||
|
||||
CONTIKI_PROJECT = test-potentiometer
|
||||
CONTIKI_SOURCEFILES += cc2420-arch.c
|
||||
PROJECT_SOURCEFILES = sky-sensors.c potentiometer-sensor.c
|
||||
APPS=serial-shell
|
||||
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
1
examples/z1sp/Makefile.target
Normal file
1
examples/z1sp/Makefile.target
Normal file
|
@ -0,0 +1 @@
|
|||
TARGET = z1sp
|
32
examples/z1sp/test-potentiometer.c
Normal file
32
examples/z1sp/test-potentiometer.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "contiki.h"
|
||||
|
||||
#include "dev/potentiometer-sensor.h"
|
||||
#include <stdio.h> /* For printf() */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(aplicacio, "Aplicacio de prova");
|
||||
AUTOSTART_PROCESSES(&aplicacio);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(aplicacio, ev, data)
|
||||
{
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
SENSORS_ACTIVATE(potentiometer_sensor);
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
uint16_t v = potentiometer_sensor.value(0);
|
||||
|
||||
printf("Potentiometer Value: %i\n", v);
|
||||
}
|
||||
|
||||
SENSORS_DEACTIVATE(potentiometer_sensor);
|
||||
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
127
platform/z1/Makefile.common
Normal file
127
platform/z1/Makefile.common
Normal file
|
@ -0,0 +1,127 @@
|
|||
# $Id: Makefile.z1,v 1.5 2011/02/26 enricmcalvo Exp $
|
||||
|
||||
CFLAGS+=-Os -g
|
||||
CLEAN += symbols.c symbols.h
|
||||
|
||||
ARCH=msp430.c leds.c watchdog.c xmem.c \
|
||||
spix.c cc2420.c cc2420-aes.c cc2420-arch.c cc2420-arch-sfd.c\
|
||||
node-id.c sensors.c button-sensor.c cfs-coffee.c \
|
||||
radio-sensor.c uart0x.c uart0-putchar.c uip-ipchksum.c \
|
||||
checkpoint-arch.c slip.c slip_uart0.c z1-phidgets.c
|
||||
|
||||
CONTIKI_TARGET_DIRS = . dev apps net
|
||||
ifndef CONTIKI_TARGET_MAIN
|
||||
CONTIKI_TARGET_MAIN = contiki-z1-main.c
|
||||
endif
|
||||
|
||||
ifdef UIP_CONF_IPV6
|
||||
CFLAGS += -DWITH_UIP6=1
|
||||
endif
|
||||
|
||||
ifdef nodemac
|
||||
CFLAGS += -DMACID=$(nodemac)
|
||||
endif
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) $(CONTIKI_TARGET_MAIN)
|
||||
CONTIKI_TARGET_SOURCEFILES += contiki-z1-platform.c
|
||||
|
||||
MCU=msp430x2617
|
||||
include $(CONTIKI)/cpu/msp430/Makefile.msp430
|
||||
|
||||
contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
|
||||
# $(AR) rcf $@ $^
|
||||
|
||||
|
||||
NUMPAR=20
|
||||
IHEXFILE=tmpimage.ihex
|
||||
|
||||
# If we are not running under Windows, we assume Linux
|
||||
ifndef MOTELIST
|
||||
USBDEVPREFIX=
|
||||
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
|
||||
MOTELIST = $(CONTIKI)/tools/z1/motelist-z1
|
||||
BSL = $(CONTIKI)/tools/z1/z1-bsl-nopic --z1
|
||||
BSL_FILETYPE = -I
|
||||
MOTES = $(shell $(MOTELIST) -c 2>&- | \
|
||||
cut -f 2 -d , | \
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
|
||||
CMOTES=$(MOTES)
|
||||
endif
|
||||
|
||||
z1-motelist:
|
||||
$(MOTELIST)
|
||||
z1-motes:
|
||||
@echo $(MOTES)
|
||||
|
||||
ifdef MOTE
|
||||
%.upload: %.ihex
|
||||
cp $< $(IHEXFILE)
|
||||
$(MAKE) z1-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
|
||||
else # MOTE
|
||||
%.upload: %.ihex
|
||||
cp $< $(IHEXFILE)
|
||||
@echo $(MOTES)
|
||||
$(MAKE) z1-reset z1-upload
|
||||
endif # MOTE
|
||||
|
||||
z1-upload: z1-reset
|
||||
$(MAKE) -j $(NUMPAR) z1-upload-sequence
|
||||
|
||||
z1-upload-sequence: $(foreach PORT, $(MOTES), z1-u.$(subst /,-,$(PORT)))
|
||||
@echo Done
|
||||
|
||||
z1-reset:
|
||||
$(MAKE) -k -j $(NUMPAR) z1-reset-sequence
|
||||
|
||||
z1-reset-sequence: $(foreach PORT, $(MOTES), z1-r.$(subst /,-,$(PORT)))
|
||||
@echo Done
|
||||
|
||||
z1-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
|
||||
|
||||
z1-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
|
|
@ -1,126 +1,7 @@
|
|||
# $Id: Makefile.z1,v 1.4 2010/11/07 08:40:24 enricmcalvo Exp $
|
||||
# Common makefile between Z1 and Z1 Starter Platform
|
||||
|
||||
CFLAGS+=-Os -g
|
||||
CLEAN += *.z1 symbols.c symbols.h
|
||||
CONTIKI_TARGET_SOURCEFILES += contiki-z1-platform.c
|
||||
CLEAN += *.z1
|
||||
|
||||
ARCH=msp430.c leds.c watchdog.c xmem.c \
|
||||
spix.c cc2420.c cc2420-aes.c cc2420-arch.c cc2420-arch-sfd.c\
|
||||
node-id.c sensors.c button-sensor.c cfs-coffee.c \
|
||||
radio-sensor.c uart0x.c uart0-putchar.c uip-ipchksum.c \
|
||||
checkpoint-arch.c slip.c slip_uart0.c z1-phidgets.c
|
||||
include $(CONTIKI)/platform/z1/Makefile.common
|
||||
|
||||
CONTIKI_TARGET_DIRS = . dev apps net
|
||||
ifndef CONTIKI_TARGET_MAIN
|
||||
CONTIKI_TARGET_MAIN = contiki-z1-main.c
|
||||
endif
|
||||
|
||||
ifdef UIP_CONF_IPV6
|
||||
CFLAGS += -DWITH_UIP6=1
|
||||
endif
|
||||
|
||||
ifdef nodemac
|
||||
CFLAGS += -DMACID=$(nodemac)
|
||||
endif
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) $(CONTIKI_TARGET_MAIN)
|
||||
|
||||
MCU=msp430x2617
|
||||
include $(CONTIKI)/cpu/msp430/Makefile.msp430
|
||||
|
||||
contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
|
||||
# $(AR) rcf $@ $^
|
||||
|
||||
|
||||
NUMPAR=20
|
||||
IHEXFILE=tmpimage.ihex
|
||||
|
||||
# If we are not running under Windows, we assume Linux
|
||||
ifndef MOTELIST
|
||||
USBDEVPREFIX=
|
||||
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux
|
||||
MOTELIST = $(CONTIKI)/tools/z1/motelist-z1
|
||||
BSL = $(CONTIKI)/tools/z1/z1-bsl-nopic --z1
|
||||
BSL_FILETYPE = -I
|
||||
MOTES = $(shell $(MOTELIST) -c 2>&- | \
|
||||
cut -f 2 -d , | \
|
||||
perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);')
|
||||
CMOTES=$(MOTES)
|
||||
endif
|
||||
|
||||
z1-motelist:
|
||||
$(MOTELIST)
|
||||
z1-motes:
|
||||
@echo $(MOTES)
|
||||
|
||||
ifdef MOTE
|
||||
%.upload: %.ihex
|
||||
cp $< $(IHEXFILE)
|
||||
$(MAKE) z1-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
|
||||
else # MOTE
|
||||
%.upload: %.ihex
|
||||
cp $< $(IHEXFILE)
|
||||
@echo $(MOTES)
|
||||
$(MAKE) z1-reset z1-upload
|
||||
endif # MOTE
|
||||
|
||||
z1-upload: z1-reset
|
||||
$(MAKE) -j $(NUMPAR) z1-upload-sequence
|
||||
|
||||
z1-upload-sequence: $(foreach PORT, $(MOTES), z1-u.$(subst /,-,$(PORT)))
|
||||
@echo Done
|
||||
|
||||
z1-reset:
|
||||
$(MAKE) -k -j $(NUMPAR) z1-reset-sequence
|
||||
|
||||
z1-reset-sequence: $(foreach PORT, $(MOTES), z1-r.$(subst /,-,$(PORT)))
|
||||
@echo Done
|
||||
|
||||
z1-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
|
||||
|
||||
z1-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
|
||||
|
|
|
@ -106,6 +106,8 @@ static uint8_t is_gateway;
|
|||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
void init_platform(void);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
int
|
||||
|
@ -251,10 +253,10 @@ main(int argc, char **argv)
|
|||
process_init();
|
||||
process_start(&etimer_process, NULL);
|
||||
|
||||
process_start(&sensors_process, NULL);
|
||||
|
||||
ctimer_init();
|
||||
|
||||
init_platform(); //Enric_Z1SP process_start(&sensors_process, NULL);
|
||||
|
||||
set_rime_addr();
|
||||
|
||||
cc2420_init();
|
||||
|
|
42
platform/z1/contiki-z1-platform.c
Normal file
42
platform/z1/contiki-z1-platform.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2011, Zolertia(TM) is a trademark of Advancare,SL
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Author: Enric M. Calvo <ecalvo@zolertia.com> based on previous work by
|
||||
* 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"
|
||||
|
||||
void
|
||||
init_platform(void)
|
||||
{
|
||||
process_start(&sensors_process, NULL);
|
||||
}
|
18
platform/z1sp/Makefile.z1sp
Normal file
18
platform/z1sp/Makefile.z1sp
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Makefile for Z1 Starter Platform, adapted from the Z1 platform makefile
|
||||
|
||||
CFLAGS += -DCONTIKI_TARGET_Z1
|
||||
|
||||
CONTIKI_TARGET_DIRS += . dev
|
||||
#CONTIKI_CORE=contiki-z1sp-main
|
||||
#CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.c
|
||||
|
||||
# include here
|
||||
CONTIKI_TARGET_SOURCEFILES += contiki-z1sp-platform.c potentiometer-sensor.c
|
||||
|
||||
CONTIKIZ1PLATFORMDIR = $(CONTIKI)/platform/z1
|
||||
|
||||
CLEAN += *.z1sp
|
||||
|
||||
include $(CONTIKIZ1PLATFORMDIR)/Makefile.common
|
||||
|
||||
CONTIKI_TARGET_DIRS += ${addprefix $(CONTIKIZ1PLATFORMDIR)/,. dev apps net}
|
480
platform/z1sp/_del/contiki-z1sp-main.c
Normal file
480
platform/z1sp/_del/contiki-z1sp-main.c
Normal file
|
@ -0,0 +1,480 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 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.
|
||||
*
|
||||
* @(#)$Id: contiki-z1-main.c,v 1.4 2010/08/26 22:08:11 nifi Exp $
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h> //Enric_Joakim
|
||||
|
||||
#include <io.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/cc2420.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/serial-line.h"
|
||||
#include "dev/slip.h"
|
||||
#include "dev/uart0.h"
|
||||
#include "dev/watchdog.h"
|
||||
#include "dev/xmem.h"
|
||||
#include "lib/random.h"
|
||||
#include "net/netstack.h"
|
||||
#include "net/mac/frame802154.h"
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
#if WITH_UIP6
|
||||
#include "net/uip-ds6.h"
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
#include "net/rime.h"
|
||||
|
||||
#include "node-id.h"
|
||||
#include "cfs-coffee-arch.h"
|
||||
#include "cfs/cfs-coffee.h"
|
||||
#include "sys/autostart.h"
|
||||
#include "sys/profile.h"
|
||||
|
||||
|
||||
#include "dev/battery-sensor.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/sht11-sensor.h"
|
||||
|
||||
SENSORS(&button_sensor);
|
||||
|
||||
#if DCOSYNCH_CONF_ENABLED
|
||||
static struct timer mgt_timer;
|
||||
#endif
|
||||
|
||||
#ifndef WITH_UIP
|
||||
#define WITH_UIP 0
|
||||
#endif
|
||||
|
||||
#if WITH_UIP
|
||||
#include "net/uip.h"
|
||||
#include "net/uip-fw.h"
|
||||
#include "net/uip-fw-drv.h"
|
||||
#include "net/uip-over-mesh.h"
|
||||
static struct uip_fw_netif slipif =
|
||||
{UIP_FW_NETIF(192,168,1,2, 255,255,255,255, slip_send)};
|
||||
static struct uip_fw_netif meshif =
|
||||
{UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
|
||||
|
||||
#endif /* WITH_UIP */
|
||||
|
||||
#define UIP_OVER_MESH_CHANNEL 8
|
||||
#if WITH_UIP
|
||||
static uint8_t is_gateway;
|
||||
#endif /* WITH_UIP */
|
||||
|
||||
#ifdef EXPERIMENT_SETUP
|
||||
#include "experiment-setup.h"
|
||||
#endif
|
||||
|
||||
#define DEBUG 1
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#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); }
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef RF_CHANNEL
|
||||
#define RF_CHANNEL 26
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
void
|
||||
force_inclusion(int d1, int d2)
|
||||
{
|
||||
snprintf(NULL, 0, "%d", d1 % d2);
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
set_rime_addr(void)
|
||||
{
|
||||
rimeaddr_t addr;
|
||||
int i;
|
||||
|
||||
memset(&addr, 0, sizeof(rimeaddr_t));
|
||||
#if UIP_CONF_IPV6
|
||||
memcpy(addr.u8, node_mac, sizeof(addr.u8));
|
||||
#else
|
||||
if(node_id == 0) {
|
||||
for(i = 0; i < sizeof(rimeaddr_t); ++i) {
|
||||
addr.u8[i] = node_mac[7 - i];
|
||||
}
|
||||
} else {
|
||||
addr.u8[0] = node_id & 0xff;
|
||||
addr.u8[1] = node_id >> 8;
|
||||
}
|
||||
#endif
|
||||
rimeaddr_set_node_addr(&addr);
|
||||
printf("Rime started with address ");
|
||||
for(i = 0; i < sizeof(addr.u8) - 1; i++) {
|
||||
printf("%d.", addr.u8[i]);
|
||||
}
|
||||
printf("%d\n", addr.u8[i]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
print_processes(struct process * const processes[])
|
||||
{
|
||||
/* const struct process * const * p = processes;*/
|
||||
printf("Starting");
|
||||
while(*processes != NULL) {
|
||||
printf(" '%s'", (*processes)->name);
|
||||
processes++;
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#if WITH_UIP
|
||||
static void
|
||||
set_gateway(void)
|
||||
{
|
||||
if(!is_gateway) {
|
||||
leds_on(LEDS_RED);
|
||||
printf("%d.%d: making myself the IP network gateway.\n\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
||||
printf("IPv4 address of the gateway: %d.%d.%d.%d\n\n",
|
||||
uip_ipaddr_to_quad(&uip_hostaddr));
|
||||
uip_over_mesh_set_gateway(&rimeaddr_node_addr);
|
||||
uip_over_mesh_make_announced_gateway();
|
||||
is_gateway = 1;
|
||||
}
|
||||
}
|
||||
#endif /* WITH_UIP */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
* Initalize hardware.
|
||||
*/
|
||||
msp430_cpu_init();
|
||||
clock_init();
|
||||
leds_init();
|
||||
leds_on(LEDS_RED);
|
||||
|
||||
clock_wait(100);
|
||||
|
||||
uart0_init(BAUD2UBR(115200)); /* Must come before first printf */
|
||||
#if WITH_UIP
|
||||
slip_arch_init(BAUD2UBR(115200));
|
||||
#endif /* WITH_UIP */
|
||||
|
||||
/* XXX hack: Fix it so that the 802.15.4 MAC address is compatible
|
||||
with an Ethernet MAC address - byte 0 (byte 2 in the DS ID)
|
||||
cannot be odd. */
|
||||
//Enric node_mac[2] &= 0xfe;
|
||||
node_mac[0] = 0x00;
|
||||
node_mac[1] = 0x12;
|
||||
node_mac[2] = 0x76;
|
||||
node_mac[3] = 0x01;
|
||||
node_mac[4] = 0x02;
|
||||
node_mac[5] = 0x03;
|
||||
node_mac[2] = 0x04;
|
||||
node_mac[7] = 0x05;
|
||||
|
||||
|
||||
xmem_init();
|
||||
|
||||
rtimer_init();
|
||||
/*
|
||||
* Hardware initialization done!
|
||||
*/
|
||||
|
||||
|
||||
/* Restore node id if such has been stored in external mem */
|
||||
node_id_restore();
|
||||
|
||||
|
||||
/* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
|
||||
#ifdef IEEE_802154_MAC_ADDRESS
|
||||
{
|
||||
uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
|
||||
memcpy(node_mac, ieee, sizeof(uip_lladdr.addr));
|
||||
node_mac[7] = node_id & 0xff;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Enric random_init(node_mac[0] + node_id);
|
||||
|
||||
/*
|
||||
* Initialize Contiki and our processes.
|
||||
*/
|
||||
process_init();
|
||||
process_start(&etimer_process, NULL);
|
||||
|
||||
process_start(&sensors_process, NULL);
|
||||
|
||||
ctimer_init();
|
||||
|
||||
set_rime_addr();
|
||||
|
||||
cc2420_init();
|
||||
{
|
||||
uint8_t longaddr[8];
|
||||
uint16_t shortaddr;
|
||||
|
||||
shortaddr = (rimeaddr_node_addr.u8[0] << 8) +
|
||||
rimeaddr_node_addr.u8[1];
|
||||
memset(longaddr, 0, sizeof(longaddr));
|
||||
rimeaddr_copy((rimeaddr_t *)&longaddr, &rimeaddr_node_addr);
|
||||
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
|
||||
longaddr[0], longaddr[1], longaddr[2], longaddr[3],
|
||||
longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
|
||||
|
||||
cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
|
||||
}
|
||||
cc2420_set_channel(RF_CHANNEL);
|
||||
|
||||
leds_off(LEDS_ALL);
|
||||
|
||||
PRINTF(CONTIKI_VERSION_STRING " started. ");
|
||||
|
||||
if(node_id > 0) {
|
||||
PRINTF("Node id is set to %u.\n", node_id);
|
||||
} else {
|
||||
PRINTF("Node id is not set.\n");
|
||||
}
|
||||
|
||||
//Enric printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
//Enric node_mac[0], node_mac[1], node_mac[2], node_mac[3],
|
||||
//Enric node_mac[4], node_mac[5], node_mac[6], node_mac[7]);
|
||||
|
||||
#if WITH_UIP6
|
||||
PRINTF("in WITH_UIP6\n"); //Enric
|
||||
memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));
|
||||
/* Setup nullmac-like MAC for 802.15.4 */
|
||||
/* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */
|
||||
/* printf(" %s channel %u\n", sicslowmac_driver.name, RF_CHANNEL); */
|
||||
|
||||
/* Setup X-MAC for 802.15.4 */
|
||||
queuebuf_init();
|
||||
|
||||
NETSTACK_RDC.init();
|
||||
NETSTACK_MAC.init();
|
||||
NETSTACK_NETWORK.init();
|
||||
|
||||
printf("%s %s, channel check rate %lu Hz, radio channel %u\n",
|
||||
NETSTACK_MAC.name, NETSTACK_RDC.name,
|
||||
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
|
||||
NETSTACK_RDC.channel_check_interval()),
|
||||
RF_CHANNEL);
|
||||
|
||||
process_start(&tcpip_process, NULL);
|
||||
|
||||
printf("Tentative link-local IPv6 address ");
|
||||
{
|
||||
uip_ds6_addr_t *lladdr;
|
||||
int i;
|
||||
lladdr = uip_ds6_get_link_local(-1);
|
||||
for(i = 0; i < 7; ++i) {
|
||||
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
|
||||
lladdr->ipaddr.u8[i * 2 + 1]);
|
||||
}
|
||||
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
|
||||
}
|
||||
|
||||
if(!UIP_CONF_IPV6_RPL) {
|
||||
uip_ipaddr_t ipaddr;
|
||||
int i;
|
||||
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
||||
uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
|
||||
printf("Tentative global IPv6 address ");
|
||||
for(i = 0; i < 7; ++i) {
|
||||
printf("%02x%02x:",
|
||||
ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
|
||||
}
|
||||
printf("%02x%02x\n",
|
||||
ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
|
||||
}
|
||||
|
||||
#else /* WITH_UIP6 */
|
||||
|
||||
NETSTACK_RDC.init();
|
||||
NETSTACK_MAC.init();
|
||||
NETSTACK_NETWORK.init();
|
||||
|
||||
printf("%s %s, channel check rate %lu Hz, radio channel %u\n",
|
||||
NETSTACK_MAC.name, NETSTACK_RDC.name,
|
||||
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
|
||||
NETSTACK_RDC.channel_check_interval()),
|
||||
RF_CHANNEL);
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
#if !WITH_UIP && !WITH_UIP6
|
||||
uart0_set_input(serial_line_input_byte);
|
||||
serial_line_init();
|
||||
#endif
|
||||
|
||||
#if PROFILE_CONF_ON
|
||||
profile_init();
|
||||
#endif /* PROFILE_CONF_ON */
|
||||
|
||||
leds_off(LEDS_GREEN);
|
||||
|
||||
#if TIMESYNCH_CONF_ENABLED
|
||||
timesynch_init();
|
||||
timesynch_set_authority_level(rimeaddr_node_addr.u8[0]);
|
||||
#endif /* TIMESYNCH_CONF_ENABLED */
|
||||
|
||||
#if WITH_UIP
|
||||
process_start(&tcpip_process, NULL);
|
||||
process_start(&uip_fw_process, NULL); /* Start IP output */
|
||||
process_start(&slip_process, NULL);
|
||||
|
||||
slip_set_input_callback(set_gateway);
|
||||
|
||||
{
|
||||
uip_ipaddr_t hostaddr, netmask;
|
||||
|
||||
uip_init();
|
||||
|
||||
uip_ipaddr(&hostaddr, 172,16,
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
||||
uip_ipaddr(&netmask, 255,255,0,0);
|
||||
uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
|
||||
|
||||
uip_sethostaddr(&hostaddr);
|
||||
uip_setnetmask(&netmask);
|
||||
uip_over_mesh_set_net(&hostaddr, &netmask);
|
||||
/* uip_fw_register(&slipif);*/
|
||||
uip_over_mesh_set_gateway_netif(&slipif);
|
||||
uip_fw_default(&meshif);
|
||||
uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
|
||||
printf("uIP started with IP address %d.%d.%d.%d\n",
|
||||
uip_ipaddr_to_quad(&hostaddr));
|
||||
}
|
||||
#endif /* WITH_UIP */
|
||||
|
||||
energest_init();
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
|
||||
print_processes(autostart_processes);
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
/*
|
||||
* This is the scheduler loop.
|
||||
*/
|
||||
#if DCOSYNCH_CONF_ENABLED
|
||||
timer_set(&mgt_timer, DCOSYNCH_PERIOD * CLOCK_SECOND);
|
||||
#endif
|
||||
watchdog_start();
|
||||
/* watchdog_stop();*/
|
||||
while(1) {
|
||||
int r;
|
||||
#if PROFILE_CONF_ON
|
||||
profile_episode_start();
|
||||
#endif /* PROFILE_CONF_ON */
|
||||
do {
|
||||
/* Reset watchdog. */
|
||||
watchdog_periodic();
|
||||
r = process_run();
|
||||
} while(r > 0);
|
||||
#if PROFILE_CONF_ON
|
||||
profile_episode_end();
|
||||
#endif /* PROFILE_CONF_ON */
|
||||
|
||||
/*
|
||||
* Idle processing.
|
||||
*/
|
||||
int s = splhigh(); /* Disable interrupts. */
|
||||
/* uart0_active is for avoiding LPM3 when still sending or receiving */
|
||||
if(process_nevents() != 0 || uart0_active()) {
|
||||
splx(s); /* Re-enable interrupts. */
|
||||
} else {
|
||||
static unsigned long irq_energest = 0;
|
||||
|
||||
#if DCOSYNCH_CONF_ENABLED
|
||||
/* before going down to sleep possibly do some management */
|
||||
if (timer_expired(&mgt_timer)) {
|
||||
timer_reset(&mgt_timer);
|
||||
msp430_sync_dco();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Re-enable interrupts and go to sleep atomically. */
|
||||
ENERGEST_OFF(ENERGEST_TYPE_CPU);
|
||||
ENERGEST_ON(ENERGEST_TYPE_LPM);
|
||||
/* We only want to measure the processing done in IRQs when we
|
||||
are asleep, so we discard the processing time done when we
|
||||
were awake. */
|
||||
energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
|
||||
watchdog_stop();
|
||||
_BIS_SR(GIE | SCG0 | SCG1 | CPUOFF); /* LPM3 sleep. This
|
||||
statement will block
|
||||
until the CPU is
|
||||
woken up by an
|
||||
interrupt that sets
|
||||
the wake up flag. */
|
||||
|
||||
/* We get the current processing time for interrupts that was
|
||||
done during the LPM and store it for next time around. */
|
||||
dint();
|
||||
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
|
||||
eint();
|
||||
watchdog_start();
|
||||
ENERGEST_OFF(ENERGEST_TYPE_LPM);
|
||||
ENERGEST_ON(ENERGEST_TYPE_CPU);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if LOG_CONF_ENABLED
|
||||
void
|
||||
log_message(char *m1, char *m2)
|
||||
{
|
||||
printf("%s%s\n", m1, m2);
|
||||
}
|
||||
#endif /* LOG_CONF_ENABLED */
|
||||
|
197
platform/z1sp/contiki-conf.h
Normal file
197
platform/z1sp/contiki-conf.h
Normal file
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONTIKI_CONF_H
|
||||
#define CONTIKI_CONF_H
|
||||
|
||||
|
||||
#include "platform-conf.h"
|
||||
|
||||
#define XMAC_CONF_COMPOWER 1
|
||||
#define CXMAC_CONF_COMPOWER 1
|
||||
|
||||
#if WITH_UIP6
|
||||
|
||||
/* Network setup for IPv6 */
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
/* #define NETSTACK_CONF_MAC nullmac_driver */
|
||||
/* #define NETSTACK_CONF_RDC sicslowmac_driver */
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
#define NETSTACK_CONF_RDC contikimac_driver
|
||||
#define NETSTACK_CONF_RADIO cc2420_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
|
||||
#define CC2420_CONF_AUTOACK 1
|
||||
#define NETSTACK_RDC_CHANNEL_CHECK_RATE 8
|
||||
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
|
||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
||||
|
||||
#define QUEUEBUF_CONF_NUM 4
|
||||
|
||||
#else /* WITH_UIP6 */
|
||||
|
||||
/* Network setup for non-IPv6 (rime). */
|
||||
|
||||
#define NETSTACK_CONF_NETWORK rime_driver
|
||||
#define NETSTACK_CONF_MAC csma_driver
|
||||
/* #define NETSTACK_CONF_RDC contikimac_driver */
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
|
||||
#define CC2420_CONF_AUTOACK 0
|
||||
#define MAC_CONF_CHANNEL_CHECK_RATE 8
|
||||
|
||||
#define COLLECT_CONF_ANNOUNCEMENTS 1
|
||||
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
|
||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define XMAC_CONF_ANNOUNCEMENTS 0
|
||||
#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0
|
||||
|
||||
#define CONTIKIMAC_CONF_COMPOWER 1
|
||||
#define XMAC_CONF_COMPOWER 1
|
||||
#define CXMAC_CONF_COMPOWER 1
|
||||
|
||||
#define COLLECT_NEIGHBOR_CONF_MAX_NEIGHBORS 32
|
||||
|
||||
#define QUEUEBUF_CONF_NUM 8
|
||||
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
#define PACKETBUF_CONF_ATTRS_INLINE 1
|
||||
|
||||
#ifndef RF_CHANNEL
|
||||
#define RF_CHANNEL 26
|
||||
#endif /* RF_CHANNEL */
|
||||
|
||||
#define IEEE802154_CONF_PANID 0xABCD
|
||||
|
||||
#define SHELL_VARS_CONF_RAM_BEGIN 0x1100
|
||||
#define SHELL_VARS_CONF_RAM_END 0x2000
|
||||
|
||||
|
||||
#define CFS_CONF_OFFSET_TYPE long
|
||||
|
||||
#define PROFILE_CONF_ON 0
|
||||
#define ENERGEST_CONF_ON 0
|
||||
|
||||
#define ELFLOADER_CONF_TEXT_IN_ROM 0
|
||||
#define ELFLOADER_CONF_DATAMEMORY_SIZE 0x400
|
||||
#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x800
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define AODV_COMPLIANCE
|
||||
#define AODV_NUM_RT_ENTRIES 32
|
||||
|
||||
#define WITH_ASCII 1
|
||||
|
||||
#define PROCESS_CONF_NUMEVENTS 8
|
||||
#define PROCESS_CONF_STATS 1
|
||||
/*#define PROCESS_CONF_FASTPOLL 4*/
|
||||
|
||||
|
||||
#define UART0_CONF_TX_WITH_INTERRUPT 0 // So far, printfs without interrupt.
|
||||
|
||||
#ifdef WITH_UIP6
|
||||
|
||||
#define RIMEADDR_CONF_SIZE 8
|
||||
|
||||
#define UIP_CONF_LL_802154 1
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
|
||||
#define UIP_CONF_ROUTER 1
|
||||
#define UIP_CONF_IPV6_RPL 1
|
||||
|
||||
/* Handle 10 neighbors */
|
||||
#define UIP_CONF_DS6_NBR_NBU 15
|
||||
/* Handle 10 routes */
|
||||
#define UIP_CONF_DS6_ROUTE_NBU 15
|
||||
|
||||
#define UIP_CONF_ND6_SEND_RA 0
|
||||
#define UIP_CONF_ND6_REACHABLE_TIME 600000
|
||||
#define UIP_CONF_ND6_RETRANS_TIMER 10000
|
||||
|
||||
#define UIP_CONF_IPV6 1
|
||||
#define UIP_CONF_IPV6_QUEUE_PKT 0
|
||||
#define UIP_CONF_IPV6_CHECKS 1
|
||||
#define UIP_CONF_IPV6_REASSEMBLY 0
|
||||
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
|
||||
#define UIP_CONF_ND6_MAX_PREFIXES 3
|
||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
|
||||
#define UIP_CONF_IP_FORWARD 0
|
||||
#define UIP_CONF_BUFFER_SIZE 140
|
||||
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_HC1 1
|
||||
#define SICSLOWPAN_CONF_COMPRESSION_HC01 2
|
||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||
#ifndef SICSLOWPAN_CONF_FRAG
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
#define SICSLOWPAN_CONF_MAXAGE 8
|
||||
#endif /* SICSLOWPAN_CONF_FRAG */
|
||||
#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1
|
||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
||||
#else /* WITH_UIP6 */
|
||||
#define UIP_CONF_IP_FORWARD 1
|
||||
#define UIP_CONF_BUFFER_SIZE 108
|
||||
#endif /* WITH_UIP6 */
|
||||
|
||||
#define UIP_CONF_ICMP_DEST_UNREACH 1
|
||||
|
||||
#define UIP_CONF_DHCP_LIGHT
|
||||
#define UIP_CONF_LLH_LEN 0
|
||||
#define UIP_CONF_RECEIVE_WINDOW 48
|
||||
#define UIP_CONF_TCP_MSS 48
|
||||
#define UIP_CONF_MAX_CONNECTIONS 4
|
||||
#define UIP_CONF_MAX_LISTENPORTS 8
|
||||
#define UIP_CONF_UDP_CONNS 12
|
||||
#define UIP_CONF_FWCACHE_SIZE 30
|
||||
#define UIP_CONF_BROADCAST 1
|
||||
#define UIP_ARCH_IPCHKSUM 1
|
||||
#define UIP_CONF_UDP 1
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
#define UIP_CONF_PINGADDRCONF 0
|
||||
#define UIP_CONF_LOGGING 0
|
||||
|
||||
#define UIP_CONF_TCP_SPLIT 0
|
||||
|
||||
|
||||
#ifdef PROJECT_CONF_H
|
||||
#include PROJECT_CONF_H
|
||||
#endif /* PROJECT_CONF_H */
|
||||
|
||||
|
||||
|
||||
#endif /* CONTIKI_CONF_H */
|
42
platform/z1sp/contiki-z1sp-platform.c
Normal file
42
platform/z1sp/contiki-z1sp-platform.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2011, Zolertia(TM) is a trademark of Advancare,SL
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Author: Enric M. Calvo <ecalvo@zolertia.com> based on previous work by
|
||||
* 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"
|
||||
|
||||
void
|
||||
init_platform(void)
|
||||
{
|
||||
process_start(&sensors_process, NULL);
|
||||
}
|
67
platform/z1sp/dev/potentiometer-sensor.c
Normal file
67
platform/z1sp/dev/potentiometer-sensor.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Zolertia(TM) is a trademark by Advancare,SL
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Enric M. Calvo (based on work by A. Dunkels, J. Eriksson, N. Finne)
|
||||
* Created : 2011-02-22
|
||||
* $Revision: 1.0 $
|
||||
*/
|
||||
|
||||
#include "dev/potentiometer-sensor.h"
|
||||
#include "dev/sky-sensors.h"
|
||||
#include <io.h>
|
||||
|
||||
/* Configure ADC12_2 to sample channel 11 (voltage) and use */
|
||||
/* the Vref+ as reference (SREF_1) since it is a stable reference */
|
||||
#define INPUT_CHANNEL (1 << INCH_4)
|
||||
#define INPUT_REFERENCE SREF_0
|
||||
#define POTENTIOMETER_MEM ADC12MEM4
|
||||
|
||||
const struct sensors_sensor battery_sensor;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
value(int type)
|
||||
{
|
||||
return POTENTIOMETER_MEM;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
configure(int type, int c)
|
||||
{
|
||||
return sky_sensors_configure(INPUT_CHANNEL, INPUT_REFERENCE, type, c);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
status(int type)
|
||||
{
|
||||
return sky_sensors_status(INPUT_CHANNEL, type);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(potentiometer_sensor, POTENTIOMETER_SENSOR, value, configure, status);
|
46
platform/z1sp/dev/potentiometer-sensor.h
Normal file
46
platform/z1sp/dev/potentiometer-sensor.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Zolertia(TM) is a trademark by Advancare,SL
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Enric M. Calvo (based on work by A. Dunkels, J. Eriksson, N. Finne)
|
||||
* Created : 2011-02-22
|
||||
* $Revision: 1.0 $
|
||||
*/
|
||||
|
||||
#ifndef __POTENTIOMETER_SENSOR_H__
|
||||
#define __POTENTIOMETER_SENSOR_H__
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
extern const struct sensors_sensor potentiometer_sensor;
|
||||
|
||||
#define POTENTIOMETER_SENSOR "Potentiometer"
|
||||
|
||||
#endif /* __POTENTIOMETER_SENSOR_H__ */
|
212
platform/z1sp/platform-conf.h
Normal file
212
platform/z1sp/platform-conf.h
Normal file
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* $Id: platform-conf.h,v 1.1 2010/08/24 16:26:38 joxe Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A brief description of what this file is
|
||||
* \author
|
||||
* Joakim Eriksson <joakime@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __PLATFORM_CONF_H__
|
||||
#define __PLATFORM_CONF_H__
|
||||
|
||||
/*
|
||||
* Definitions below are dictated by the hardware and not really
|
||||
* changeable!
|
||||
*/
|
||||
#define ZOLERTIA_Z1 0 /* Enric */
|
||||
#define ZOLERTIA_Z1SP 1 /* Enric */
|
||||
|
||||
/* CPU target speed in Hz */
|
||||
/* CPU target speed in Hz */
|
||||
#define F_CPU 8000000uL // 8MHz by default
|
||||
//Enric #define F_CPU 3900000uL /*2457600uL*/
|
||||
|
||||
/* Our clock resolution, this is the same as Unix HZ. */
|
||||
#define CLOCK_CONF_SECOND 128UL
|
||||
|
||||
#define BAUD2UBR(baud) ((F_CPU/baud))
|
||||
|
||||
#define CCIF
|
||||
#define CLIF
|
||||
|
||||
#define CC_CONF_INLINE inline
|
||||
|
||||
#define HAVE_STDINT_H
|
||||
#define MSP430_MEMCPY_WORKAROUND 1
|
||||
#include "msp430def.h"
|
||||
|
||||
|
||||
/* Types for clocks and uip_stats */
|
||||
typedef unsigned short uip_stats_t;
|
||||
typedef unsigned long clock_time_t;
|
||||
typedef unsigned long off_t;
|
||||
|
||||
/* the low-level radio driver */
|
||||
#define NETSTACK_CONF_RADIO cc2420_driver
|
||||
|
||||
/*
|
||||
* Definitions below are dictated by the hardware and not really
|
||||
* changeable!
|
||||
*/
|
||||
|
||||
/* LED ports */
|
||||
#define LEDS_PxDIR P4DIR
|
||||
#define LEDS_PxOUT P4OUT
|
||||
#define LEDS_CONF_RED 0x04
|
||||
#define LEDS_CONF_GREEN 0x01
|
||||
#define LEDS_CONF_YELLOW 0x80
|
||||
|
||||
/* DCO speed resynchronization for more robust UART, etc. */
|
||||
#define DCOSYNCH_CONF_ENABLED 0
|
||||
#define DCOSYNCH_CONF_PERIOD 30
|
||||
|
||||
#define ROM_ERASE_UNIT_SIZE 512
|
||||
#define XMEM_ERASE_UNIT_SIZE (64*1024L)
|
||||
|
||||
|
||||
#define CFS_CONF_OFFSET_TYPE long
|
||||
|
||||
/* Use the first 64k of external flash for node configuration */
|
||||
#define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE)
|
||||
|
||||
/* Use the second 64k of external flash for codeprop. */
|
||||
#define EEPROMFS_ADDR_CODEPROP (1 * XMEM_ERASE_UNIT_SIZE)
|
||||
|
||||
#define CFS_XMEM_CONF_OFFSET (2 * XMEM_ERASE_UNIT_SIZE)
|
||||
#define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE)
|
||||
|
||||
#define CFS_RAM_CONF_SIZE 4096
|
||||
|
||||
/*
|
||||
* SPI bus configuration for the TMote Sky.
|
||||
*/
|
||||
|
||||
/* SPI input/output registers. */
|
||||
#define SPI_TXBUF UCB0TXBUF
|
||||
#define SPI_RXBUF UCB0RXBUF
|
||||
|
||||
/* USART0 Tx ready? */
|
||||
#define SPI_WAITFOREOTx() while ((UCB0STAT & UCBUSY) != 0)
|
||||
/* USART0 Rx ready? */
|
||||
#define SPI_WAITFOREORx() while ((IFG2 & UCB0RXIFG) == 0)
|
||||
/* USART0 Tx buffer ready? */
|
||||
#define SPI_WAITFORTxREADY() while ((IFG2 & UCB0TXIFG) == 0)
|
||||
|
||||
#define MOSI 1 /* P3.1 - Output: SPI Master out - slave in (MOSI) */
|
||||
#define MISO 2 /* P3.2 - Input: SPI Master in - slave out (MISO) */
|
||||
#define SCK 3 /* P3.3 - Output: SPI Serial Clock (SCLK) */
|
||||
|
||||
/*
|
||||
* SPI bus - M25P80 external flash configuration.
|
||||
*/
|
||||
//#define FLASH_PWR 3 /* P4.3 Output */ ALWAYS POWERED ON Z1
|
||||
#define FLASH_CS 4 /* P4.4 Output */
|
||||
#define FLASH_HOLD 7 /* P5.7 Output */
|
||||
|
||||
/* Enable/disable flash access to the SPI bus (active low). */
|
||||
|
||||
#define SPI_FLASH_ENABLE() ( P4OUT &= ~BV(FLASH_CS) )
|
||||
#define SPI_FLASH_DISABLE() ( P4OUT |= BV(FLASH_CS) )
|
||||
|
||||
#define SPI_FLASH_HOLD() ( P5OUT &= ~BV(FLASH_HOLD) )
|
||||
#define SPI_FLASH_UNHOLD() ( P5OUT |= BV(FLASH_HOLD) )
|
||||
|
||||
|
||||
/*
|
||||
* SPI bus - CC2420 pin configuration.
|
||||
*/
|
||||
|
||||
#define CC2420_CONF_SYMBOL_LOOP_COUNT 1302 /* 326us msp430X @ 8MHz */
|
||||
|
||||
/* P1.2 - Input: FIFOP from CC2420 */
|
||||
#define CC2420_FIFOP_PORT(type) P1##type
|
||||
#define CC2420_FIFOP_PIN 2
|
||||
/* P1.3 - Input: FIFO from CC2420 */
|
||||
#define CC2420_FIFO_PORT(type) P1##type
|
||||
#define CC2420_FIFO_PIN 3
|
||||
/* P1.4 - Input: CCA from CC2420 */
|
||||
#define CC2420_CCA_PORT(type) P1##type
|
||||
#define CC2420_CCA_PIN 4
|
||||
/* P4.1 - Input: SFD from CC2420 */
|
||||
#define CC2420_SFD_PORT(type) P4##type
|
||||
#define CC2420_SFD_PIN 1
|
||||
/* P3.0 - Output: SPI Chip Select (CS_N) */
|
||||
#define CC2420_CSN_PORT(type) P3##type
|
||||
#define CC2420_CSN_PIN 0
|
||||
/* P4.5 - Output: VREG_EN to CC2420 */
|
||||
#define CC2420_VREG_PORT(type) P4##type
|
||||
#define CC2420_VREG_PIN 5
|
||||
/* P4.6 - Output: RESET_N to CC2420 */
|
||||
#define CC2420_RESET_PORT(type) P4##type
|
||||
#define CC2420_RESET_PIN 6
|
||||
|
||||
|
||||
#define CC2420_IRQ_VECTOR PORT1_VECTOR
|
||||
|
||||
/* Pin status. */
|
||||
#define CC2420_FIFOP_IS_1 (!!(CC2420_FIFOP_PORT(IN) & BV(CC2420_FIFOP_PIN)))
|
||||
#define CC2420_FIFO_IS_1 (!!(CC2420_FIFO_PORT(IN) & BV(CC2420_FIFO_PIN)))
|
||||
#define CC2420_CCA_IS_1 (!!(CC2420_CCA_PORT(IN) & BV(CC2420_CCA_PIN)))
|
||||
#define CC2420_SFD_IS_1 (!!(CC2420_SFD_PORT(IN) & BV(CC2420_SFD_PIN)))
|
||||
|
||||
/* The CC2420 reset pin. */
|
||||
#define SET_RESET_INACTIVE() (CC2420_RESET_PORT(OUT) |= BV(CC2420_RESET_PIN))
|
||||
#define SET_RESET_ACTIVE() (CC2420_RESET_PORT(OUT) &= ~BV(CC2420_RESET_PIN))
|
||||
|
||||
/* CC2420 voltage regulator enable pin. */
|
||||
#define SET_VREG_ACTIVE() (CC2420_VREG_PORT(OUT) |= BV(CC2420_VREG_PIN))
|
||||
#define SET_VREG_INACTIVE() (CC2420_VREG_PORT(OUT) &= ~BV(CC2420_VREG_PIN))
|
||||
|
||||
/* CC2420 rising edge trigger for external interrupt 0 (FIFOP). */
|
||||
#define CC2420_FIFOP_INT_INIT() do { \
|
||||
CC2420_FIFOP_PORT(IES) &= ~BV(CC2420_FIFOP_PIN); \
|
||||
CC2420_CLEAR_FIFOP_INT(); \
|
||||
} while(0)
|
||||
|
||||
/* FIFOP on external interrupt 0. */
|
||||
#define CC2420_ENABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) |= BV(CC2420_FIFOP_PIN);} while(0)
|
||||
#define CC2420_DISABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) &= ~BV(CC2420_FIFOP_PIN);} while(0)
|
||||
#define CC2420_CLEAR_FIFOP_INT() do {CC2420_FIFOP_PORT(IFG) &= ~BV(CC2420_FIFOP_PIN);} while(0)
|
||||
|
||||
/*
|
||||
* Enables/disables CC2420 access to the SPI bus (not the bus).
|
||||
* (Chip Select)
|
||||
*/
|
||||
|
||||
/* ENABLE CSn (active low) */
|
||||
#define CC2420_SPI_ENABLE() (CC2420_CSN_PORT(OUT) &= ~BV(CC2420_CSN_PIN))
|
||||
/* DISABLE CSn (active low) */
|
||||
#define CC2420_SPI_DISABLE() (CC2420_CSN_PORT(OUT) |= BV(CC2420_CSN_PIN))
|
||||
#define CC2420_SPI_IS_ENABLED() ((CC2420_CSN_PORT(OUT) & BV(CC2420_CSN_PIN)) != BV(CC2420_CSN_PIN))
|
||||
|
||||
#endif /* __PLATFORM_CONF_H__ */
|
Loading…
Reference in a new issue