]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/platforms/mica/sim/MeasureClockC.nc
Merge devel code into the trunk.
[tinyos-2.x.git] / tos / platforms / mica / sim / MeasureClockC.nc
diff --git a/tos/platforms/mica/sim/MeasureClockC.nc b/tos/platforms/mica/sim/MeasureClockC.nc
new file mode 100644 (file)
index 0000000..7a1ba0c
--- /dev/null
@@ -0,0 +1,32 @@
+#include "scale.h"
+
+/**
+ * Simulation version of MeasureClockC for the mica platform. See 
+ * tos/platforms/mica/MeasureClockC.nc for more details.
+ *
+ * @author Phil Levis
+ */
+
+module MeasureClockC {
+  /* This code MUST be called from PlatformP only, hence the exactlyonce */
+  provides interface Init @exactlyonce();
+
+  provides {
+    command uint16_t cyclesPerJiffy();
+    command uint32_t calibrateMicro(uint32_t n);
+  }
+}
+implementation 
+{
+  command error_t Init.init() {
+    return SUCCESS;
+  }
+
+  command uint16_t cyclesPerJiffy() {
+    return (1 << 8);
+  }
+
+  command uint32_t calibrateMicro(uint32_t n) {
+    return scale32(n + 122, 244, (1 << 32));
+  }
+}