echo "Usage: $0 <port> [<comm_port>] <platform>"
echo " <port> /dev/ttyUSB0"
echo " <comm_port> /dev/ttyUSB1"
- echo " <platform> micaz, telosb or iris"
+ echo " <platform> micaz, telosb, iris or epic"
exit 2
fi
PLATFORM=$3
fi
-if [ ${PLATFORM} != 'micaz' -a ${PLATFORM} != 'telosb' -a ${PLATFORM} != 'iris' ]; then
+if [ ${PLATFORM} != 'micaz' -a ${PLATFORM} != 'telosb' -a ${PLATFORM} != 'iris' -a ${PLATFORM} != 'epic' ]; then
echo "\"${PLATFORM}\" is not a supported platform"
exit 2
fi
if [ $PLATFORM == 'micaz' ]
then
CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM} install mib510,${PPORT}
-elif [ $PLATFORM == 'telosb' ]
+elif [ $PLATFORM == 'telosb' -o $PLATFORM == 'epic' ]
then
CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM} install bsl,${PPORT}
elif [ $PLATFORM == 'iris' ]
MSP_BSL ?= tos-bsl
MSP_BSL_FLAGS = --telosb
-#Update for Epic AT45 flash
-#VOLUME_FILE = volumes-stm25p.xml
-#VOLUME_ALLOCATOR = tos-storage-stm25p
+VOLUME_FILE = volumes-at45db.xml
+VOLUME_ALLOCATOR ?= tos-storage-at45db
ifdef CC2420_CHANNEL
PFLAGS += -DCC2420_DEF_CHANNEL=$(CC2420_CHANNEL)
CFLAGS += -DDELUGE
CFLAGS += -I$(TOSDIR)/lib/net -I$(TOSDIR)/lib/net/drip -I$(DELUGE_DIR) -I$(DELUGE_DIR)/FlashVolumeManager -I$(DELUGE_DIR)/BlockStorageManager
- ifneq ($(filter telosb tmote,$(TARGETS)),)
- CFLAGS += -I$(DELUGE_EXTRA) -I$(DELUGE_EXTRA)/msp430 -I$(DELUGE_EXTRA)/telos -I$(DELUGE_EXTRA)/telosb
+ ifneq ($(filter telosb tmote epic,$(TARGETS)),)
+ CFLAGS += -I$(DELUGE_EXTRA) -I$(DELUGE_EXTRA)/msp430 -I$(DELUGE_EXTRA)/telos
ifeq ($(filter docs,$(GOALS)),)
CFLAGS += -Wl,--section-start=.text=0x4a00,--defsym=_reset_vector__=0x4000
endif
- BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/telosb/main.ihex
+ ifeq ($(TARGETS),telosb)
+ CFLAGS += -I$(DELUGE_EXTRA)/telosb
+ BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/telosb/main.ihex
+ endif
+ ifeq ($(TARGETS),epic)
+ CFLAGS += -I$(DELUGE_EXTRA)/epic
+ BOOTLOADER_IMG ?= $(TOSBOOT_DIR)/epic/main.ihex
+ endif
ifeq ($(shell [ -f /bin/cygwin1.dll ] && echo cygwin),cygwin)
BOOTLOADER_IMG := $(shell cygpath -m $(BOOTLOADER_IMG))
endif
SERIAL_DATA_LENGTH = 28 - 1 - 1 - 2 - 2
BAUDRATES = {'micaz': 57600,
'telosb': 115200,
- 'iris': 57600}
+ 'iris': 57600,
+ 'epic': 115200}
# Commands for FlashManager
FM_CMD_ERASE = 0
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)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC)
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)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC)
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)
- 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;
- p_addr = p_addr << AT45_PAGE_SIZE_LOG2;
- p_addr += offset;
-#elif defined(PLATFORM_IRIS)
+#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC)
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;
#ifndef DELUGEPAGETRANSFER_H
#define DELUGEPAGETRANSFER_H
-#if defined(PLATFORM_TELOSB)
+#if defined(PLATFORM_TELOSB) || defined(PLATFORM_EPIC)
#include "extra/telosb/TOSBoot_platform.h"
#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS)
#include "extra/micaz/TOSBoot_platform.h"
--- /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
--- /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."
+ *
+ */
+
+/**
+ * InternalFlash.h - Internal flash implementation for telos msp
+ * platform. On the msp, the flash must first be erased before a value
+ * can be written. However, the msp can only erase the flash at a
+ * segment granularity (128 bytes for the information section). This
+ * module allows transparent read/write of individual bytes to the
+ * information section by dynamically switching between the two
+ * provided segments in the information section.
+ *
+ * Valid address range is 0x1000 - 0x107E (0x107F is used to store the
+ * version number of the information segment).
+ *
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#ifndef __INTERNAL_FLASH_H__
+#define __INTERNAL_FLASH_H__
+
+#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."
+ *
+ */
+
+/**
+ * InternalFlash.nc - A generic interface to read and store values in
+ * the internal flash of a microcontroller.
+ *
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+interface InternalFlash {
+ command error_t write(void* addr, void* buf, uint16_t size);
+ command error_t read(void* addr, void* buf, uint16_t size);
+}
--- /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-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."
- *
- */
-
-/**
- * InternalFlash.h - Internal flash implementation for telos msp
- * platform. On the msp, the flash must first be erased before a value
- * can be written. However, the msp can only erase the flash at a
- * segment granularity (128 bytes for the information section). This
- * module allows transparent read/write of individual bytes to the
- * information section by dynamically switching between the two
- * provided segments in the information section.
- *
- * Valid address range is 0x1000 - 0x107E (0x107F is used to store the
- * version number of the information segment).
- *
- * @author Jonathan Hui <jwhui@cs.berkeley.edu>
- */
-
-#ifndef __INTERNAL_FLASH_H__
-#define __INTERNAL_FLASH_H__
-
-#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."
- *
- */
-
-/**
- * InternalFlash.nc - A generic interface to read and store values in
- * the internal flash of a microcontroller.
- *
- * @author Jonathan Hui <jwhui@cs.berkeley.edu>
- */
-
-interface InternalFlash {
- command error_t write(void* addr, void* buf, uint16_t size);
- command error_t read(void* addr, void* buf, uint16_t size);
-}
ifeq ($(MAKECMDGOALS),telosb)
CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00
- CFLAGS += -Imsp430 -Istm25p -Itelosb -Ilib
+ CFLAGS += -Imsp430 -Imsp430f1611 -Istm25p -Itelosb -Ilib
+ CFLAGS += -I../net/Deluge
+ POST_BUILD_EXTRA_DEPS += strip_iv
+endif
+
+ifeq ($(MAKECMDGOALS),epic)
+ CFLAGS += -DTOSBOOT_START=0x4000 -DTOSBOOT_END=0x4a00
+ CFLAGS += -Imsp430 -Imsp430f1611 -Iepic -Ilib
CFLAGS += -I../net/Deluge
POST_BUILD_EXTRA_DEPS += strip_iv
endif
startAddr + addr, DELUGE_BYTES_PER_PAGE)) {
if (i == 0)
while (1)
- call Leds.flash(1);
+ call Leds.flash(2);
return FALSE;
}
addr += DELUGE_BYTES_PER_PAGE;
secLength = extFlashReadAddr();
curAddr = curAddr + 8;
-#if defined(PLATFORM_TELOSB)
+#if defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC)
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>
+ */
+
+configuration ExtFlashC {
+ provides {
+ interface Init;
+ interface StdControl;
+ interface ExtFlash;
+ }
+}
+
+implementation {
+
+ components
+ ExtFlashM,
+ HPLUSART0M;
+
+ Init = ExtFlashM;
+ StdControl = ExtFlashM;
+ ExtFlash = ExtFlashM;
+
+ ExtFlashM.USARTControl -> HPLUSART0M;
+
+}
--- /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 Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
+ */
+
+module ExtFlashM {
+ provides {
+ interface StdControl;
+ interface Init;
+ interface ExtFlash;
+ }
+ uses {
+ interface HPLUSARTControl as USARTControl;
+ }
+}
+
+implementation {
+
+ uint32_t addr;
+
+ command error_t Init.init() {
+ TOSH_MAKE_FLASH_CS_OUTPUT();
+ TOSH_SET_FLASH_CS_PIN();
+ call USARTControl.setModeSPI();
+ return SUCCESS;
+ }
+
+ command error_t StdControl.start() {
+ return SUCCESS;
+ }
+
+ command error_t StdControl.stop() {
+ call USARTControl.disableSPI();
+ return SUCCESS;
+ }
+
+ command void ExtFlash.startRead(uint32_t newAddr) {
+
+ uint8_t cmd[4];
+ uint8_t i;
+ uint32_t page = newAddr / 512;
+ uint32_t offset = newAddr % 512;
+
+ addr = newAddr;
+
+ cmd[0] = 0x03;
+ cmd[1] = page >> 6;
+ cmd[2] = (page << 2) | (offset >> 8);
+ cmd[3] = offset;
+
+ TOSH_CLR_FLASH_CS_PIN();
+
+ for ( i = 0; i < sizeof(cmd); i++ ) {
+ call USARTControl.tx(cmd[i]);
+ while(call USARTControl.isTxEmpty() != SUCCESS);
+ }
+ }
+
+ command uint8_t ExtFlash.readByte() {
+ if (!(addr & 0x1ff)) {
+ call ExtFlash.stopRead();
+ call ExtFlash.startRead(addr);
+ }
+ addr++;
+ call USARTControl.rx();
+ call USARTControl.tx(0);
+ while(call USARTControl.isRxIntrPending() != SUCCESS);
+ return call USARTControl.rx();
+ }
+
+ command void ExtFlash.stopRead() {
+ TOSH_SET_FLASH_CS_PIN();
+ }
+
+}
--- /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 __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-- );
+}
+
+// LEDs
+TOSH_ASSIGN_PIN(RED_LED, 4, 0);
+TOSH_ASSIGN_PIN(GREEN_LED, 4, 3);
+TOSH_ASSIGN_PIN(YELLOW_LED, 4, 7);
+
+// UART pins
+TOSH_ASSIGN_PIN(SOMI0, 3, 2);
+TOSH_ASSIGN_PIN(SIMO0, 3, 1);
+TOSH_ASSIGN_PIN(UCLK0, 3, 3);
+TOSH_ASSIGN_PIN(UTXD0, 3, 4);
+TOSH_ASSIGN_PIN(URXD0, 3, 5);
+
+// User Interupt Pin
+TOSH_ASSIGN_PIN(USERINT, 2, 7);
+
+// FLASH
+TOSH_ASSIGN_PIN(FLASH_CS, 4, 4);
+
+void TOSH_SET_PIN_DIRECTIONS(void)
+{
+ P3SEL = 0x0E; // set SPI and I2C to mod func
+
+ P1DIR = 0xe0;
+ P1OUT = 0x00;
+
+ P2DIR = 0x7b;
+ P2OUT = 0x10;
+
+ P3DIR = 0xf1;
+ P3OUT = 0x00;
+
+ P4DIR = 0xfd;
+ P4OUT = 0xdd;
+
+ P5DIR = 0xff;
+ P5OUT = 0xff;
+
+ P6DIR = 0xff;
+ P6OUT = 0x00;
+}
+
+#endif
#define __TOSBOOT_PLATFORM_H__
enum {
- // address of TOSBoot args in internal flash
- TOSBOOT_ARGS_ADDR = 0xff0,
- // number of resets to force golden image
- TOSBOOT_GESTURE_MAX_COUNT = 3,
- // address of the golden image in external flash
- TOSBOOT_GOLDEN_IMG_ADDR = 0x0L,
- // size of each internal program flash page
- TOSBOOT_INT_PAGE_SIZE = SPM_PAGESIZE,
+ TOSBOOT_ARGS_ADDR = 0xff0, // 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 = SPM_PAGESIZE, // size of each internal program flash page
};
enum {
--- /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."
+ *
+ */
+
+/**
+ * InternalFlash.h - Internal flash implementation for telos msp
+ * platform. On the msp, the flash must first be erased before a value
+ * can be written. However, the msp can only erase the flash at a
+ * segment granularity (128 bytes for the information section). This
+ * module allows transparent read/write of individual bytes to the
+ * information section by dynamically switching between the two
+ * provided segments in the information section.
+ *
+ * Valid address range is 0x1000 - 0x107E (0x107F is used to store the
+ * version number of the information segment).
+ *
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+#ifndef __INTERNAL_FLASH_H__
+#define __INTERNAL_FLASH_H__
+
+#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."
+ *
+ */
+
+/**
+ * InternalFlash.nc - A generic interface to read and store values in
+ * the internal flash of a microcontroller.
+ *
+ * @author Jonathan Hui <jwhui@cs.berkeley.edu>
+ */
+
+interface InternalFlash {
+ command error_t write(void* addr, void* buf, uint16_t size);
+ command error_t read(void* addr, void* buf, uint16_t size);
+}
--- /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>
+ */
+
+configuration PluginC {
+ provides {
+ interface StdControl;
+ }
+}
+
+implementation {
+
+ components ExtFlashC, LedsC, PowerOffM;
+
+ StdControl = PowerOffM;
+
+ PowerOffM.Leds -> LedsC;
+ PowerOffM.SubControl -> ExtFlashC;
+
+}
--- /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 PowerOffM {
+ 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);
+
+ // if user button is pressed, power down
+ if (!TOSH_READ_USERINT_PIN())
+ haltsystem();
+
+ return SUCCESS;
+
+ }
+
+ command error_t StdControl.stop() {
+ return SUCCESS;
+ }
+
+}
--- /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 = 0xf0000L, // 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."
- *
- */
-
-/**
- * InternalFlash.h - Internal flash implementation for telos msp
- * platform. On the msp, the flash must first be erased before a value
- * can be written. However, the msp can only erase the flash at a
- * segment granularity (128 bytes for the information section). This
- * module allows transparent read/write of individual bytes to the
- * information section by dynamically switching between the two
- * provided segments in the information section.
- *
- * Valid address range is 0x1000 - 0x107E (0x107F is used to store the
- * version number of the information segment).
- *
- * @author Jonathan Hui <jwhui@cs.berkeley.edu>
- */
-
-#ifndef __INTERNAL_FLASH_H__
-#define __INTERNAL_FLASH_H__
-
-#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."
- *
- */
-
-/**
- * InternalFlash.nc - A generic interface to read and store values in
- * the internal flash of a microcontroller.
- *
- * @author Jonathan Hui <jwhui@cs.berkeley.edu>
- */
-
-interface InternalFlash {
- command error_t write(void* addr, void* buf, uint16_t size);
- command error_t read(void* addr, void* buf, uint16_t size);
-}
+++ /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>
- */
-
-configuration PluginC {
- provides {
- interface StdControl;
- }
-}
-
-implementation {
-
- components ExtFlashC, LedsC, PowerOffM;
-
- StdControl = PowerOffM;
-
- PowerOffM.Leds -> LedsC;
- PowerOffM.SubControl -> ExtFlashC;
-
-}
+++ /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 PowerOffM {
- 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);
-
- // if user button is pressed, power down
- if (!TOSH_READ_USERINT_PIN())
- haltsystem();
-
- return SUCCESS;
-
- }
-
- command error_t StdControl.stop() {
- return SUCCESS;
- }
-
-}
+++ /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 {
- // address of TOSBoot args in internal flash
- TOSBOOT_ARGS_ADDR = 0x70,
- // number of resets to force golden image
- TOSBOOT_GESTURE_MAX_COUNT = 3,
- // address of the golden image in external flash
- TOSBOOT_GOLDEN_IMG_ADDR = 0xf0000L,
- // size of each internal program flash page
- TOSBOOT_INT_PAGE_SIZE = 512L,
-};
-
-enum {
- DELUGE_MIN_ADV_PERIOD_LOG2 = 9,
- DELUGE_QSIZE = 1,
-};
-
-#endif
push( @includes, qw(
%T/platforms/epic
+ %T/platforms/epic/chips/at45db
%T/platforms/telosa
%T/platforms/telosa/chips/cc2420
%T/chips/cc2420
%T/chips/msp430/timer
%T/chips/msp430/usart
%T/chips/msp430/sensors
-# TODO
-# %T/chips/at45db161d
+ %T/chips/at45db
%T/lib/timer
%T/lib/serial
%T/lib/adc
--- /dev/null
+module MotePlatformC @safe() {
+ provides interface Init;
+}
+implementation {
+
+ command error_t Init.init() {
+ // reset all of the ports to be input and using i/o functionality
+ atomic
+ {
+ P1SEL = 0;
+ P2SEL = 0;
+ P3SEL = 0;
+ P4SEL = 0;
+ P5SEL = 0;
+ P6SEL = 0;
+
+ P1OUT = 0x00;
+ P1DIR = 0xe0;
+
+ P2OUT = 0x30;
+ P2DIR = 0x7b;
+
+ P3OUT = 0x00;
+ P3DIR = 0xf1;
+
+ P4OUT = 0xdd;
+ P4DIR = 0xfd;
+
+ P5OUT = 0xff;
+ P5DIR = 0xff;
+
+ P6OUT = 0x00;
+ P6DIR = 0xff;
+
+ P1IE = 0;
+ P2IE = 0;
+
+ // the commands above take care of the pin directions
+ // there is no longer a need for explicit set pin
+ // directions using the TOSH_SET/CLR macros
+
+ }//atomic
+ return SUCCESS;
+ }
+}
implementation {
components PlatformP;
components MoteClockC;
+ components MotePlatformC;
Init = PlatformP;
PlatformP.MoteClockInit -> MoteClockC;
+ PlatformP.MoteInit -> MotePlatformC;
}
}
uses {
interface Init as MoteClockInit;
+ interface Init as MoteInit;
interface Init as LedsInit;
}
}
implementation {
command error_t Init.init() {
call MoteClockInit.init();
+ call MoteInit.init();
call LedsInit.init();
return SUCCESS;
}
--- /dev/null
+/*
+* Copyright (c) 2006, Technische Universitat Berlin
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* - Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+* - 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.
+* - Neither the name of the Technische Universitat Berlin 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 COPYRIGHT HOLDERS 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 COPYRIGHT
+* OWNER 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.
+*/
+
+configuration HplAt45dbC {
+ provides interface HplAt45db;
+}
+implementation {
+
+ components new HplAt45dbByteC(10),
+ new Msp430Spi0C() as Spi,
+ HplAt45dbP,
+ HplMsp430GeneralIOC as MspGeneralIO,
+ new Msp430GpioC() as Select;
+
+ HplAt45db = HplAt45dbByteC;
+
+ HplAt45dbByteC.Resource -> Spi;
+ HplAt45dbByteC.FlashSpi -> Spi;
+ HplAt45dbByteC.HplAt45dbByte -> HplAt45dbP;
+
+ Select -> MspGeneralIO.Port44;
+ HplAt45dbP.Select -> Select;
+ HplAt45dbP.FlashSpi -> Spi;
+}
--- /dev/null
+/*
+* Copyright (c) 2006, Technische Universitat Berlin
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* - Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+* - 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.
+* - Neither the name of the Technische Universitat Berlin 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 COPYRIGHT HOLDERS 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 COPYRIGHT
+* OWNER 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.
+*/
+
+
+module HplAt45dbP {
+ provides {
+ interface HplAt45dbByte;
+ }
+ uses {
+ interface SpiByte as FlashSpi;
+ interface GeneralIO as Select;
+ }
+}
+implementation
+{
+ command void HplAt45dbByte.select() {
+ call Select.clr();
+ }
+
+ command void HplAt45dbByte.deselect() {
+ call Select.set();
+ }
+
+ task void idleTask() {
+ uint8_t status;
+ status = call FlashSpi.write(0);
+ if (!(status & 0x80)) {
+ post idleTask();
+ } else {
+ //printf("idle: %d\n", status);
+ signal HplAt45dbByte.idle();
+ }
+ }
+
+ command void HplAt45dbByte.waitIdle() {
+ post idleTask();
+ }
+
+ command bool HplAt45dbByte.getCompareStatus() {
+ uint8_t status;
+ status = call FlashSpi.write(0);
+ //printf("s: %d\n", status);
+ return (!(status & 0x40));
+ }
+}
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2000-2003 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."
+ *
+ * Copyright (c) 2002-2006 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+
+#ifndef HPLAT45DB_CHIP_H
+#define HPLAT45DB_CHIP_H
+
+// flash characteristics
+enum {
+ AT45_MAX_PAGES = 4096,
+ AT45_PAGE_SIZE = 528,
+ AT45_PAGE_SIZE_LOG2 = 9 // For those who want to ignore the last 8 bytes
+};
+
+typedef uint16_t at45page_t;
+typedef uint16_t at45pageoffset_t; /* must fit 0 to AT45_PAGE_SIZE - 1 */
+
+#endif
}
implementation {
- components new HplAt45dbByteC(9),
- new Msp430Spi0C() as Spi,
- HplAt45dbP,
- HplMsp430GeneralIOC as MspGeneralIO,
- new Msp430GpioC() as Select;
+ components new HplAt45dbByteC(9),
+ new Msp430Spi0C() as Spi,
+ HplAt45dbP,
+ HplMsp430GeneralIOC as MspGeneralIO,
+ new Msp430GpioC() as Select;
- HplAt45db = HplAt45dbByteC;
+ HplAt45db = HplAt45dbByteC;
HplAt45dbByteC.Resource -> Spi;
HplAt45dbByteC.FlashSpi -> Spi;
HplAt45dbByteC.HplAt45dbByte -> HplAt45dbP;
- Select -> MspGeneralIO.Port44;
- HplAt45dbP.Select -> Select;
- HplAt45dbP.FlashSpi -> Spi;
+ Select -> MspGeneralIO.Port44;
+ HplAt45dbP.Select -> Select;
+ HplAt45dbP.FlashSpi -> Spi;
}
interface HplAt45dbByte;
}
uses {
- interface SpiByte as FlashSpi;
+ interface SpiByte as FlashSpi;
interface GeneralIO as Select;
}
}
call Select.set();
}
- task void idleTask() {
- uint8_t status;
- status = call FlashSpi.write(0);
- if (!(status & 0x80)) {
- post idleTask();
- } else {
- signal HplAt45dbByte.idle();
- }
- }
+ task void idleTask() {
+ uint8_t status;
+ status = call FlashSpi.write(0);
+ if (!(status & 0x80)) {
+ post idleTask();
+ } else {
+ signal HplAt45dbByte.idle();
+ }
+ }
command void HplAt45dbByte.waitIdle() {
- post idleTask();
+ post idleTask();
}
command bool HplAt45dbByte.getCompareStatus() {
- uint8_t status;
- status = call FlashSpi.write(0);
+ uint8_t status;
+ status = call FlashSpi.write(0);
return (!(status & 0x40));
}
}