]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
add a 64 bit interface
authorandreaskoepke <andreaskoepke>
Wed, 5 Dec 2007 10:14:55 +0000 (10:14 +0000)
committerandreaskoepke <andreaskoepke>
Wed, 5 Dec 2007 10:14:55 +0000 (10:14 +0000)
tos/platforms/eyesIFX/LocalTimeC.nc
tos/platforms/eyesIFX/LocalTimeP.nc
tos/platforms/eyesIFX/RadioDataLinkC.nc
tos/platforms/eyesIFX/WideLocalTime.nc [new file with mode: 0644]

index 97be68bfb8f9cdd46fd6118dbff84e955f46317c..23bc816af6fe3ebf2d4fc8d94c98287358330786 100644 (file)
 configuration LocalTimeC {
     provides {  
         interface LocalTime<T32khz> as LocalTime;
+        interface WideLocalTime<T32khz> as WideLocalTime;
     }
 }
 implementation  {
     components LocalTimeP, Counter32khz16C as Counter;
     LocalTime = LocalTimeP;
+    WideLocalTime = LocalTimeP;
     LocalTimeP.Counter32khz16 -> Counter;
 }
 
index 87784227ceca7a2cbf438a64efbbfaa4539175c0..6e00648de802127ec9f446798b9d56e6bb8bcb12 100644 (file)
@@ -30,6 +30,7 @@
 module LocalTimeP {
     provides {  
         interface LocalTime<T32khz> as LocalTime32kHz;
+        interface WideLocalTime<T32khz> as WideLocalTime;
     }
     uses {
         interface Counter<T32khz,uint16_t> as Counter32khz16;
@@ -45,20 +46,42 @@ implementation  {
         };
     } ui32parts_t;
     
-    uint16_t counter2sec = 127;
+    typedef union 
+    {
+        uint64_t op;
+        struct {
+            uint32_t lo;
+            uint32_t hi;
+        };
+    } ui64parts_t;
 
+    uint16_t counter2sec = 127;
+    uint32_t dayCounter = 0;
+    
     async command uint32_t LocalTime32kHz.get() {
         ui32parts_t time;
         atomic {
             time.lo = call Counter32khz16.get();
             time.hi = counter2sec;
-            if(call Counter32khz16.isOverflowPending()) ++time.hi;
+            if(call Counter32khz16.isOverflowPending()) {
+                time.hi++;
+            }
         }
         return time.op;
     }
 
+    async command uint64_t WideLocalTime.get() {
+        ui64parts_t time;
+        atomic {
+            time.lo = call LocalTime32kHz.get();
+            time.hi = dayCounter;
+        }
+        return time.op;
+    }
+    
     async event void Counter32khz16.overflow() {
         ++counter2sec;
+        if(counter2sec == 0) ++dayCounter;
     }
 }
 
index d9109daf410f6f3ad8605290bde28eaea3315c51..fb47e88f6ec614e7c2ac5e79af93ffff51c4c2d2 100644 (file)
@@ -51,10 +51,10 @@ implementation
         Tda5250RadioC as Radio,                  //The actual Tda5250 radio over which data is receives/transmitted
         Uart4b6bPhyC as UartPhy,                 //The UartPhy turns Bits into Bytes
         PacketSerializerP  as PacketSerializer,  //The PacketSerializer turns Bytes into Packets
-        // RedMacC as Mac,                         //The MAC protocol to use
-        CsmaMacC as Mac,                         //The MAC protocol to use
-        
-            LinkLayerC as Llc;                       //The Link Layer Control module to use
+        RedMacC as Mac,                         //The MAC protocol to use
+        // SpeckMacDC as Mac,                         //The MAC protocol to use
+        // CsmaMacC as Mac,                         //The MAC protocol to use
+        LinkLayerC as Llc;                       //The Link Layer Control module to use
     
     //Don't change wirings below this point, just change which components
     //They are compposed of in the list above             
diff --git a/tos/platforms/eyesIFX/WideLocalTime.nc b/tos/platforms/eyesIFX/WideLocalTime.nc
new file mode 100644 (file)
index 0000000..f0fe733
--- /dev/null
@@ -0,0 +1,44 @@
+/* -*- mode:c++; indent-tabs-mode:nil -*- 
+ * Copyright (c) 2007, Technische Universitaet 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 Universitaet 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.
+ */
+/**
+ * A wide version of the localtime interface, 32 bit are too narrow
+ */
+#include "Timer.h"
+
+interface WideLocalTime<precision_tag>
+{
+  /** 
+   * Return current time. Time starts counting at boot - some time sources
+   * may stop counting while the processor is in low-power mode.
+   *
+   * @return Current time.
+   */
+  async command uint64_t get();
+}
+