]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Consistent voltage stuff for mica family based on code from
authoridgay <idgay>
Tue, 22 May 2007 20:59:01 +0000 (20:59 +0000)
committeridgay <idgay>
Tue, 22 May 2007 20:59:01 +0000 (20:59 +0000)
Razvan Musaloiu-E.

14 files changed:
tos/platforms/mica/VoltageC.nc [new file with mode: 0644]
tos/platforms/mica/VoltageNowC.nc [new file with mode: 0644]
tos/platforms/mica/VoltageP.nc [new file with mode: 0644]
tos/platforms/mica/VoltageStreamC.nc [new file with mode: 0644]
tos/platforms/mica2/VoltageC.nc [deleted file]
tos/platforms/mica2/VoltageDeviceP.nc [deleted file]
tos/platforms/mica2/VoltageNowC.nc [deleted file]
tos/platforms/mica2/VoltageP.nc [deleted file]
tos/platforms/mica2/VoltageStreamC.nc [deleted file]
tos/platforms/mica2dot/VoltageDeviceP.nc [deleted file]
tos/platforms/mica2dot/VoltageP.nc [deleted file]
tos/platforms/micaz/DemoSensorC.nc
tos/platforms/micaz/DemoSensorNowC.nc
tos/platforms/micaz/DemoSensorStreamC.nc

