]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Deluge T2 support for Epic. This includes support for at45db161d and some refactoring...
authorrazvanm <razvanm>
Mon, 25 Aug 2008 16:48:45 +0000 (16:48 +0000)
committerrazvanm <razvanm>
Mon, 25 Aug 2008 16:48:45 +0000 (16:48 +0000)
39 files changed:
apps/tests/deluge/Blink/burn
support/make/epic.target
support/make/tosboot.extra
tools/tinyos/misc/tos-deluge
tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerC.nc
tos/lib/net/Deluge/BlockStorageManager/BlockStorageManagerP.nc
tos/lib/net/Deluge/DelugePageTransfer.h
tos/lib/net/Deluge/extra/epic/TOSBoot_platform.h [new file with mode: 0644]
tos/lib/net/Deluge/extra/telos/InternalFlash.h [new file with mode: 0644]
tos/lib/net/Deluge/extra/telos/InternalFlash.nc [new file with mode: 0644]
tos/lib/net/Deluge/extra/telos/ReprogramGuardC.nc [new file with mode: 0644]
tos/lib/net/Deluge/extra/telos/ReprogramGuardP.nc [new file with mode: 0644]
tos/lib/net/Deluge/extra/telosb/InternalFlash.h [deleted file]
tos/lib/net/Deluge/extra/telosb/InternalFlash.nc [deleted file]
tos/lib/tosboot/Makefile
tos/lib/tosboot/TOSBootM.nc
tos/lib/tosboot/epic/ExtFlashC.nc [new file with mode: 0644]
tos/lib/tosboot/epic/ExtFlashM.nc [new file with mode: 0644]
tos/lib/tosboot/epic/hardware.h [new file with mode: 0644]
tos/lib/tosboot/micaz/TOSBoot_platform.h
tos/lib/tosboot/msp430f1611/InternalFlash.h [new file with mode: 0644]
tos/lib/tosboot/msp430f1611/InternalFlash.nc [new file with mode: 0644]
tos/lib/tosboot/msp430f1611/PluginC.nc [new file with mode: 0644]
tos/lib/tosboot/msp430f1611/PowerOffM.nc [new file with mode: 0644]
tos/lib/tosboot/msp430f1611/TOSBoot_platform.h [new file with mode: 0644]
tos/lib/tosboot/telosb/InternalFlash.h [deleted file]
tos/lib/tosboot/telosb/InternalFlash.nc [deleted file]
tos/lib/tosboot/telosb/PluginC.nc [deleted file]
tos/lib/tosboot/telosb/PowerOffM.nc [deleted file]
tos/lib/tosboot/telosb/TOSBoot_platform.h [deleted file]
tos/platforms/epic/.platform
tos/platforms/epic/MotePlatformC.nc [new file with mode: 0644]
tos/platforms/epic/PlatformC.nc
tos/platforms/epic/PlatformP.nc
tos/platforms/epic/chips/at45db/HplAt45dbC.nc [new file with mode: 0644]
tos/platforms/epic/chips/at45db/HplAt45dbP.nc [new file with mode: 0644]
tos/platforms/epic/chips/at45db/HplAt45db_chip.h [new file with mode: 0644]
tos/platforms/telosa/chips/at45db/HplAt45dbC.nc
tos/platforms/telosa/chips/at45db/HplAt45dbP.nc

