]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/net/Deluge/extra/tinynode/ReprogramGuardP.nc
Merge TinyOS 2.1.1 into master.
[tinyos-2.x.git] / tos / lib / net / Deluge / extra / tinynode / ReprogramGuardP.nc
diff --git a/tos/lib/net/Deluge/extra/tinynode/ReprogramGuardP.nc b/tos/lib/net/Deluge/extra/tinynode/ReprogramGuardP.nc
new file mode 100644 (file)
index 0000000..2a3b010
--- /dev/null
@@ -0,0 +1,18 @@
+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);
+  }
+}