diff --git a/cpu/avr/radio/rf230/hal.h b/cpu/avr/radio/rf230/hal.h
index b15c3b226..0f4ba42ea 100644
--- a/cpu/avr/radio/rf230/hal.h
+++ b/cpu/avr/radio/rf230/hal.h
@@ -75,10 +75,12 @@
// RAVENUSB_C : used for USB key or Raven card
// RCB_B : RZ200 kit from Atmel based on 1281V
// ZIGBIT : Zigbit module from Meshnetics
+// IRIS : IRIS Mote from MEMSIC
#define RAVEN_D 4
#define RAVENUSB_C 1
#define RCB_B 2
#define ZIGBIT 3
+#define IRIS 5
@@ -168,6 +170,26 @@
# define HAS_CW_MODE
# define HAS_SPARE_TIMER
+#elif HARWARE_REVISION == IRIS
+/* 1281 IRIS */
+# define SSPORT B
+# define SSPIN (0x00)
+# define SPIPORT B
+# define MOSIPIN (0x02)
+# define MISOPIN (0x03)
+# define SCKPIN (0x01)
+# define RSTPORT A
+# define RSTPIN (0x06)
+# define IRQPORT D
+# define IRQPIN (0x04)
+# define SLPTRPORT B
+# define SLPTRPIN (0x07)
+//# define TXCWPORT B
+//# define TXCWPIN (0x07)
+# define USART 1
+# define USARTVECT USART1_RX_vect
+//# define TICKTIMER 3
+//# define HAS_SPARE_TIMER // Not used
#else
#error "Platform undefined in hal.h"
diff --git a/cpu/avr/radio/rf230bb/hal.h b/cpu/avr/radio/rf230bb/hal.h
index 6611b4ce7..4df4a5e5d 100644
--- a/cpu/avr/radio/rf230bb/hal.h
+++ b/cpu/avr/radio/rf230bb/hal.h
@@ -74,11 +74,13 @@
// RCB_B : RZ200 kit from Atmel based on 1281V
// ZIGBIT : Zigbit module from Meshnetics
// ATMEGA128RFA1 : Bare chip with internal radio
+// IRIS : IRIS Mote from MEMSIC
#define RAVEN_D 4
#define RAVENUSB_C 1
#define RCB_B 2
#define ZIGBIT 3
#define ATMEGA128RFA1 4
+#define IRIS 5
@@ -214,6 +216,26 @@
# define HAS_SPARE_TIMER
+#elif HARWARE_REVISION == IRIS
+/* 1281 IRIS */
+# define SSPORT B
+# define SSPIN (0x00)
+# define SPIPORT B
+# define MOSIPIN (0x02)
+# define MISOPIN (0x03)
+# define SCKPIN (0x01)
+# define RSTPORT A
+# define RSTPIN (0x06)
+# define IRQPORT D
+# define IRQPIN (0x04)
+# define SLPTRPORT B
+# define SLPTRPIN (0x07)
+//# define TXCWPORT B
+//# define TXCWPIN (0x07)
+# define USART 1
+# define USARTVECT USART1_RX_vect
+//# define TICKTIMER 3
+//# define HAS_SPARE_TIMER // Not used
#else
#error "Platform undefined in hal.h"
diff --git a/examples/ipv6/rpl-border-router/Makefile b/examples/ipv6/rpl-border-router/Makefile
index 8ce443082..3fd4c82b4 100644
--- a/examples/ipv6/rpl-border-router/Makefile
+++ b/examples/ipv6/rpl-border-router/Makefile
@@ -5,24 +5,16 @@ CONTIKI=../../..
WITH_UIP6=1
UIP_CONF_IPV6=1
+#Override inclusion of internal webserver with make WITH_WEBSERVER=0
+WITH_WEBSERVER=1
+
+ifeq ($(WITH_WEBSERVER), 0)
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += slip-bridge.c
-
-#Simple built-in webserver is the default.
-#Override with make WITH_WEBSERVER=0 for no webserver.
-#WITH_WEBSERVER=webserver-name will use /apps/webserver-name if it can be
-#found in the /apps, /platform/$(TARGET)/apps/, or current directory (in that order).
-# WITH_WEBSERVER=webserver for /apps/webserver
-# WITH_WEBSERVER=raven-webserver for /platform/avr-raven/apps/raven-webserver/
-#make clean before changing webservers!
-WITH_WEBSERVER=1
-ifeq ($(WITH_WEBSERVER),1)
-CFLAGS += -DWEBSERVER=1
-PROJECT_SOURCEFILES += httpd-simple.c
+else
APPS += webserver
-else ifneq ($(WITH_WEBSERVER), 0)
-APPS += $(WITH_WEBSERVER)
-CFLAGS += -DWEBSERVER=2
+CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" -DWEBSERVER
+PROJECT_SOURCEFILES += slip-bridge.c httpd-simple.c
endif
include $(CONTIKI)/Makefile.include
diff --git a/examples/ipv6/rpl-border-router/border-router.c b/examples/ipv6/rpl-border-router/border-router.c
index b5e9a470e..a7a31f48e 100644
--- a/examples/ipv6/rpl-border-router/border-router.c
+++ b/examples/ipv6/rpl-border-router/border-router.c
@@ -69,17 +69,11 @@ static uip_ipaddr_t prefix;
static uint8_t prefix_set;
PROCESS(border_router_process, "Border router process");
-
-#if WEBSERVER==0
- /* No webserver */
AUTOSTART_PROCESSES(&border_router_process);
-#elif WEBSERVER>1
-/* Use an external webserver process */
-//PROCESS_NAME(webserver_nogui_process);
-AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
-#else
-AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
-/* Use simple webserver with only one page */
+
+#if WEBSERVER
+/*---------------------------------------------------------------------------*/
+/* Only one single web request at time */
static const char *TOP = "
ContikiRPL\n";
static const char *BOTTOM = "\n";
static char buf[128];
@@ -218,6 +212,10 @@ PROCESS_THREAD(border_router_process, ev, data)
PROCESS_PAUSE();
+#if WEBSERVER
+ process_start(&webserver_nogui_process, NULL);
+#endif
+
SENSORS_ACTIVATE(button_sensor);
PRINTF("RPL-Border router started\n");
diff --git a/platform/iris/Makefile.iris b/platform/iris/Makefile.iris
new file mode 100644
index 000000000..8d58e24d5
--- /dev/null
+++ b/platform/iris/Makefile.iris
@@ -0,0 +1,65 @@
+CONTIKI_TARGET_DIRS = . dev dev/sensors
+CONTIKI_CORE=contiki-iris
+CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
+
+SENSOR_BOARD_SOURCEFILES = mts300.c
+
+CONTIKI_TARGET_SOURCEFILES += adc.c rs232.c cfs-eeprom.c contiki-iris-main.c \
+ leds-arch.c init-net.c node-id.c \
+ clock.c spi.c rtimer-arch.c ds2401.c \
+ battery-sensor.c slip.c slip_uart0.c
+
+CONTIKI_TARGET_SOURCEFILES += $(SENSOR_BOARD_SOURCEFILES)
+
+CONTIKIAVR=$(CONTIKI)/cpu/avr
+CONTIKIBOARD=.
+
+# IRIS runs on Clock rate 8 MHz
+CONTIKI_PLAT_DEFS = -DF_CPU=8000000UL -DAUTO_CRC_PADDING=2 #-DUSART_BAUD_115200
+
+MCU=atmega1281
+AVRDUDE_OPTIONS=-V
+AVRDUDE_PROGRAMMER=mib510
+#AVRDUDE_PROGRAMMER=jtag2
+#AVRDUDE_PORT=usb
+AVRDUDE_PORT=$(PORT)
+
+include $(CONTIKIAVR)/Makefile.avr
+
+
+%.od: %.$(TARGET)
+ avr-objdump -zhD $< > $@
+
+
+ifndef WINDIR
+ ifdef OS
+ ifneq (,$(findstring Windows,$(OS)))
+ WINDIR := Windows
+ endif
+ endif
+endif
+
+ifeq ($(PRGBOARD), )
+ PRGBOARD = mib510
+endif
+
+ifeq ($(PORT), )
+ ifndef WINDIR
+ PORT = /dev/ttyUSB0
+ else
+ PORT = COM1
+ endif
+endif
+
+PRGBOARD_FILE = $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.$(PRGBOARD)
+HAVE_PRGBOARD_FILE = $(wildcard $(PRGBOARD_FILE))
+
+ifneq ($(strip $(HAVE_PRGBOARD_FILE)), )
+ include $(PRGBOARD_FILE)
+endif
+
+include $(CONTIKIAVR)/radio/Makefile.radio
+ifdef UIP_CONF_IPV6
+CFLAGS += -DWITH_UIP6=1
+endif
+
diff --git a/platform/iris/apps/Makefile b/platform/iris/apps/Makefile
new file mode 100644
index 000000000..082acb6c9
--- /dev/null
+++ b/platform/iris/apps/Makefile
@@ -0,0 +1,5 @@
+CONTIKI = ../../..
+
+all: battery-monitor
+
+include $(CONTIKI)/Makefile.include
diff --git a/platform/iris/apps/battery-monitor.c b/platform/iris/apps/battery-monitor.c
new file mode 100644
index 000000000..be4599458
--- /dev/null
+++ b/platform/iris/apps/battery-monitor.c
@@ -0,0 +1,34 @@
+#include "contiki.h"
+#include "dev/battery-sensor.h"
+#include "lib/sensors.h"
+#include /* For printf() */
+/*---------------------------------------------------------------------------*/
+PROCESS(battery_monitor_process, "Battery Voltage Monitor");
+AUTOSTART_PROCESSES(&battery_monitor_process);
+/*---------------------------------------------------------------------------*/
+PROCESS_THREAD(battery_monitor_process, ev, data)
+{
+ static struct etimer et;
+
+ PROCESS_BEGIN();
+
+ SENSORS_ACTIVATE(battery_sensor);
+
+ while(1) {
+
+ etimer_set(&et, CLOCK_SECOND * 2);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
+ /*
+ * Battery voltage calculation formula
+ *
+ * V(Battery Voltage) = v(Voltage Reference) * 1024 / ADC
+ *
+ * Where:
+ * v = 1.223
+ *
+ */
+ printf("ADC value : %d\n", battery_sensor.value(0));
+ }
+ PROCESS_END();
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/apps/mts310/Makefile b/platform/iris/apps/mts310/Makefile
new file mode 100644
index 000000000..744dd1613
--- /dev/null
+++ b/platform/iris/apps/mts310/Makefile
@@ -0,0 +1,5 @@
+CONTIKI = ../../../..
+
+all: accel-test light-test magnet-test mic-test
+
+include $(CONTIKI)/Makefile.include
diff --git a/platform/iris/apps/mts310/accel-test.c b/platform/iris/apps/mts310/accel-test.c
new file mode 100644
index 000000000..94de0c474
--- /dev/null
+++ b/platform/iris/apps/mts310/accel-test.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+#include
+#include "contiki.h"
+#include "dev/sensors/mts300.h"
+
+/*---------------------------------------------------------------------------*/
+PROCESS(test_accel_process, "Accel test");
+AUTOSTART_PROCESSES(&test_accel_process);
+/*---------------------------------------------------------------------------*/
+PROCESS_THREAD(test_accel_process, ev, data)
+{
+ static struct etimer et;
+
+ PROCESS_BEGIN();
+
+ while(1) {
+
+ printf("AccX : %d\n",get_accx());
+ printf("AccY : %d\n",get_accy());
+
+ etimer_set(&et, CLOCK_SECOND / 2);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
+ }
+
+ PROCESS_END();
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/apps/mts310/light-test.c b/platform/iris/apps/mts310/light-test.c
new file mode 100644
index 000000000..8c24489a0
--- /dev/null
+++ b/platform/iris/apps/mts310/light-test.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+#include "contiki.h"
+#include "dev/sensors/mts300.h"
+#include
+
+/*---------------------------------------------------------------------------*/
+PROCESS(test_light_process, "light test");
+AUTOSTART_PROCESSES(&test_light_process);
+/*---------------------------------------------------------------------------*/
+PROCESS_THREAD(test_light_process, ev, data)
+{
+ static struct etimer et;
+
+ PROCESS_BEGIN();
+
+ while(1) {
+
+ printf("Light : %d\n",get_light());
+ printf("Temp : %d\n",get_temp());
+
+ etimer_set(&et, CLOCK_SECOND / 2);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
+
+ }
+
+ PROCESS_END();
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/apps/mts310/magnet-test.c b/platform/iris/apps/mts310/magnet-test.c
new file mode 100644
index 000000000..2b22436b5
--- /dev/null
+++ b/platform/iris/apps/mts310/magnet-test.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+#include "contiki.h"
+#include "dev/sensors/mts300.h"
+#include
+
+/*---------------------------------------------------------------------------*/
+PROCESS(test_sounder_process, "Sounder test");
+AUTOSTART_PROCESSES(&test_sounder_process);
+/*---------------------------------------------------------------------------*/
+PROCESS_THREAD(test_sounder_process, ev, data)
+{
+ static struct etimer et;
+
+ PROCESS_BEGIN();
+
+ while(1) {
+
+ sounder_on();
+ etimer_set(&et, 1);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
+
+ sounder_off();
+ etimer_set(&et, 1);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
+ }
+
+ PROCESS_END();
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/apps/mts310/mic-test.c b/platform/iris/apps/mts310/mic-test.c
new file mode 100644
index 000000000..bb4ec62d9
--- /dev/null
+++ b/platform/iris/apps/mts310/mic-test.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+#include "contiki.h"
+#include "dev/sensors/mts300.h"
+#include
+
+/*---------------------------------------------------------------------------*/
+PROCESS(test_mic_process, "Mic test");
+AUTOSTART_PROCESSES(&test_mic_process);
+/*---------------------------------------------------------------------------*/
+PROCESS_THREAD(test_mic_process, ev, data)
+{
+ static struct etimer et;
+
+ PROCESS_BEGIN();
+
+ while(1) {
+
+ printf("Mic : %d\n",get_mic());
+ etimer_set(&et, CLOCK_SECOND / 8);
+ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
+;
+ }
+
+ PROCESS_END();
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/contiki-conf.h b/platform/iris/contiki-conf.h
new file mode 100644
index 000000000..51fadd71c
--- /dev/null
+++ b/platform/iris/contiki-conf.h
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+/**
+ * \file
+ * Configuration for MICAz platform.
+ *
+ * \author
+ * Kasun Hewage
+ */
+
+#ifndef __CONTIKI_CONF_H__
+#define __CONTIKI_CONF_H__
+
+#define HAVE_STDINT_H
+#include "avrdef.h"
+
+#include "platform-conf.h"
+
+#if WITH_UIP6
+
+/* Network setup for IPv6 */
+#define NETSTACK_CONF_NETWORK sicslowpan_driver
+#define NETSTACK_CONF_MAC csma_driver
+#define NETSTACK_CONF_RDC nullrdc_driver
+#define NETSTACK_CONF_FRAMER framer_802154
+
+#define RF230_CONF_AUTOACK 1
+#define MAC_CONF_CHANNEL_CHECK_RATE 8
+#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
+#define CXMAC_CONF_ANNOUNCEMENTS 0
+
+#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 cxmac_driver
+#define NETSTACK_CONF_FRAMER framer_802154
+
+#define RF230_CONF_AUTOACK 1
+#define MAC_CONF_CHANNEL_CHECK_RATE 8
+
+#define COLLECT_CONF_ANNOUNCEMENTS 1
+#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 1
+#define CXMAC_CONF_ANNOUNCEMENTS 0
+#define CXMAC_CONF_COMPOWER 1
+#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0
+#define CONTIKIMAC_CONF_COMPOWER 1
+
+#define COLLECT_NEIGHBOR_CONF_MAX_NEIGHBORS 32
+
+#endif /* WITH_UIP6 */
+
+#define PACKETBUF_CONF_ATTRS_INLINE 1
+
+#ifndef RF_CHANNEL
+#define RF_CHANNEL 26
+#endif /* RF_CHANNEL */
+
+#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0
+
+#define IEEE802154_CONF_PANID 0xABCD
+
+
+#define AODV_COMPLIANCE
+#define AODV_NUM_RT_ENTRIES 32
+
+#define WITH_ASCII 1
+
+#define PROCESS_CONF_NUMEVENTS 8
+#define PROCESS_CONF_STATS 1
+
+#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
+
+/* configure number of neighbors and routes */
+#define UIP_CONF_DS6_NBR_NBU 5
+#define UIP_CONF_DS6_ROUTE_NBU 5
+
+#define RPL_CONF_MAX_PARENTS 4
+#define NEIGHBOR_CONF_MAX_NEIGHBORS 8
+
+#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 240
+
+#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 128
+#endif /* WITH_UIP6 */
+
+#define UIP_CONF_ICMP_DEST_UNREACH 1
+
+#if !WITH_UIP && !WITH_UIP6
+#define QUEUEBUF_CONF_NUM 8
+#else
+#define QUEUEBUF_CONF_NUM 4
+#endif
+
+#define TIMESYNCH_CONF_ENABLED 1
+#define RF230_CONF_TIMESTAMPS 0
+#define RF230_CONF_SYMBOL_LOOP_COUNT 500
+
+#define WITH_NULLMAC 0
+
+#define CCIF
+#define CLIF
+
+/* The process names are not used to save RAM */
+#define PROCESS_CONF_NO_PROCESS_NAMES 0
+
+#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 15
+#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
+
+
+typedef unsigned short clock_time_t;
+typedef unsigned short uip_stats_t;
+typedef unsigned long off_t;
+
+void clock_delay(unsigned int us2);
+void clock_wait(int ms10);
+void clock_set_seconds(unsigned long s);
+unsigned long clock_seconds(void);
+
+#ifdef PROJECT_CONF_H
+#include PROJECT_CONF_H
+#endif /* PROJECT_CONF_H */
+
+#endif /* __CONTIKI_CONF_H__ */
diff --git a/platform/iris/contiki-iris-main.c b/platform/iris/contiki-iris-main.c
new file mode 100644
index 000000000..f72971de4
--- /dev/null
+++ b/platform/iris/contiki-iris-main.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+
+/**
+ * \file
+ * Main file of the MICAz port.
+ *
+ * \author
+ * Kasun Hewage
+ */
+
+#include
+#include
+
+#include "contiki.h"
+#include "contiki-lib.h"
+#include "net/rime.h"
+#include "dev/leds.h"
+#include "dev/rs232.h"
+#include "dev/watchdog.h"
+#include "dev/slip.h"
+
+#include "init-net.h"
+#include "dev/ds2401.h"
+#include "node-id.h"
+
+/*---------------------------------------------------------------------------*/
+void
+init_usart(void)
+{
+ /* First rs232 port for debugging */
+ rs232_init(RS232_PORT_0, USART_BAUD_115200,
+ USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
+
+#if WITH_UIP || WITH_UIP6
+ slip_arch_init(USART_BAUD_115200);
+#else
+ rs232_redirect_stdout(RS232_PORT_0);
+#endif /* WITH_UIP */
+
+}
+/*---------------------------------------------------------------------------*/
+int
+main(void)
+{
+
+ leds_init();
+
+ leds_on(LEDS_RED);
+
+ /* Initialize USART */
+ init_usart();
+
+ /* Clock */
+ clock_init();
+
+ leds_on(LEDS_GREEN);
+
+ ds2401_init();
+
+ node_id_restore();
+
+ random_init(ds2401_id[0] + node_id);
+
+ rtimer_init();
+
+ /* Process subsystem */
+ process_init();
+
+ process_start(&etimer_process, NULL);
+
+ ctimer_init();
+
+ leds_on(LEDS_YELLOW);
+
+ init_net();
+
+ printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u\n"), node_id);
+
+ leds_off(LEDS_ALL);
+
+ /* Autostart processes */
+ autostart_start(autostart_processes);
+
+ mmem_init();
+ /* Main scheduler loop */
+ do {
+
+ process_run();
+
+ }while(1);
+
+ return 0;
+}
diff --git a/platform/iris/dev/adc.c b/platform/iris/dev/adc.c
new file mode 100644
index 000000000..62986f795
--- /dev/null
+++ b/platform/iris/dev/adc.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2010, University of Colombo School of Computing
+ * 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.
+ *
+ */
+
+#include
+#include "dev/adc.h"
+
+/*---------------------------------------------------------------------------*/
+void
+adc_init()
+{
+ ADMUX = 0;
+ /* AVCC with external capacitor at AREF pin. */
+ ADMUX |= _BV(REFS0);
+ /* Disable ADC interrupts. */
+ ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
+ /* Set ADC prescaler to 64 and clear interrupt flag. */
+ ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
+
+}
+/*---------------------------------------------------------------------------*/
+/* Poll based approach. The interrupt based adc is currently not used.
+ The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
+ other two bits are in ADCH. See Atmega128 datasheet page 228. */
+uint16_t
+get_adc(int channel)
+{
+ uint16_t reading;
+
+ ADMUX |= (channel & 0x1F);
+
+ /* Disable ADC interrupts. */
+ ADCSRA &= ~_BV(ADIE);
+ /* Clear previous interrupts. */
+ ADCSRA |= _BV(ADIF);
+ /* Enable ADC and start conversion. */
+ ADCSRA |= _BV(ADEN) | _BV(ADSC);
+ /* Wait until conversion is completed. */
+ while ( ADCSRA & _BV(ADSC) );
+ /* Get first 8 bits. */
+ reading = ADCL;
+ /* Get last two bits. */
+ reading |= (ADCH & 3) << 8;
+ /* Disable ADC. */
+ ADCSRA &= ~_BV(ADEN);
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/dev/adc.h b/platform/iris/dev/adc.h
new file mode 100644
index 000000000..473290b86
--- /dev/null
+++ b/platform/iris/dev/adc.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, University of Colombo School of Computing
+ * 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.
+ *
+ */
+
+#ifndef __ADC_H__
+#define __ADC_H__
+
+void adc_init();
+
+uint16_t get_adc(int channel);
+
+#endif /* __ADC_H__ */
diff --git a/platform/iris/dev/ds2401.c b/platform/iris/dev/ds2401.c
new file mode 100644
index 000000000..578479891
--- /dev/null
+++ b/platform/iris/dev/ds2401.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ */
+
+/*
+ * Device driver for the Dallas Semiconductor DS2401 chip. Heavily
+ * based on the application note 126 "1-Wire Communications Through
+ * Software".
+ *
+ * http://www.maxim-ic.com/appnotes.cfm/appnote_number/126
+ */
+
+/*
+ * For now we stuff in Crossbow Technology, Inc's unique OUI.
+ * 00:1A:4C Crossbow Technology, Inc
+ *
+ * The EUI-64 is a concatenation of the 24-bit OUI value assigned by
+ * the IEEE Registration Authority and a 40-bit extension identifier
+ * assigned by the organization with that OUI assignment.
+ */
+
+#include
+#include
+#include "contiki.h"
+
+#include "ds2401.h"
+
+unsigned char ds2401_id[8];
+
+/* 1-wire is at PortA.4 */
+#define SERIAL_ID_PIN_READ PINA
+#define SERIAL_ID_PIN_MASK _BV(4)
+#define SERIAL_ID_PxOUT PORTA
+#define SERIAL_ID_PxDIR DDRA
+
+#define SET_PIN_INPUT() (SERIAL_ID_PxDIR &= ~SERIAL_ID_PIN_MASK)
+#define SET_PIN_OUTPUT() (SERIAL_ID_PxDIR |= SERIAL_ID_PIN_MASK)
+
+#define OUTP_0() (SERIAL_ID_PxOUT &= ~SERIAL_ID_PIN_MASK)
+#define OUTP_1() (SERIAL_ID_PxOUT |= SERIAL_ID_PIN_MASK)
+
+#define PIN_INIT() do{ \
+ SET_PIN_INPUT(); \
+ OUTP_0(); \
+ } while(0)
+
+
+/* Drive the one wire interface low */
+#define OW_DRIVE() do { \
+ SET_PIN_OUTPUT(); \
+ OUTP_0(); \
+ } while (0)
+
+/* Release the one wire by turning on the internal pull-up. */
+#define OW_RELEASE() do { \
+ SET_PIN_INPUT(); \
+ OUTP_1(); \
+ } while (0)
+
+/* Read one bit. */
+#define INP() (SERIAL_ID_PIN_READ & SERIAL_ID_PIN_MASK)
+
+/*
+ * Delay times in us.
+ */
+#define tA 6 /* min-5, recommended-6, max-15 */
+#define tB 64 /* min-59, recommended-64, max-N/A */
+#define tC 60 /* min-60, recommended-60, max-120 */
+#define tD 10 /* min-5.3, recommended-10, max-N/A */
+#define tE 9 /* min-0.3, recommended-9, max-9.3 */
+#define tF 55 /* min-50, recommended-55, max-N/A */
+#define tG 0 /* min-0, recommended-0, max-0 */
+#define tH 480 /* min-480, recommended-480, max-640 */
+#define tI 70 /* min-60.3, recommended-70, max-75.3 */
+#define tJ 410 /* min-410, recommended-410, max-N/A */
+/*---------------------------------------------------------------------------*/
+/*
+ * The delay caused by calling the delay_loop is given by the following
+ * formula.
+ * delay(us) = (4n + 1)/XTAL
+ * where n is the number of iterations and XTAL is the clock frequency(in MHz).
+ * TODO: Moving the delay_loop to dev/clock.c
+ */
+static void
+delay_loop(uint16_t __count)
+{
+ asm volatile ("1: sbiw %0,1" "\n\t"
+ "brne 1b"
+ : "=w" (__count)
+ : "0" (__count)
+ );
+}
+/*---------------------------------------------------------------------------*/
+/*
+ * This macro relies on the compiler doing the arithmetic during compile time
+ * for the needed iterations.!!
+ * In MICAz, XTAL = 7.3728 MHz
+ */
+#define udelay(u) delay_loop(((7.3728F * u)-1)/4)
+/*---------------------------------------------------------------------------*/
+static uint8_t
+reset(void)
+{
+ uint8_t result;
+ OW_DRIVE();
+ udelay(500); /* 480 < tH < 640 */
+ OW_RELEASE(); /* Releases the bus */
+ udelay(tI);
+ result = INP();
+ udelay(tJ);
+ return result;
+}
+/*---------------------------------------------------------------------------*/
+static void
+write_byte(uint8_t byte)
+{
+ uint8_t i = 7;
+ do {
+ if (byte & 0x01) {
+ OW_DRIVE();
+ udelay(tA);
+ OW_RELEASE(); /* Releases the bus */
+ udelay(tB);
+ } else {
+ OW_DRIVE();
+ udelay(tC);
+ OW_RELEASE(); /* Releases the bus */
+ udelay(tD);
+ }
+ if (i == 0)
+ return;
+ i--;
+ byte >>= 1;
+ } while (1);
+}
+/*---------------------------------------------------------------------------*/
+static unsigned
+read_byte(void)
+{
+ unsigned result = 0;
+ int i = 7;
+ do {
+ OW_DRIVE();
+ udelay(tA);
+ OW_RELEASE(); /* Releases the bus */
+ udelay(tE);
+ if (INP())
+ result |= 0x80; /* LSbit first */
+ udelay(tF);
+ if (i == 0)
+ return result;
+ i--;
+ result >>= 1;
+ } while (1);
+}
+/*---------------------------------------------------------------------------*/
+/* Polynomial ^8 + ^5 + ^4 + 1 */
+static unsigned
+crc8_add(unsigned acc, unsigned byte)
+{
+ int i;
+ acc ^= byte;
+ for (i = 0; i < 8; i++)
+ if (acc & 1)
+ acc = (acc >> 1) ^ 0x8c;
+ else
+ acc >>= 1;
+
+ return acc;
+}
+/*---------------------------------------------------------------------------*/
+int
+ds2401_init()
+{
+ int i;
+ uint8_t volatile sreg;
+ unsigned family, crc, acc;
+
+ PIN_INIT();
+
+ sreg = SREG; /* Save status register before disabling interrupts. */
+ cli(); /* Disable interrupts. */
+
+ if (reset() == 0) {
+ write_byte(0x33); /* Read ROM command. */
+ family = read_byte();
+ for (i = 7; i >= 2; i--) {
+ ds2401_id[i] = read_byte();
+ }
+ crc = read_byte();
+
+ SREG = sreg; /* Enable interrupts. */
+
+ if(family != 0x01) {
+ goto fail;
+ }
+ acc = crc8_add(0x0, family);
+ for (i = 7; i >= 2; i--) {
+ acc = crc8_add(acc, ds2401_id[i]);
+ }
+ if (acc == crc) {
+ /* 00:1A:4C OUI for Crossbow Technology, Inc. */
+ ds2401_id[0] = 0x00;
+ ds2401_id[1] = 0x1A;
+ ds2401_id[2] = 0x4C;
+ return 1; /* Success! */
+ }
+ } else {
+ SREG = sreg; /* Enable interrupts. */
+ }
+
+fail:
+ memset(ds2401_id, 0x0, sizeof(ds2401_id));
+ return 0; /* Fail! */
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/dev/ds2401.h b/platform/iris/dev/ds2401.h
new file mode 100644
index 000000000..bdabb41b1
--- /dev/null
+++ b/platform/iris/dev/ds2401.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ */
+
+#ifndef DS2401_H
+#define DS2401_H
+
+extern unsigned char ds2401_id[8];
+extern int ds2401_init();
+
+#endif /* DS2401_H */
diff --git a/platform/iris/dev/leds-arch.c b/platform/iris/dev/leds-arch.c
new file mode 100644
index 000000000..a23366f02
--- /dev/null
+++ b/platform/iris/dev/leds-arch.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+/**
+ * \file
+ * LED architecture of the MICAz port.
+ * \author
+ * Kasun Hewage
+ */
+
+#include "contiki-conf.h"
+#include "dev/leds.h"
+#include
+
+
+/*---------------------------------------------------------------------------*/
+void leds_arch_init(void)
+{
+ LEDS_PxDIR |= (LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW);
+ LEDS_PxOUT |= (LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW);
+}
+/*---------------------------------------------------------------------------*/
+unsigned char leds_arch_get(void)
+{
+ return ((LEDS_PxOUT & LEDS_CONF_RED) ? 0 : LEDS_RED)
+ | ((LEDS_PxOUT & LEDS_CONF_GREEN) ? 0 : LEDS_GREEN)
+ | ((LEDS_PxOUT & LEDS_CONF_YELLOW) ? 0 : LEDS_YELLOW);
+}
+/*---------------------------------------------------------------------------*/
+void leds_arch_set(unsigned char leds)
+{
+ LEDS_PxOUT = (LEDS_PxOUT & ~(LEDS_CONF_RED|LEDS_CONF_GREEN|LEDS_CONF_YELLOW))
+ | ((leds & LEDS_RED) ? 0 : LEDS_CONF_RED)
+ | ((leds & LEDS_GREEN) ? 0 : LEDS_CONF_GREEN)
+ | ((leds & LEDS_YELLOW) ? 0 : LEDS_CONF_YELLOW);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/micaz/dev/clock.c b/platform/iris/dev/sensors/battery-sensor.c
similarity index 50%
rename from platform/micaz/dev/clock.c
rename to platform/iris/dev/sensors/battery-sensor.c
index d69b7a83d..bd0d4e40a 100644
--- a/platform/micaz/dev/clock.c
+++ b/platform/iris/dev/sensors/battery-sensor.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, University of Colombo School of Computing
+ * Copyright (c) 2010, University of Colombo School of Computing.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,134 +27,77 @@
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
- *
- * @(#)$$
*/
-#include "sys/clock.h"
-#include "sys/etimer.h"
+/**
+ * \file
+ * Battery sensor driver.
+ * \author
+ * Kasun Hewage
+ */
#include
-#include
+#include "dev/battery-sensor.h"
+#include "dev/adc.h"
-static volatile clock_time_t count, scount;
-static volatile unsigned long seconds;
+#define BAT_MONITOR_PORT PORTF
+#define BAT_MONITOR_PIN_MASK _BV(1)
+#define BAT_MONITOR_PORT_DDR DDRF
+#define BAT_MONITOR_ADC_CHANNEL 30
+
+const struct sensors_sensor battery_sensor;
+static uint8_t active;
/*---------------------------------------------------------------------------*/
-ISR(TIMER0_COMP_vect)
+static void
+activate(void)
{
- count++;
- if(++scount == CLOCK_SECOND) {
- scount = 0;
- seconds++;
+ /* This assumes that some other sensor system already did setup the ADC */
+ adc_init();
+
+ /* Enable battery sensor. */
+ BAT_MONITOR_PORT |= BAT_MONITOR_PIN_MASK;
+ BAT_MONITOR_PORT_DDR |= BAT_MONITOR_PIN_MASK;
+
+ active = 1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+deactivate(void)
+{
+ active = 0;
+}
+/*---------------------------------------------------------------------------*/
+static int
+value(int type)
+{
+ return get_adc(BAT_MONITOR_ADC_CHANNEL);
+}
+/*---------------------------------------------------------------------------*/
+static int
+configure(int type, int c)
+{
+ switch(type) {
+ case SENSORS_ACTIVE:
+ if (c) {
+ activate();
+ } else {
+ deactivate();
+ }
}
- if(etimer_pending()) {
- etimer_request_poll();
+ return 0;
+}
+/*---------------------------------------------------------------------------*/
+static int
+status(int type)
+{
+ switch (type) {
+ case SENSORS_ACTIVE:
+ case SENSORS_READY:
+ return active;
}
-}
-
-/*---------------------------------------------------------------------------*/
-void
-clock_init(void)
-{
- /* Disable interrupts*/
- cli();
-
- /* Disable compare match interrupts and overflow interrupts. */
- TIMSK &= ~( _BV(TOIE0) | _BV(OCIE0) );
-
- /**
- * set Timer/Counter0 to be asynchronous
- * from the CPU clock with a second external
- * clock(32,768kHz) driving it.
- */
- ASSR |= _BV(AS0);
-
- /*
- * Set timer control register:
- * - prescale: 32 (CS00 and CS01)
- * - counter reset via comparison register (WGM01)
- */
- TCCR0 = _BV(CS00) | _BV(CS01) | _BV(WGM01);
-
- /* Set counter to zero */
- TCNT0 = 0;
-
- /*
- * 128 clock ticks per second.
- * 32,768 = 32 * 8 * 128
- */
- OCR0 = 8;
-
- /* Clear interrupt flag register */
- TIFR = 0x00;
-
- /**
- * Wait for TCN0UB, OCR0UB, and TCR0UB.
- *
- */
- while(ASSR & 0x07);
-
- /* Raise interrupt when value in OCR0 is reached. */
- TIMSK |= _BV(OCIE0);
-
- count = 0;
-
- /* enable all interrupts*/
- sei();
-
-}
-/*---------------------------------------------------------------------------*/
-clock_time_t
-clock_time(void)
-{
- clock_time_t tmp;
- do {
- tmp = count;
- } while(tmp != count);
- return tmp;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Delay the CPU for a multiple of TODO
- */
-void
-clock_delay(unsigned int i)
-{
- for (; i > 0; i--) { /* Needs fixing XXX */
- unsigned j;
- for (j = 50; j > 0; j--)
- asm volatile("nop");
- }
-}
-
-/*---------------------------------------------------------------------------*/
-/**
- * Wait for a multiple of 1 / 128 sec = 7.8125 ms.
- *
- */
-void
-clock_wait(int i)
-{
- clock_time_t start;
-
- start = clock_time();
- while(clock_time() - start < (clock_time_t)i);
-}
-/*---------------------------------------------------------------------------*/
-void
-clock_set_seconds(unsigned long sec)
-{
- // TODO
-}
-/*---------------------------------------------------------------------------*/
-unsigned long
-clock_seconds(void)
-{
- unsigned long tmp;
- do {
- tmp = seconds;
- } while(tmp != seconds);
- return tmp;
+ return 0;
}
/*---------------------------------------------------------------------------*/
+SENSORS_SENSOR(battery_sensor, BATTERY_SENSOR,
+ value, configure, status);
diff --git a/platform/iris/dev/sensors/mts300.c b/platform/iris/dev/sensors/mts300.c
new file mode 100644
index 000000000..4104e46f7
--- /dev/null
+++ b/platform/iris/dev/sensors/mts300.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+/**
+ * \file
+ * Device drivers implementation for MTS300 sensor board.
+ * \author
+ * Kasun Hewage
+ */
+
+#include "mts300.h"
+/*---------------------------------------------------------------------------*/
+void
+sounder_on()
+{
SOUNDER_DDR |= SOUNDER_MASK;
+ SOUNDER_PORT &= ~SOUNDER_MASK;
+ SOUNDER_PORT |= SOUNDER_MASK;
+}
+/*---------------------------------------------------------------------------*/
+void
+sounder_off()
+{
+ SOUNDER_PORT &= ~(SOUNDER_MASK);
+ SOUNDER_DDR &= ~(SOUNDER_MASK);
+}
+/*---------------------------------------------------------------------------*/
+void
+adc_init()
+{
+ ADMUX = 0;
+ /* AVCC with external capacitor at AREF pin. */
+ //ADMUX |= _BV(REFS0)
+ /* Disable ADC interrupts. */
+ ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
+ /* Set ADC prescaler to 64 and clear interrupt flag. */
+ ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
+
+}
+/*---------------------------------------------------------------------------*/
+/* Poll based approach. The interrupt based adc is currently not used.
+ The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
+ other two bits are in ADCH. See Atmega128 datasheet page 228. */
+uint16_t
+get_adc(int channel)
+{
+ uint16_t reading;
+
+ ADMUX |= (channel & 0x1F);
+
+ /* Disable ADC interrupts. */
+ ADCSRA &= ~_BV(ADIE);
+ /* Clear previous interrupts. */
+ ADCSRA |= _BV(ADIF);
+ /* Enable ADC and start conversion. */
+ ADCSRA |= _BV(ADEN) | _BV(ADSC);
+ /* Wait until conversion is completed. */
+ while ( ADCSRA & _BV(ADSC) );
+ /* Get first 8 bits. */
+ reading = ADCL;
+ /* Get last two bits. */
+ reading |= (ADCH & 3) << 8;
+ /* Disable ADC. */
+ ADCSRA &= ~_BV(ADEN);
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+uint16_t
+get_light()
+{
+ uint16_t reading;
+
+ /* Enable light sensor. */
+ LIGHT_PORT |= LIGHT_PIN_MASK;
+ LIGHT_PORT_DDR |= LIGHT_PIN_MASK;
+ /* Disable temperature sensor. */
+ TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
+ TEMP_PORT &= ~TEMP_PIN_MASK;
+ /* Read ADC. */
+ reading = get_adc(LIGHT_ADC_CHANNEL);
+ /* Disable light sensor. */
+ LIGHT_PORT &= ~LIGHT_PIN_MASK;
+ LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+uint16_t
+get_temp()
+{
+ uint16_t reading;
+
+ /* Disable light sensor. */
+ LIGHT_PORT &= ~LIGHT_PIN_MASK;
+ LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
+ /* Enable temperature sensor. */
+ TEMP_PORT_DDR |= TEMP_PIN_MASK;
+ TEMP_PORT |= TEMP_PIN_MASK;
+ /* Read ADC. */
+ reading = get_adc(TEMP_ADC_CHANNEL);
+ /* Disable temperature sensor. */
+ TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
+ TEMP_PORT &= ~TEMP_PIN_MASK;
+
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+uint16_t
+get_accx()
+{
+ uint16_t reading;
+
+ /* Enable accelerometer. */
+ ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
+ ACCEL_PORT |= ACCEL_PIN_MASK;
+ /* Read ADC. */
+ reading = get_adc(ACCELX_ADC_CHANNEL);
+ /* Enable accelerometer. */
+ ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
+ ACCEL_PORT &= ~ACCEL_PIN_MASK;
+
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+uint16_t
+get_accy()
+{
+ uint16_t reading;
+
+ /* Enable accelerometer. */
+ ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
+ ACCEL_PORT |= ACCEL_PIN_MASK;
+ /* Read ADC. */
+ reading = get_adc(ACCELY_ADC_CHANNEL);
+ /* Enable accelerometer. */
+ ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
+ ACCEL_PORT &= ~ACCEL_PIN_MASK;
+
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+uint16_t
+get_magx()
+{
+ uint16_t reading;
+
+ /* Enable magnetometer. */
+ MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
+ MAGNET_PORT |= MAGNET_PIN_MASK;
+ /* Read ADC. */
+ reading = get_adc(MAGNETX_ADC_CHANNEL);
+ /* Enable magnetometer. */
+ MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
+ MAGNET_PORT &= ~MAGNET_PIN_MASK;
+
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+uint16_t
+get_magy()
+{
+ uint16_t reading;
+
+ /* Enable magnetometer. */
+ MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
+ MAGNET_PORT |= MAGNET_PIN_MASK;
+ /* Read ADC. */
+ reading = get_adc(MAGNETY_ADC_CHANNEL);
+ /* Enable magnetometer. */
+ MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
+ MAGNET_PORT &= ~MAGNET_PIN_MASK;
+
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+uint16_t
+get_mic()
+{
+ uint16_t reading;
+
+ /* Enable mic. */
+ MIC_PORT_DDR |= MIC_PIN_MASK;
+ MIC_PORT |= MIC_PIN_MASK;
+ /* Read ADC. */
+ reading = get_adc(MIC_ADC_CHANNEL);
+ /* Enable mic. */
+ MIC_PORT_DDR &= ~MIC_PIN_MASK;
+ MIC_PORT &= ~MIC_PIN_MASK;
+
+ return reading;
+}
+/*---------------------------------------------------------------------------*/
+
diff --git a/platform/iris/dev/sensors/mts300.h b/platform/iris/dev/sensors/mts300.h
new file mode 100644
index 000000000..ca43229a1
--- /dev/null
+++ b/platform/iris/dev/sensors/mts300.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+/**
+ * \file
+ * Device drivers header file for MTS300 sensor board.
+ * \author
+ * Kasun Hewage
+ */
+
+#ifndef __MTS300_H__
+#define __MTS300_H__
+
+#include
+#include "contiki-conf.h"
+
+#define SOUNDER_PORT PORTC
+#define SOUNDER_MASK _BV(2)
+#define SOUNDER_DDR DDRC
+
+/* MTS300CA and MTS310CA, the light sensor power is controlled
+ * by setting signal INT1(PORTE pin 5).
+ * Both light and thermistor use the same ADC channel.
+ */
+#define LIGHT_PORT_DDR DDRE
+#define LIGHT_PORT PORTE
+#define LIGHT_PIN_MASK _BV(5)
+#define LIGHT_ADC_CHANNEL 1
+
+/* MTS300CA and MTS310CA, the thermistor power is controlled
+ * by setting signal INT2(PORTE pin 6).
+ * Both light and thermistor use the same ADC channel.
+ */
+#define TEMP_PORT_DDR DDRE
+#define TEMP_PORT PORTE
+#define TEMP_PIN_MASK _BV(6)
+#define TEMP_ADC_CHANNEL 1
+
+/* Power is controlled to the accelerometer by setting signal
+ * PW4(PORTC pin 4), and the analog data is sampled on ADC3 and ADC4.
+ */
+#define ACCEL_PORT_DDR DDRC
+#define ACCEL_PORT PORTC
+#define ACCEL_PIN_MASK _BV(4)
+#define ACCELX_ADC_CHANNEL 3
+#define ACCELY_ADC_CHANNEL 4
+
+/* Power is controlled to the magnetometer by setting signal
+ * PW5(PORTC pin 5), and the analog data is sampled on ADC5 and ADC6.
+ */
+#define MAGNET_PORT_DDR DDRC
+#define MAGNET_PORT PORTC
+#define MAGNET_PIN_MASK _BV(5)
+#define MAGNETX_ADC_CHANNEL 5
+#define MAGNETY_ADC_CHANNEL 6
+
+
+#define MIC_PORT_DDR DDRC
+#define MIC_PORT PORTC
+#define MIC_PIN_MASK _BV(3)
+#define MIC_ADC_CHANNEL 2
+
+void sounder_on();
+void sounder_off();
+
+uint16_t get_light();
+uint16_t get_temp();
+
+uint16_t get_accx();
+uint16_t get_accy();
+
+uint16_t get_magx();
+uint16_t get_magy();
+
+uint16_t get_mic();
+
+void mts300_init();
+
+#endif /* __MTS300_H__ */
+
+
+
diff --git a/platform/iris/dev/slip_uart0.c b/platform/iris/dev/slip_uart0.c
new file mode 100644
index 000000000..bf36616ad
--- /dev/null
+++ b/platform/iris/dev/slip_uart0.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+/**
+ * \file
+ * Machine dependent AVR SLIP routines for UART0.
+ * \author
+ * Kasun Hewage
+ */
+
+#include
+#include "contiki.h"
+#include "dev/rs232.h"
+#include "slip.h"
+
+/*---------------------------------------------------------------------------*/
+static int
+slip_putchar(char c, FILE *stream)
+{
+#define SLIP_END 0300
+ static char debug_frame = 0;
+
+ if (!debug_frame) { /* Start of debug output */
+ slip_arch_writeb(SLIP_END);
+ slip_arch_writeb('\r'); /* Type debug line == '\r' */
+ debug_frame = 1;
+ }
+
+ slip_arch_writeb((unsigned char)c);
+
+ /*
+ * Line buffered output, a newline marks the end of debug output and
+ * implicitly flushes debug output.
+ */
+ if (c == '\n') {
+ slip_arch_writeb(SLIP_END);
+ debug_frame = 0;
+ }
+
+ return c;
+}
+/*---------------------------------------------------------------------------*/
+static FILE slip_stdout = FDEV_SETUP_STREAM(slip_putchar, NULL,
+ _FDEV_SETUP_WRITE);
+/*---------------------------------------------------------------------------*/
+void
+slip_arch_init(unsigned long ubr)
+{
+ rs232_set_input(RS232_PORT_0, slip_input_byte);
+ stdout = &slip_stdout;
+}
+/*---------------------------------------------------------------------------*/
+/*
+ XXX:
+ Currently, the following function is in cpu/avr/dev/rs232.c file. this
+ should be moved to here from there hence this is a platform specific slip
+ related function.
+void
+slip_arch_writeb(unsigned char c)
+{
+ rs232_send(RS232_PORT_0, c);
+}
+*/
diff --git a/platform/iris/init-net.c b/platform/iris/init-net.c
new file mode 100644
index 000000000..f5e3f6556
--- /dev/null
+++ b/platform/iris/init-net.c
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2010, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+/**
+ * \file
+ * Network initialization for the MICAz port.
+ * \author
+ * Kasun Hewage
+ */
+
+#include
+#include
+#include
+
+#include "contiki.h"
+#include "rf230bb.h"
+#include "dev/rs232.h"
+#include "dev/slip.h"
+#include "dev/leds.h"
+#include "net/netstack.h"
+#include "net/mac/frame802154.h"
+
+#include "dev/ds2401.h"
+#include "node-id.h"
+
+#if WITH_UIP6
+#include "net/uip-ds6.h"
+#endif /* WITH_UIP6 */
+
+#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)};
+
+static uint8_t is_gateway;
+
+#endif /* WITH_UIP */
+
+#define UIP_OVER_MESH_CHANNEL 8
+
+/*---------------------------------------------------------------------------*/
+static void
+set_rime_addr(void)
+{
+ rimeaddr_t addr;
+ int i;
+
+ memset(&addr, 0, sizeof(rimeaddr_t));
+#if UIP_CONF_IPV6
+ memcpy(addr.u8, ds2401_id, sizeof(addr.u8));
+#else
+ if(node_id == 0) {
+ for(i = 0; i < sizeof(rimeaddr_t); ++i) {
+ addr.u8[i] = ds2401_id[7 - i];
+ }
+ } else {
+ addr.u8[0] = node_id & 0xff;
+ addr.u8[1] = node_id >> 8;
+ }
+#endif
+ rimeaddr_set_node_addr(&addr);
+ printf_P(PSTR("Rime started with address "));
+ for(i = 0; i < sizeof(addr.u8) - 1; i++) {
+ printf_P(PSTR("%d."), addr.u8[i]);
+ }
+ printf_P(PSTR("%d\n"), addr.u8[i]);
+}
+
+/*--------------------------------------------------------------------------*/
+#if WITH_UIP
+static void
+set_gateway(void)
+{
+ if(!is_gateway) {
+ leds_on(LEDS_RED);
+ printf_P(PSTR("%d.%d: making myself the IP network gateway.\n\n"),
+ rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
+ printf_P(PSTR("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 */
+/*---------------------------------------------------------------------------*/
+void
+init_net(void)
+{
+
+ set_rime_addr();
+ NETSTACK_RADIO.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_P(PSTR("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"),
+ longaddr[0], longaddr[1], longaddr[2], longaddr[3],
+ longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
+
+ rf230_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
+ }
+ rf230_set_channel(RF_CHANNEL);
+
+
+#if WITH_UIP6
+ memcpy(&uip_lladdr.addr, ds2401_id, 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_P(PSTR("%s %s, channel check rate %d Hz, radio channel %d\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_P(PSTR("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_P(PSTR("%02x%02x:"), lladdr->ipaddr.u8[i * 2],
+ lladdr->ipaddr.u8[i * 2 + 1]);
+ }
+ printf_P(PSTR("%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_P(PSTR("Tentative global IPv6 address "));
+ for(i = 0; i < 7; ++i) {
+ printf_P(PSTR("%02x%02x:"),
+ ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
+ }
+ printf_P(PSTR("%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_P(PSTR("%s %s, channel check rate %d Hz, radio channel %d\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
+ uip_ipaddr_t hostaddr, netmask;
+
+ uip_init();
+ uip_fw_init();
+
+ process_start(&tcpip_process, NULL);
+ process_start(&slip_process, NULL);
+ process_start(&uip_fw_process, NULL);
+
+ slip_set_input_callback(set_gateway);
+
+ /* Construct ip address from four bytes. */
+ uip_ipaddr(&hostaddr, 172, 16, rimeaddr_node_addr.u8[0],
+ rimeaddr_node_addr.u8[1]);
+ /* Construct netmask from four bytes. */
+ uip_ipaddr(&netmask, 255,255,0,0);
+
+ uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
+ /* Set the IP address for this host. */
+ uip_sethostaddr(&hostaddr);
+ /* Set the netmask for this host. */
+ uip_setnetmask(&netmask);
+
+ uip_over_mesh_set_net(&hostaddr, &netmask);
+
+ /* Register slip interface with forwarding module. */
+ //uip_fw_register(&slipif);
+ uip_over_mesh_set_gateway_netif(&slipif);
+ /* Set slip interface to be a default forwarding interface . */
+ uip_fw_default(&meshif);
+ uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
+ printf_P(PSTR("uIP started with IP address %d.%d.%d.%d\n"),
+ uip_ipaddr_to_quad(&hostaddr));
+#endif /* WITH_UIP */
+
+
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/init-net.h b/platform/iris/init-net.h
new file mode 100644
index 000000000..8c3711980
--- /dev/null
+++ b/platform/iris/init-net.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+/**
+ * \file
+ * Network initialization for the MICAz port.
+ * \author
+ * Kasun Hewage
+ */
+
+#ifndef __INIT_NET_H__
+#define __INIT_NET_H__
+
+void init_net(void);
+
+#endif /* __INIT_NET_H__ */
diff --git a/platform/iris/node-id.c b/platform/iris/node-id.c
new file mode 100644
index 000000000..dffa514bd
--- /dev/null
+++ b/platform/iris/node-id.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2009, University of Colombo School of Computing
+ * 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.
+ *
+ * @(#)$$
+ */
+
+#include "node-id.h"
+
+uint16_t node_id = 0;
+
+/*---------------------------------------------------------------------------*/
+void
+node_id_restore(void)
+{
+ uint16_t newid[2];
+ uint8_t volatile sreg;
+
+ sreg = SREG; /* Save status register before disabling interrupts. */
+ cli(); /* Disable interrupts. */
+ eeprom_read(EEPROM_NODE_ID_START, (unsigned char *)newid, sizeof(newid));
+ node_id = (newid[0] == 0xdead) ? newid[1] : 0;
+ SREG = sreg; /* Enable interrupts. */
+}
+/*---------------------------------------------------------------------------*/
+void
+node_id_burn(uint16_t id)
+{
+ uint16_t buffer[2] = { 0xdead, id };
+ uint8_t volatile sreg;
+
+ sreg = SREG; /* Save status register before disabling interrupts. */
+ cli(); /* Disable interrupts. */
+ eeprom_write(EEPROM_NODE_ID_START, (unsigned char *)buffer, sizeof(buffer));
+ SREG = sreg; /* Enable interrupts. */
+}
+/*---------------------------------------------------------------------------*/
diff --git a/platform/iris/node-id.h b/platform/iris/node-id.h
new file mode 100644
index 000000000..6c3a2d9c7
--- /dev/null
+++ b/platform/iris/node-id.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005, 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: Adam Dunkels
+ *
+ */
+
+#ifndef NODE_ID_H
+#define NODE_ID_H
+
+#include "contiki-conf.h"
+
+void node_id_restore(void);
+void node_id_burn(uint16_t node_id);
+
+extern uint16_t node_id;
+
+#endif /* !NODE_ID_H */
diff --git a/platform/iris/platform-conf.h b/platform/iris/platform-conf.h
new file mode 100644
index 000000000..fc39ea646
--- /dev/null
+++ b/platform/iris/platform-conf.h
@@ -0,0 +1,114 @@
+/*
+ * 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/06/23 10:25:54 joxe Exp $
+ */
+
+/**
+ * \file
+ * A brief description of what this file is
+ * \author
+ * Niclas Finne
+ * Joakim Eriksson
+ */
+
+#ifndef __PLATFORM_CONF_H__
+#define __PLATFORM_CONF_H__
+
+/*
+ * Definitions below are dictated by the hardware and not really
+ * changeable!
+ */
+#define PLATFORM PLATFORM_AVR
+
+#define HARWARE_REVISION IRIS
+
+/* Clock ticks per second */
+#define CLOCK_CONF_SECOND 128
+
+
+/* LED ports */
+#define LEDS_PxDIR DDRA // port direction register
+#define LEDS_PxOUT PORTA // port register
+#define LEDS_CONF_RED 0x04 //red led
+#define LEDS_CONF_GREEN 0x02 // green led
+#define LEDS_CONF_YELLOW 0x01 // yellow led
+
+/* COM port to be used for SLIP connection */
+#define SLIP_PORT RS232_PORT_0
+
+/* Pre-allocated memory for loadable modules heap space (in bytes)*/
+#define MMEM_CONF_SIZE 256
+
+/* Use the following address for code received via the codeprop
+ * facility
+ */
+#define EEPROMFS_ADDR_CODEPROP 0x8000
+
+#define EEPROM_NODE_ID_START 0x00
+
+
+#define NETSTACK_CONF_RADIO rf230_driver
+
+
+/*
+ * SPI bus configuration for the TMote Sky.
+ */
+
+/* SPI input/output registers. */
+#define SPI_TXBUF SPDR
+#define SPI_RXBUF SPDR
+
+#define BV(bitno) _BV(bitno)
+
+#define SPI_WAITFOREOTx() do { while (!(SPSR & BV(SPIF))); } while (0)
+#define SPI_WAITFOREORx() do { while (!(SPSR & BV(SPIF))); } while (0)
+
+#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */
+#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */
+#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */
+
+/*
+ * SPI bus - M25P80 external flash configuration.
+ */
+
+#define FLASH_PWR 3 /* P4.3 Output */
+#define FLASH_CS 4 /* P4.4 Output */
+#define FLASH_HOLD 7 /* P4.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() ( P4OUT &= ~BV(FLASH_HOLD) )
+#define SPI_FLASH_UNHOLD() ( P4OUT |= BV(FLASH_HOLD) )
+
+#define CSN 0
+
+#endif /* __PLATFORM_CONF_H__ */