index 1e82f5d3b23859ce8d8440fff2b1bf7f5985b89d..e43e7b0c71bd8254f1a77441fa4137000257fca6 100755 (executable)
@@ -22,7 +22,7 @@ if [[ $# -ne 2 && $# -ne 3 ]]; then
   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
 
@@ -35,7 +35,7 @@ if [ $# -eq 3 ]; then
  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
@@ -52,7 +52,7 @@ echo ============================ Compile and load Blink =======================
 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' ]
index 8f0aadb45207e1770e36bd8faf5bc054a3101e91..02b6b4b50bbff3469443881c20f628482f3ec0fa 100644 (file)
@@ -11,9 +11,8 @@ OPTFLAGS += -O
 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)
index 2420fa9372fb992aedeaccff61e28f778b715b21..80e00688c96f2509b695620d3a519fd20752d44c 100644 (file)
@@ -10,12 +10,19 @@ ifeq ($(BOOTLOADER),tosboot)
   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
index c1c7777fb86b7c87d483232be7184371f3c19434..1ca3acb5ef1042cb54b8d3ea91e54578dc8fb896 100755 (executable)
@@ -41,7 +41,8 @@ DM_AMID = 0x54
 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
index 5feb30312607bc0ac31a638894163dc7a99c88b1..168961d69458cef03aa0498434742df16b28305c 100644 (file)
@@ -69,7 +69,7 @@ implementation
   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
index 9fbd9e40ae52c64df0f989726206d6ecd594c887..a6ce351f54d4ad397ab846106ebc46398ffd3b75 100644 (file)
@@ -37,7 +37,7 @@ generic module BlockStorageManagerP(uint8_t clients)
     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
   }
@@ -180,13 +180,7 @@ implementation
     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;
index c491dffb0a460387c71f65cb76d3a62b74b6a155..f3d6c652a74f3b89eb0b4f92a6182ffca63e8aa7 100644 (file)
@@ -31,7 +31,7 @@
 #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"
diff --git a/tos/lib/net/Deluge/extra/epic/TOSBoot_platform.h b/tos/lib/net/Deluge/extra/epic/TOSBoot_platform.h
new file mode 100644 (file)
index 0000000..c892207
--- /dev/null
@@ -0,0 +1,38 @@
+// $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
diff --git a/tos/lib/net/Deluge/extra/telos/InternalFlash.h b/tos/lib/net/Deluge/extra/telos/InternalFlash.h
new file mode 100644 (file)
index 0000000..eca3667
--- /dev/null
@@ -0,0 +1,45 @@
+// $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
diff --git a/tos/lib/net/Deluge/extra/telos/InternalFlash.nc b/tos/lib/net/Deluge/extra/telos/InternalFlash.nc
new file mode 100644 (file)
index 0000000..d41d52b
--- /dev/null
@@ -0,0 +1,37 @@
+// $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);
+}
diff --git a/tos/lib/net/Deluge/extra/telos/ReprogramGuardC.nc b/tos/lib/net/Deluge/extra/telos/ReprogramGuardC.nc
new file mode 100644 (file)
index 0000000..9f25e50
--- /dev/null
@@ -0,0 +1,13 @@
+configuration ReprogramGuardC
+{
+  provides interface ReprogramGuard;
+}
+
+implementation
+{
+  components ReprogramGuardP;
+  components new VoltageC();
+  
+  ReprogramGuard = ReprogramGuardP;
+  ReprogramGuardP.Voltage -> VoltageC;
+}
diff --git a/tos/lib/net/Deluge/extra/telos/ReprogramGuardP.nc b/tos/lib/net/Deluge/extra/telos/ReprogramGuardP.nc
new file mode 100644 (file)
index 0000000..1ffb1e9
--- /dev/null
@@ -0,0 +1,23 @@
+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);
+  }
+  
+}
diff --git a/tos/lib/net/Deluge/extra/telosb/InternalFlash.h b/tos/lib/net/Deluge/extra/telosb/InternalFlash.h
deleted file mode 100644 (file)
index eca3667..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// $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
diff --git a/tos/lib/net/Deluge/extra/telosb/InternalFlash.nc b/tos/lib/net/Deluge/extra/telosb/InternalFlash.nc
deleted file mode 100644 (file)
index d41d52b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// $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);
-}
index 5551bc798d9bf26ae7fdc439b20d0c348e6d971e..605bbbb40527e539f62684ee01276976dc442fff 100644 (file)
@@ -67,7 +67,14 @@ endif
 
 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
index fa1893c72c93f176fc4ee26fc672524e410d6871..e04718f4d33d0abb97845aaf126aa3857511e20b 100644 (file)
@@ -120,7 +120,7 @@ implementation {
                       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;
@@ -147,7 +147,7 @@ implementation {
     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) {
diff --git a/tos/lib/tosboot/epic/ExtFlashC.nc b/tos/lib/tosboot/epic/ExtFlashC.nc
new file mode 100644 (file)
index 0000000..9f7d534
--- /dev/null
@@ -0,0 +1,51 @@
+// $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;
+
+}
diff --git a/tos/lib/tosboot/epic/ExtFlashM.nc b/tos/lib/tosboot/epic/ExtFlashM.nc
new file mode 100644 (file)
index 0000000..a80ecab
--- /dev/null
@@ -0,0 +1,98 @@
+// $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();
+  }
+
+}
diff --git a/tos/lib/tosboot/epic/hardware.h b/tos/lib/tosboot/epic/hardware.h
new file mode 100644 (file)
index 0000000..281de0a
--- /dev/null
@@ -0,0 +1,86 @@
+// $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
index 91300751999fd25c4b76d0d1a5c14e35a9f2a282..1747746144e3bdbec4aa185b88192c2d9caddbfc 100644 (file)
 #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 {
