${PLATFORM} != 'telosb' -a \
${PLATFORM} != 'iris' -a \
${PLATFORM} != 'mulle' -a \
+ ${PLATFORM} != 'tinynode' -a \
${PLATFORM} != 'epic' ]
then
echo "\"${PLATFORM}\" is not a supported platform"
AVR_FUSE_H ?= 0xda
endif
+ ifeq ($(TARGETS),tinynode)
+ CFLAGS += -I$(DELUGE_EXTRA)/tinynode
+ CFLAGS += -I$(DELUGE_EXTRA) -I$(DELUGE_EXTRA)/msp430 -I$(DELUGE_EXTRA)/msp430f1611
+ ifeq ($(filter docs,$(GOALS)),)
+ CFLAGS += -Wl,--section-start=.text=0x4a00,--defsym=_reset_vector__=0x4000
+ endif
+ BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/tinynode/main.ihex
+ endif
+
endif
BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE1] -> BlockStorageC_1;
BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE2] -> BlockStorageC_2;
BlockStorageManagerP.SubStorageMap[VOLUME_DELUGE3] -> BlockStorageC_3;
-#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE) || defined(PLATFORM_TINYNODE)
components At45dbStorageManagerC;
BlockStorageManagerP.At45dbVolume -> At45dbStorageManagerC;
#endif
interface VolumeId[uint8_t client];
#if defined(PLATFORM_TELOSB)
interface StorageMap as SubStorageMap[volume_id_t volume_id];
-#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE) || defined(PLATFORM_TINYNODE)
interface At45dbVolume[volume_id_t volume_id];
#endif
}
storage_addr_t p_addr = 0xFFFFFFFF;
#if defined(PLATFORM_TELOSB)
p_addr = call SubStorageMap.getPhysicalAddress[volume_id](addr);
-#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC) || defined(PLATFORM_MULLE) || defined(PLATFORM_TINYNODE)
at45page_t page = call At45dbVolume.remap[volume_id]((addr >> AT45_PAGE_SIZE_LOG2));
at45pageoffset_t offset = addr & ((1 << AT45_PAGE_SIZE_LOG2) - 1);
p_addr = page;
#include "extra/micaz/TOSBoot_platform.h"
#elif defined(PLATFORM_MULLE)
#include "extra/mulle/TOSBoot_platform.h"
+#elif defined(PLATFORM_TINYNODE)
+ #include "extra/tinynode/TOSBoot_platform.h"
#else
#error "Target platform is not currently supported by Deluge T2"
#endif
components ActiveMessageAddressC;
NetProgM.setAmAddress -> ActiveMessageAddressC;
+#if !defined(PLATFORM_TINYNODE)
components CC2420ControlP;
NetProgM.CC2420Config -> CC2420ControlP;
+#endif
}
interface InternalFlash as IFlash;
interface Crc;
interface Leds;
+#if !defined(PLATFORM_TINYNODE)
interface CC2420Config;
+#endif
async command void setAmAddress(am_addr_t a);
interface ReprogramGuard;
}
TOS_NODE_ID = bootArgs.address;
call setAmAddress(bootArgs.address);
}
+#if !defined(PLATFORM_TINYNODE)
call CC2420Config.setShortAddr(bootArgs.address);
call CC2420Config.sync();
-
+#endif
return SUCCESS;
}
}
}
+#if !defined(PLATFORM_TINYNODE)
event void CC2420Config.syncDone(error_t error) {}
+#endif
}
--- /dev/null
+// $Id$
+
+/*
+ *
+ *
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#ifndef __NETPROG_PLATFORM_H__
+#define __NETPROG_PLATFORM_H__
+
+void netprog_reboot() {
+ WDTCTL = WDT_ARST_1_9;
+ while(1);
+}
+
+#endif
--- /dev/null
+Deluge T2 for TinyNode
+----------------------------------
+
+
+These files are needed by Deluge T2 to compile for the TinyNode platform.
+
+Note:
+
+Reprogramming fails if the voltage of the node is not above a given
+threshold. Currently, this is set to 2.7V, which may be too high if
+you run your mote on batteries. In this case, set the value of
+VTHRESH in the ReprogramGaurdP.nc file to a different value.
+
+In case you wish not to test the voltage at all, modify ReprogramGuardP.nc
+s.t. the command okToProgram() posts readDone with SUCCESS.
\ No newline at end of file
--- /dev/null
+configuration ReprogramGuardC
+{
+ provides interface ReprogramGuard;
+}
+
+implementation
+{
+ components ReprogramGuardP;
+ components new VoltageC();
+
+ ReprogramGuard = ReprogramGuardP;
+ ReprogramGuardP.Voltage -> VoltageC;
+}
--- /dev/null
+module ReprogramGuardP {
+ provides interface ReprogramGuard;
+ uses interface Read<uint16_t> as Voltage;
+}
+
+implementation {
+ enum {
+ VTHRESH = 0xE66, // 2.7V
+ };
+
+ command error_t ReprogramGuard.okToProgram() {
+ return call Voltage.read();
+ }
+
+ event void Voltage.readDone(error_t result, uint16_t val) {
+ signal ReprogramGuard.okToProgramDone(result == SUCCESS && val > VTHRESH);
+ }
+}
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#ifndef __TOSBOOT_PLATFORM_H__
+#define __TOSBOOT_PLATFORM_H__
+
+enum {
+ TOSBOOT_ARGS_ADDR = 0x70, // address of TOSBoot args in internal flash
+ TOSBOOT_GESTURE_MAX_COUNT = 3, // number of resets to force golden image
+ TOSBOOT_GOLDEN_IMG_ADDR = 0x0L, // address of the golden image in external flash
+ TOSBOOT_INT_PAGE_SIZE = 512L, // size of each internal program flash page
+};
+
+#endif
CFLAGS += -I../net/Deluge/extra/m16c62p
endif
+ifeq ($(MAKECMDGOALS),tinynode)
+ CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00
+ CFLAGS += -Itinynode -Imsp430 -Imsp430f1611 -Iat45db -Ilib
+ CFLAGS += -I../net/Deluge
+ POST_BUILD_EXTRA_DEPS += strip_iv
+endif
+
+
+
strip_iv: FORCE
@echo " removing interrupt vector from binary"
msp430-objcopy -j .text -j .data -O ihex $(BUILDDIR)/main.exe $(BUILDDIR)/main.ihex
secLength = extFlashReadAddr();
curAddr = curAddr + 8;
-#if defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC)
+#if defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE)
if (intAddr != TOSBOOT_END) {
#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS)
if (intAddr != 0) {
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/*
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+module ExecC {
+ provides {
+ interface Exec;
+ }
+}
+
+implementation {
+
+ command void Exec.exec() {
+
+ //goto *(void*)(TOSBOOT_END);
+
+ typedef void __attribute__((noreturn)) (*tosboot_exec)();
+ ((tosboot_exec)TOSBOOT_END)();
+
+ }
+
+}
--- /dev/null
+// $Id$
+
+/*
+ *
+ *
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ * @author Roland Flury <roland.flury@shockfish.com>
+ */
+
+module ExtFlashC {
+ provides {
+ interface Init;
+ interface StdControl;
+ interface ExtFlash;
+ }
+}
+
+/**
+ * Simple reader module to access the Atmel at45db041 flash chip
+ */
+implementation {
+
+ uint32_t addr;
+
+ command error_t Init.init() {
+
+ TOSH_SET_FLASH_CS_PIN(); // inverted, deselect by default
+ TOSH_MAKE_FLASH_CS_OUTPUT();
+
+ TOSH_CLR_FLASH_CLK_PIN();
+ TOSH_MAKE_FLASH_CLK_OUTPUT();
+
+ TOSH_SET_FLASH_OUT_PIN();
+ TOSH_MAKE_FLASH_OUT_OUTPUT();
+
+ TOSH_MAKE_FLASH_IN_INPUT();
+
+ TOSH_SET_FLASH_RESET_PIN(); // inverted
+ TOSH_MAKE_FLASH_RESET_OUTPUT();
+
+ return SUCCESS;
+ }
+
+ command error_t StdControl.start() { return SUCCESS; }
+ command error_t StdControl.stop() { return SUCCESS; }
+
+ /**
+ * Write a Byte over the SPI bus and receive a Byte
+ *
+ * upon calling this function, /CS must be CLR
+ */
+ uint8_t SPIByte(uint8_t out) {
+ uint8_t in = 0;
+ uint8_t i;
+
+ for ( i = 0; i < 8; i++, out <<= 1 ) {
+ // write bit
+ if (out & 0x80) {
+ TOSH_SET_FLASH_OUT_PIN();
+ } else {
+ TOSH_CLR_FLASH_OUT_PIN();
+ }
+
+ // clock
+ TOSH_SET_FLASH_CLK_PIN();
+
+ // read bit
+ in <<= 1;
+ if (TOSH_READ_FLASH_IN_PIN()) {
+ in |= 1;
+ }
+
+ // clock
+ TOSH_CLR_FLASH_CLK_PIN();
+ }
+
+ return in;
+ }
+
+
+
+ /**
+ * Initializes the flash to read Byte after Byte starting
+ * from the given address.
+ *
+ * Subsequent calls to readByte() will return the Bytes
+ * starting from the specified address.
+ *
+ * stopRead() terminates this process and disables the Flash.
+ */
+ command void ExtFlash.startRead(uint32_t newAddr) {
+ uint8_t cmdBuf[4];
+ uint8_t i;
+
+ // we're using "Waveform 1 - Inactive Clock Polarity Low"
+ // see p.7 of data sheet
+ TOSH_CLR_FLASH_CLK_PIN();
+ TOSH_CLR_FLASH_CS_PIN(); // select the flash
+
+ addr = newAddr;
+
+ // we only use 256 Bytes per block (of 264 Bytes)
+ cmdBuf[0] = 0x52; // command for reading data starting at the following address
+ cmdBuf[1] = (addr >> 15) & 0xff; // 4 LSbits
+ cmdBuf[2] = (addr >> 7) & 0xfe; // 7 MSbits with the above 4 bits describe page to read
+ cmdBuf[3] = addr & 0xff; // Offset to Byte in page to read
+
+ // transmit read command
+ for(i = 0; i < 4; i++) {
+ SPIByte(cmdBuf[i]);
+ }
+ // transmit 4 Bytes "don't care" as to spec
+ for(i = 0; i < 4; i++) {
+ SPIByte(0x0);
+ }
+
+ // need to do one additional clock transition before reading
+ TOSH_SET_FLASH_CLK_PIN();
+ TOSH_CLR_FLASH_CLK_PIN();
+ }
+
+ command uint8_t ExtFlash.readByte() {
+ uint8_t b = SPIByte(0); // write anything, read Byte
+ addr++;
+ if(0 == (addr & 0xFF)) {
+ // we've just read the last Byte from a page
+ // initialize the Flash to continue reading on the new page
+ call ExtFlash.stopRead();
+ call ExtFlash.startRead(addr);
+ }
+ return b;
+ }
+
+ command void ExtFlash.stopRead() {
+ TOSH_SET_FLASH_CS_PIN(); // disble Flash & tri-state the OUT-pin
+ }
+
+}
--- /dev/null
+// $Id$
+
+/*
+ *
+ *
+ * "Copyright (c) 2000-2004 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+module PowerOffC {
+ provides {
+ interface Init;
+ interface StdControl;
+ }
+ uses {
+ interface Leds;
+ interface StdControl as SubControl;
+ }
+}
+
+implementation {
+
+ void haltsystem() {
+
+ uint16_t _lpmreg;
+
+ TOSH_SET_PIN_DIRECTIONS();
+
+ call SubControl.stop();
+
+ call Leds.glow(0x7, 0x0);
+
+ _lpmreg = LPM4_bits;
+ _lpmreg |= SR_GIE;
+
+ __asm__ __volatile__( "bis %0, r2" : : "m" ((uint16_t)_lpmreg) );
+
+ }
+
+ command error_t Init.init() {
+ return SUCCESS;
+ }
+
+ command error_t StdControl.start() {
+
+ int i;
+
+ // wait a short period for things to stabilize
+ for ( i = 0; i < 4; i++ ) {
+ wait(0xffff);
+ }
+
+ // TinyNode: we don't have a user button
+
+ // if user button is pressed, power down
+ //if (!TOSH_READ_USERINT_PIN()) {
+ //haltsystem();
+ //}
+
+ return SUCCESS;
+
+ }
+
+ command error_t StdControl.stop() {
+ return SUCCESS;
+ }
+
+}
--- /dev/null
+Deluge T2 for TinyNode
+----------------------------------
+
+
+These files are needed by Deluge T2 to compile for the TinyNode platform.
+
+Note:
+
+Reprogramming fails if the voltage of the node is not above a given
+threshold. Currently, this is set to 2.7V, which may be too high if
+you run your mote on batteries. In this case, set the value of
+VTHRESH in the hardware.h file to a different value.
+
+In case you wish not to test the voltage at all, modify VoltageC.nc
+s.t. the command Voltage.okToProgram() returns always TRUE.
\ No newline at end of file
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#ifndef __TOSBOOT_PLATFORM_H__
+#define __TOSBOOT_PLATFORM_H__
+
+enum {
+ TOSBOOT_ARGS_ADDR = 0x70, // address of TOSBoot args in internal flash
+ TOSBOOT_GESTURE_MAX_COUNT = 3, // number of resets to force golden image
+ TOSBOOT_GOLDEN_IMG_ADDR = 0x0L, // address of the golden image in external flash
+ TOSBOOT_INT_PAGE_SIZE = 512L, // size of each internal program flash page
+};
+
+enum {
+ DELUGE_MIN_ADV_PERIOD_LOG2 = 9,
+ DELUGE_QSIZE = 1,
+};
+
+#endif
--- /dev/null
+// $Id$
+
+/*
+ *
+ *
+ * "Copyright (c) 2000-2004 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+module VoltageC {
+ provides {
+ interface Voltage;
+ }
+}
+
+implementation {
+
+ command bool Voltage.okToProgram() {
+
+ /** original code form the msp430 folder */
+ int i;
+
+ // Turn on and set up ADC12 with REF_1_5V
+ ADC12CTL0 = ADC12ON | SHT0_2 | REFON;
+ // Use sampling timer
+ ADC12CTL1 = SHP;
+ // Set up to sample voltage
+ ADC12MCTL0 = EOS | SREF_1 | INCH_11;
+ // Delay for reference start-up
+ for ( i=0; i<0x3600; i++ );
+
+ // Enable conversions
+ ADC12CTL0 |= ENC;
+ // Start conversion
+ ADC12CTL0 |= ADC12SC;
+ // Wait for completion
+ while ((ADC12IFG & BIT0) == 0);
+
+ // Turn off ADC12
+ ADC12CTL0 &= ~ENC;
+ ADC12CTL0 = 0;
+
+ // Check if voltage is greater than 2.7V
+ return ( ADC12MEM0 > VTHRESH );
+ }
+
+}
--- /dev/null
+// $Id$
+
+/*
+ *
+ *
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+/**
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ * @author Roland Flury <roland.flury@shockfish.com>
+ */
+
+#ifndef __HARDWARE_H__
+#define __HARDWARE_H__
+
+#include "msp430hardware.h"
+
+// internal flash is 16 bits in width
+typedef uint16_t in_flash_addr_t;
+// external flash is 32 bits in width
+typedef uint32_t ex_flash_addr_t;
+
+void wait(uint16_t t) {
+ for(; t > 0; t--);
+}
+enum {
+ VTHRESH = 0xE66, // 2.7V - threshold for reprogramming the node, if voltage is below, don't reprogram
+};
+
+// LEDs
+TOSH_ASSIGN_PIN(RED_LED2, 1, 5); // on tinynode
+TOSH_ASSIGN_PIN(RED_LED, 1, 6); // external
+TOSH_ASSIGN_PIN(GREEN_LED, 2, 3);
+TOSH_ASSIGN_PIN(YELLOW_LED, 2, 4);
+
+// FLASH at45db041
+TOSH_ASSIGN_PIN(FLASH_CS, 4, 7); // inverted
+TOSH_ASSIGN_PIN(FLASH_RESET, 4, 6); // inverted
+TOSH_ASSIGN_PIN(FLASH_CLK, 3, 3);
+TOSH_ASSIGN_PIN(FLASH_OUT, 3, 1); // MOSI - master OUT slave IN
+TOSH_ASSIGN_PIN(FLASH_IN, 3, 2); // MISO - master IN slave OUT
+
+void TOSH_SET_PIN_DIRECTIONS(void) {
+
+ // FLASH at45db041
+ TOSH_SET_FLASH_CS_PIN(); // inverted
+ TOSH_MAKE_FLASH_CS_OUTPUT();
+ TOSH_MAKE_FLASH_OUT_OUTPUT();
+ TOSH_MAKE_FLASH_CLK_OUTPUT();
+ TOSH_MAKE_FLASH_IN_INPUT();
+ TOSH_SET_FLASH_RESET_PIN(); // inverted
+ TOSH_MAKE_FLASH_RESET_OUTPUT();
+
+ // LEDs
+ TOSH_CLR_RED_LED2_PIN();
+ TOSH_CLR_RED_LED_PIN();
+ TOSH_CLR_YELLOW_LED_PIN();
+ TOSH_CLR_GREEN_LED_PIN();
+ TOSH_MAKE_RED_LED2_OUTPUT();
+ TOSH_MAKE_RED_LED_OUTPUT();
+ TOSH_MAKE_YELLOW_LED_OUTPUT();
+ TOSH_MAKE_GREEN_LED_OUTPUT();
+}
+
+#endif