diff --git a/tos/platforms/mica/VoltageC.nc b/tos/platforms/mica/VoltageC.nc
new file mode 100644 (file)
index 0000000..f99b346
--- /dev/null
@@ -0,0 +1,21 @@
+/**\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
+\r
+generic configuration VoltageC()\r
+{\r
+  provides interface Read<uint16_t>;\r
+}\r
+\r
+implementation\r
+{\r
+  components new AdcReadClientC(), VoltageP;\r
+\r
+  Read = AdcReadClientC;\r
+\r
+  AdcReadClientC.Atm128AdcConfig -> VoltageP;\r
+}\r
diff --git a/tos/platforms/mica/VoltageNowC.nc b/tos/platforms/mica/VoltageNowC.nc
new file mode 100644 (file)
index 0000000..814a04e
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Id$
+ * Copyright (c) 2006 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+/**
+ * Voltage sensor.
+ * 
+ * @author David Gay
+ */
+
+#include "hardware.h"
+
+generic configuration VoltageNowC() {
+  provides interface Resource;
+  provides interface ReadNow<uint16_t>;
+}
+implementation {
+  components new AdcReadNowClientC(), VoltageP;
+
+  ReadNow = AdcReadNowClientC;
+  Resource = AdcReadNowClientC;
+  AdcReadNowClientC.Atm128AdcConfig -> VoltageP;
+}
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
diff --git a/tos/platforms/mica/VoltageStreamC.nc b/tos/platforms/mica/VoltageStreamC.nc
new file mode 100644 (file)
index 0000000..ff477a6
--- /dev/null
@@ -0,0 +1,26 @@
+/* $Id$
+ * Copyright (c) 2006 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+/**
+ * Voltage sensor.
+ * 
+ * @author David Gay
+ */
+
+#include "hardware.h"
+
+generic configuration VoltageStreamC() {
+  provides interface ReadStream<uint16_t>;
+}
+implementation {
+  components VoltageP, new AdcReadStreamClientC();
+
+  ReadStream = AdcReadStreamClientC;
+  AdcReadStreamClientC.Atm128AdcConfig -> VoltageP;
+}
diff --git a/tos/platforms/mica2/VoltageC.nc b/tos/platforms/mica2/VoltageC.nc
deleted file mode 100644 (file)
index e1dbd13..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* $Id$
- * Copyright (c) 2006 Intel Corporation
- * All rights reserved.
- *
- * This file is distributed under the terms in the attached INTEL-LICENSE     
- * file. If you do not find these files, copies can be found by writing to
- * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
- * 94704.  Attention:  Intel License Inquiry.
- */
-/**
- * Voltage sensor.
- * 
- * @author David Gay
- */
-
-#include "hardware.h"
-
-generic configuration VoltageC() {
-  provides interface Read<uint16_t>;
-}
-implementation {
-  components new AdcReadClientC(), VoltageDeviceP;
-
-  Read = AdcReadClientC;
-  AdcReadClientC.Atm128AdcConfig -> VoltageDeviceP;
-  AdcReadClientC.ResourceConfigure -> VoltageDeviceP;
-}
diff --git a/tos/platforms/mica2/VoltageDeviceP.nc b/tos/platforms/mica2/VoltageDeviceP.nc
deleted file mode 100644 (file)
index 63e9466..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* $Id$
- * Copyright (c) 2006 Intel Corporation
- * All rights reserved.
- *
- * This file is distributed under the terms in the attached INTEL-LICENSE     
- * file. If you do not find these files, copies can be found by writing to
- * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
- * 94704.  Attention:  Intel License Inquiry.
- */
-/**
- * Internal component for voltage sensor. Arbitrates access to the voltage
- * sensor and automatically turns it on or off based on user requests.
- * 
- * @author David Gay
- */
-
-#include "hardware.h"
-
-configuration VoltageDeviceP {
-  provides {
-    interface Atm128AdcConfig;
-    interface ResourceConfigure;
-  }
-}
-implementation {
-  components VoltageP, HplAtm128GeneralIOC as Pins;
-
-  Atm128AdcConfig = VoltageP;
-  ResourceConfigure = VoltageP;
-
-  VoltageP.BatMon -> Pins.PortA5;
-}
diff --git a/tos/platforms/mica2/VoltageNowC.nc b/tos/platforms/mica2/VoltageNowC.nc
deleted file mode 100644 (file)
index edf0c18..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $Id$
- * Copyright (c) 2006 Intel Corporation
- * All rights reserved.
- *
- * This file is distributed under the terms in the attached INTEL-LICENSE     
- * file. If you do not find these files, copies can be found by writing to
- * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
- * 94704.  Attention:  Intel License Inquiry.
- */
-/**
- * Voltage sensor.
- * 
- * @author David Gay
- */
-
-#include "hardware.h"
-
-generic configuration VoltageNowC() {
-  provides interface Resource;
-  provides interface ReadNow<uint16_t>;
-}
-implementation {
-  components new AdcReadNowClientC(), VoltageDeviceP;
-
-  ReadNow = AdcReadNowClientC;
-  Resource = AdcReadNowClientC;
-  AdcReadNowClientC.Atm128AdcConfig -> VoltageDeviceP;
-  AdcReadNowClientC.ResourceConfigure -> VoltageDeviceP;
-}
diff --git a/tos/platforms/mica2/VoltageP.nc b/tos/platforms/mica2/VoltageP.nc
deleted file mode 100644 (file)
index e4376aa..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/// $Id$
-
-/*
- * Copyright (c) 2004-2005 Crossbow Technology, Inc.  All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- * 
- * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO 
- * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 
- * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 
- * DAMAGE. 
- *
- * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 
- * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY 
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 
- * MODIFICATIONS.
- */
-/**
- * Internal component for voltage sensor reading.
- *
- * @author Hu Siquan <husq@xbow.com>
- * @author David Gay
- */
-
-module VoltageP {
-  provides {
-    interface ResourceConfigure;
-    interface Atm128AdcConfig as VoltageConfig;
-  }
-  uses interface GeneralIO as BatMon;  
-}
-implementation {
-  async command uint8_t VoltageConfig.getChannel() {
-    return CHANNEL_BATTERY;
-  }
-
-  async command uint8_t VoltageConfig.getRefVoltage() {
-    return ATM128_ADC_VREF_OFF;
-  }
-
-  async command uint8_t VoltageConfig.getPrescaler() {
-    return ATM128_ADC_PRESCALE;
-  }
-
-  async command void ResourceConfigure.configure() {
-    call BatMon.makeOutput();
-    call BatMon.set();
-  }
-
-  async command void ResourceConfigure.unconfigure() {
-    call BatMon.clr();
-  }
-}
diff --git a/tos/platforms/mica2/VoltageStreamC.nc b/tos/platforms/mica2/VoltageStreamC.nc
deleted file mode 100644 (file)
index 6749d89..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* $Id$
- * Copyright (c) 2006 Intel Corporation
- * All rights reserved.
- *
- * This file is distributed under the terms in the attached INTEL-LICENSE     
- * file. If you do not find these files, copies can be found by writing to
- * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
- * 94704.  Attention:  Intel License Inquiry.
- */
-/**
- * Voltage sensor.
- * 
- * @author David Gay
- */
-
-#include "hardware.h"
-
-generic configuration VoltageStreamC() {
-  provides interface ReadStream<uint16_t>;
-}
-implementation {
-  components VoltageDeviceP, new AdcReadStreamClientC();
-
-  ReadStream = AdcReadStreamClientC;
-  AdcReadStreamClientC.Atm128AdcConfig -> VoltageDeviceP;
-  AdcReadStreamClientC.ResourceConfigure -> VoltageDeviceP;
-}
diff --git a/tos/platforms/mica2dot/VoltageDeviceP.nc b/tos/platforms/mica2dot/VoltageDeviceP.nc
deleted file mode 100644 (file)
index f808109..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* $Id$
- * Copyright (c) 2006 Intel Corporation
- * All rights reserved.
- *
- * This file is distributed under the terms in the attached INTEL-LICENSE     
- * file. If you do not find these files, copies can be found by writing to
- * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
- * 94704.  Attention:  Intel License Inquiry.
- */
-/**
- * Internal component for voltage sensor. Arbitrates access to the voltage
- * sensor and automatically turns it on or off based on user requests.
- *
- * @author David Gay
- */
-
-#include "hardware.h"
-
-configuration VoltageDeviceP {
-  provides {
-    interface Atm128AdcConfig;
-    interface ResourceConfigure;
-  }
-}
-implementation {
-  components VoltageP, HplAtm128GeneralIOC as Pins;
-
-  Atm128AdcConfig = VoltageP;
-  ResourceConfigure = VoltageP;
-
-  VoltageP.BatMon -> Pins.PortC6;
-  VoltageP.BatMonRef -> Pins.PortC7;
-}
diff --git a/tos/platforms/mica2dot/VoltageP.nc b/tos/platforms/mica2dot/VoltageP.nc
deleted file mode 100644 (file)
index dc3884b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/// $Id$
-
-/*
- * Copyright (c) 2004-2005 Crossbow Technology, Inc.  All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- * 
- * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO 
- * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 
- * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 
- * DAMAGE. 
- *
- * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 
- * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY 
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 
- * MODIFICATIONS.
- */
-/**
- * Internal component for voltage sensor reading.
- *
- * @author Hu Siquan <husq@xbow.com>
- * @author David Gay
- */
-
-module VoltageP {
-  provides {
-    interface ResourceConfigure;
-    interface Atm128AdcConfig as VoltageConfig;
-  }
-  uses {
-    interface GeneralIO as BatMon;
-    interface GeneralIO as BatMonRef;
-  }
-}
-implementation {
-  async command uint8_t VoltageConfig.getChannel() {
-    return CHANNEL_BATTERY_THERMISTOR;
-  }
-
-  async command uint8_t VoltageConfig.getRefVoltage() {
-    return ATM128_ADC_VREF_OFF;
-  }
-
-  async command uint8_t VoltageConfig.getPrescaler() {
-    return ATM128_ADC_PRESCALE;
-  }
-
-  async command void ResourceConfigure.configure() {
-    call BatMonRef.makeOutput();
-    call BatMonRef.clr();
-    call BatMon.makeInput();
-    call BatMon.clr();
-  }
-
-  async command void ResourceConfigure.unconfigure() {
-    call BatMonRef.makeInput();
-  }
-}
index 28959a20dfaed1719acd4384eea732363f6b6316..05bae197ffbf1ba6f46e53ec652bfdbbfc504d84 100644 (file)
@@ -22,7 +22,7 @@ generic configuration DemoSensorC()
 }
 implementation
 {
-  components new SineSensorC() as DemoChannel;
+  components new VoltageC() as DemoChannel;
 
   Read = DemoChannel;
 }
index 47b2ad1d1bb0ef2c5bf60d7748400c996af58545..4e12bc93201a031ca991714a00df14ca5442e575 100644 (file)
@@ -20,7 +20,7 @@ generic configuration DemoSensorNowC()
   provides interface ReadNow<uint16_t>;
 }
 implementation {
-  components new AdcReadNowClientC() as Sensor;
+  components new VoltageNowC() as Sensor;
 
   Resource = Sensor;
   ReadNow = Sensor;
index 0849582b41db9625e8251ccdf98df1bd1290c684..8a190d433254d8d785c884cc36444c52c28231cb 100644 (file)
@@ -22,8 +22,7 @@ generic configuration DemoSensorStreamC()
 }
 implementation
 {
-  components new AdcReadStreamClientC();
+  components new VoltageStreamC() as Sensor;
 
-  // An unconfigure atm128 ReadStream sensor reads the "ground" channel.
-  ReadStream = AdcReadStreamClientC;
+  ReadStream = Sensor;
 }