]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/platforms/mica/VoltageP.nc
Consistent voltage stuff for mica family based on code from
[tinyos-2.x.git] / tos / platforms / mica / VoltageP.nc
diff --git a/tos/platforms/mica/VoltageP.nc b/tos/platforms/mica/VoltageP.nc
new file mode 100644 (file)
index 0000000..d6e0cd1
--- /dev/null
@@ -0,0 +1,29 @@
+/**\r
+ * Battery Voltage. The returned value represents the difference\r
+ * between the battery voltage and V_BG (1.23V). The formula to convert\r
+ * it to mV is: 1223 * 1024 / value.\r
+ *\r
+ * @author Razvan Musaloiu-E.\r
+ */\r
+module VoltageP\r
+{\r
+  provides interface Atm128AdcConfig;\r
+}\r
+implementation\r
+{\r
+  async command uint8_t Atm128AdcConfig.getChannel()\r
+  {\r
+    // select the 1.23V (V_BG). Reference: Table 97, page 244 from the Atmega128\r
+    return ATM128_ADC_SNGL_1_23;\r
+  }\r
+\r
+  async command uint8_t Atm128AdcConfig.getRefVoltage()\r
+  {\r
+    return ATM128_ADC_VREF_OFF;\r
+  }\r
+\r
+  async command uint8_t Atm128AdcConfig.getPrescaler()\r
+  {\r
+    return ATM128_ADC_PRESCALE;\r
+  }\r
+}\r