diff --git a/tos/lib/tosboot/msp430f1611/InternalFlash.h b/tos/lib/tosboot/msp430f1611/InternalFlash.h
new file mode 100644 (file)
index 0000000..eca3667
--- /dev/null
@@ -0,0 +1,45 @@
+// $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
diff --git a/tos/lib/tosboot/msp430f1611/InternalFlash.nc b/tos/lib/tosboot/msp430f1611/InternalFlash.nc
new file mode 100644 (file)
index 0000000..d41d52b
--- /dev/null
@@ -0,0 +1,37 @@
+// $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);
+}
diff --git a/tos/lib/tosboot/msp430f1611/PluginC.nc b/tos/lib/tosboot/msp430f1611/PluginC.nc
new file mode 100644 (file)
index 0000000..860b248
--- /dev/null
@@ -0,0 +1,46 @@
+// $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;
+
+}
diff --git a/tos/lib/tosboot/msp430f1611/PowerOffM.nc b/tos/lib/tosboot/msp430f1611/PowerOffM.nc
new file mode 100644 (file)
index 0000000..94d8dc3
--- /dev/null
@@ -0,0 +1,85 @@
+// $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;
+  }
+
+}
diff --git a/tos/lib/tosboot/msp430f1611/TOSBoot_platform.h b/tos/lib/tosboot/msp430f1611/TOSBoot_platform.h
new file mode 100644 (file)
index 0000000..e880dd1
--- /dev/null
@@ -0,0 +1,43 @@
+// $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
diff --git a/tos/lib/tosboot/telosb/InternalFlash.h b/tos/lib/tosboot/telosb/InternalFlash.h
deleted file mode 100644 (file)
index eca3667..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// $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
diff --git a/tos/lib/tosboot/telosb/InternalFlash.nc b/tos/lib/tosboot/telosb/InternalFlash.nc
deleted file mode 100644 (file)
index d41d52b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// $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);
-}
diff --git a/tos/lib/tosboot/telosb/PluginC.nc b/tos/lib/tosboot/telosb/PluginC.nc
deleted file mode 100644 (file)
index 860b248..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// $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;
-
-}
diff --git a/tos/lib/tosboot/telosb/PowerOffM.nc b/tos/lib/tosboot/telosb/PowerOffM.nc
deleted file mode 100644 (file)
index 94d8dc3..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-// $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;
-  }
-
-}
diff --git a/tos/lib/tosboot/telosb/TOSBoot_platform.h b/tos/lib/tosboot/telosb/TOSBoot_platform.h
deleted file mode 100644 (file)
index 0522d6b..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// $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
index b33fc03057857178104f411d484eb27188ff4d30..5fa10d9e8adbcd6d3ce794db7690990272f02a25 100644 (file)
@@ -10,6 +10,7 @@
 push( @includes, qw(
 
   %T/platforms/epic
+  %T/platforms/epic/chips/at45db
   %T/platforms/telosa
   %T/platforms/telosa/chips/cc2420
   %T/chips/cc2420
@@ -32,8 +33,7 @@ push( @includes, qw(
   %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
diff --git a/tos/platforms/epic/MotePlatformC.nc b/tos/platforms/epic/MotePlatformC.nc
new file mode 100644 (file)
index 0000000..5636b32
--- /dev/null
@@ -0,0 +1,45 @@
+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;
+  }
+}
index c0cd4a177ebb985f9b69dbec9b2561e3cda1b2a8..b36f1f35cc2ad863772ce2cc4c56b1384ee32936 100644 (file)
@@ -40,7 +40,9 @@ configuration PlatformC {
 implementation {
   components PlatformP;
   components MoteClockC;
+  components MotePlatformC;
 
   Init = PlatformP;
   PlatformP.MoteClockInit -> MoteClockC;
+  PlatformP.MoteInit -> MotePlatformC;
 }
index 582e665f73b3b34196fd4f3f8b4256eedccd7aed..acb3afbeecde83295ae0b66b9bc44be0b53133fd 100644 (file)
@@ -38,12 +38,14 @@ module PlatformP {
   }
   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;
   }
diff --git a/tos/platforms/epic/chips/at45db/HplAt45dbC.nc b/tos/platforms/epic/chips/at45db/HplAt45dbC.nc
new file mode 100644 (file)
index 0000000..ef992a8
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+* 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;
+}
diff --git a/tos/platforms/epic/chips/at45db/HplAt45dbP.nc b/tos/platforms/epic/chips/at45db/HplAt45dbP.nc
new file mode 100644 (file)
index 0000000..b3be5b9
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+* 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));
+  }
+}
diff --git a/tos/platforms/epic/chips/at45db/HplAt45db_chip.h b/tos/platforms/epic/chips/at45db/HplAt45db_chip.h
new file mode 100644 (file)
index 0000000..303b351
--- /dev/null
@@ -0,0 +1,45 @@
+// $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
index b48ffbab12862b66bcc8452de15648853ab2a21d..61ed0f01ac2346a14f00fa68e4fa1bd4737cc713 100644 (file)
@@ -32,19 +32,19 @@ configuration HplAt45dbC {
 }
 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;
 }
index b7e73980a5e85d53e432adf091123830ae1683b0..79fc4c009f95c136c65a0affdbb74ac1ca363a61 100644 (file)
@@ -33,7 +33,7 @@ module HplAt45dbP {
     interface HplAt45dbByte;
   }
   uses {
-               interface SpiByte as FlashSpi;
+    interface SpiByte as FlashSpi;
     interface GeneralIO as Select;
   }
 }
@@ -47,23 +47,23 @@ implementation
     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));
   }
 }