From: andreaskoepke Date: Wed, 5 Dec 2007 10:14:55 +0000 (+0000) Subject: add a 64 bit interface X-Git-Tag: release_tinyos_2_1_0_0~645 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=4ba4b94611387e857fa1249fe49340aeabe9670e add a 64 bit interface --- diff --git a/tos/platforms/eyesIFX/LocalTimeC.nc b/tos/platforms/eyesIFX/LocalTimeC.nc index 97be68bf..23bc816a 100644 --- a/tos/platforms/eyesIFX/LocalTimeC.nc +++ b/tos/platforms/eyesIFX/LocalTimeC.nc @@ -30,11 +30,13 @@ configuration LocalTimeC { provides { interface LocalTime as LocalTime; + interface WideLocalTime as WideLocalTime; } } implementation { components LocalTimeP, Counter32khz16C as Counter; LocalTime = LocalTimeP; + WideLocalTime = LocalTimeP; LocalTimeP.Counter32khz16 -> Counter; } diff --git a/tos/platforms/eyesIFX/LocalTimeP.nc b/tos/platforms/eyesIFX/LocalTimeP.nc index 87784227..6e00648d 100644 --- a/tos/platforms/eyesIFX/LocalTimeP.nc +++ b/tos/platforms/eyesIFX/LocalTimeP.nc @@ -30,6 +30,7 @@ module LocalTimeP { provides { interface LocalTime as LocalTime32kHz; + interface WideLocalTime as WideLocalTime; } uses { interface Counter 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; } } diff --git a/tos/platforms/eyesIFX/RadioDataLinkC.nc b/tos/platforms/eyesIFX/RadioDataLinkC.nc index d9109daf..fb47e88f 100644 --- a/tos/platforms/eyesIFX/RadioDataLinkC.nc +++ b/tos/platforms/eyesIFX/RadioDataLinkC.nc @@ -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 index 00000000..f0fe7335 --- /dev/null +++ b/tos/platforms/eyesIFX/WideLocalTime.nc @@ -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 +{ + /** + * 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(); +} +