Razvan Musaloiu-E.
--- /dev/null
+/**\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
--- /dev/null
+/* $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;
+}
--- /dev/null
+/**\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
--- /dev/null
+/* $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;
+}
+++ /dev/null
-/* $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;
-}
+++ /dev/null
-/* $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;
-}
+++ /dev/null
-/* $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;
-}
+++ /dev/null
-/// $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();
- }
-}
+++ /dev/null
-/* $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;
-}
+++ /dev/null
-/* $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;
-}
+++ /dev/null
-/// $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();
- }
-}
}
implementation
{
- components new SineSensorC() as DemoChannel;
+ components new VoltageC() as DemoChannel;
Read = DemoChannel;
}
provides interface ReadNow<uint16_t>;
}
implementation {
- components new AdcReadNowClientC() as Sensor;
+ components new VoltageNowC() as Sensor;
Resource = Sensor;
ReadNow = Sensor;
}
implementation
{
- components new AdcReadStreamClientC();
+ components new VoltageStreamC() as Sensor;
- // An unconfigure atm128 ReadStream sensor reads the "ground" channel.
- ReadStream = AdcReadStreamClientC;
+ ReadStream = Sensor;
}