]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/atm128/adc/Atm128AdcMultiple.nc
Convert to Unix-style line terminators.
[tinyos-2.x.git] / tos / chips / atm128 / adc / Atm128AdcMultiple.nc
index 8549eccb1a59fd47fea1fc22a7a81cfa813e3494..d886dddbc4399e8550aeaca8e568c465be3fa1b8 100644 (file)
-/// $Id$\r
-\r
-/*\r
- * Copyright (c) 2004-2005 Crossbow Technology, Inc.  All rights reserved.\r
- *\r
- * Permission to use, copy, modify, and distribute this software and its\r
- * documentation for any purpose, without fee, and without written agreement is\r
- * hereby granted, provided that the above copyright notice, the following\r
- * two paragraphs and the author appear in all copies of this software.\r
- * \r
- * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO \r
- * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL \r
- * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH \r
- * DAMAGE. \r
- *\r
- * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,\r
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY \r
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS \r
- * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY \r
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR \r
- * MODIFICATIONS.\r
- *\r
- * Copyright (c) 2002-2005 Intel Corporation\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached INTEL-LICENSE     \r
- * file. If you do not find these files, copies can be found by writing to\r
- * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, \r
- * 94704.  Attention:  Intel License Inquiry.\r
- */\r
-\r
-/**\r
- * Hardware Abstraction Layer interface of Atmega128 for acquiring data\r
- * from multiple channels using the ATmega128's free-running mode.\r
- * <p>\r
- * Because of the possibility that samples may be imprecise after \r
- * switching channels and/or reference voltages, and because there\r
- * is a one sample delay on swithcing channels and reference voltages,\r
- * Atm128ADCMultiple is complex. Two straightforward uses are:\r
- * <ol type="A">\r
- * <li>Acquire N samples from channel C:\r
- *    <ol>\r
- *    <li>call getData to start sampling on channel C at the desired rate\r
- *       (note that the choice of prescalers is very limited, so you\r
- *       don't have many choices for sampling rate)\r
- *    <li>ignore the first dataReady event\r
- *    <li>use the results of the next N dataReady() events, return FALSE\r
- *       on the last one\r
- *    </ol>\r
- * <li>Acquire one sample each from channels C1, ..., Cn (this pseudocode\r
- *    assumes that none of these channels are differential)\r
- *    <ol>\r
- *    <li>call getData to start sampling on channel C1\r
- *    <li>on the ith dataReady event switch to channel Ci+1 by changing\r
- *       *newChannel\r
- *    <li>the data passed to the ith dataReady event is for channel Ci-1\r
- *       (the data from the first dataReady event is ignored)\r
- *    </ol>\r
- * </ol>\r
- *\r
- * @author Hu Siquan <husq@xbow.com>\r
- * @author David Gay\r
- */        \r
-\r
-#include "Atm128Adc.h"\r
-\r
-interface Atm128AdcMultiple\r
-{\r
-  /**\r
-   * Initiates free-running ADC conversions, with the ability to switch \r
-   * channels and reference-voltage with a one sample delay.\r
-   *\r
-   * @param channel Initial A/D conversion channel. The channel can \r
-   *   be changed in the dataReady event, though these changes happen\r
-   *   with a one-sample delay (this is a hardware restriction).\r
-   * @param refVoltage Initial A/D reference voltage. See the\r
-   *   ATM128_ADC_VREF_xxx constants in Atm128ADC.h. Like the channel,\r
-   *   the reference voltage can be changed in the dataReady event with\r
-   *   a one-sample delay.\r
-   * @param leftJustify TRUE to place A/D result in high-order bits \r
-   *   (i.e., shifted left by 6 bits), low to place it in the low-order bits\r
-   * @param prescaler Prescaler value for the A/D conversion clock. If you \r
-   *  specify ATM128_ADC_PRESCALE, a prescaler will be chosen that guarantees\r
-   *  full precision. Other prescalers can be used to get faster conversions. \r
-   *  See the ATmega128 manual for details.\r
-   * @return TRUE if the conversion will be precise, FALSE if it will be \r
-   *   imprecise (due to a change in reference voltage, or switching to a\r
-   *   differential input channel)\r
-   */\r
-  async command bool getData(uint8_t channel, uint8_t refVoltage,\r
-                            bool leftJustify, uint8_t prescaler);\r
-  \r
-  /**\r
-   * Returns the next sample in a free-running conversion. Allow the user\r
-   * to switch channels and/or reference voltages with a one sample delay.\r
-   *\r
-   * @param data a 2 byte unsigned data value sampled by the ADC.\r
-   * @param precise if this conversion was precise, FALSE if it wasn't \r
-   *   (we assume that the second conversion after a change of reference\r
-   *   voltage or after switching to a differential channel is precise)\r
-   * @param channel Channel this sample was from.\r
-   * @param newChannel Change this parameter to switch to a new channel\r
-   *   for the second next sample.\r
-   * @param newRefVoltage Change this parameter to change the reference \r
-   *   voltage for the second next sample.\r
-   *\r
-   * @return TRUE to continue sampling, FALSE to stop.\r
-   */  \r
-  async event bool dataReady(uint16_t data, bool precise, uint8_t channel,\r
-                            uint8_t *newChannel, uint8_t *newRefVoltage);\r
-\r
-\r
-  /* Note: there is no cancel in free-running mode because you cannot tell\r
-     from a successful (or unsuccessful) cancellation whether there will\r
-     be another dataReady event. Thus you cannot tell when you can safely\r
-     reuse the ADC (short of waiting one ADC conversion period, in which\r
-     case you might as well use the result of dataReady to cancel).\r
-  */\r
-}\r
+/// $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.
+ *
+ * Copyright (c) 2002-2005 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.
+ */
+
+/**
+ * Hardware Abstraction Layer interface of Atmega128 for acquiring data
+ * from multiple channels using the ATmega128's free-running mode.
+ * <p>
+ * Because of the possibility that samples may be imprecise after 
+ * switching channels and/or reference voltages, and because there
+ * is a one sample delay on swithcing channels and reference voltages,
+ * Atm128ADCMultiple is complex. Two straightforward uses are:
+ * <ol type="A">
+ * <li>Acquire N samples from channel C:
+ *    <ol>
+ *    <li>call getData to start sampling on channel C at the desired rate
+ *       (note that the choice of prescalers is very limited, so you
+ *       don't have many choices for sampling rate)
+ *    <li>ignore the first dataReady event
+ *    <li>use the results of the next N dataReady() events, return FALSE
+ *       on the last one
+ *    </ol>
+ * <li>Acquire one sample each from channels C1, ..., Cn (this pseudocode
+ *    assumes that none of these channels are differential)
+ *    <ol>
+ *    <li>call getData to start sampling on channel C1
+ *    <li>on the ith dataReady event switch to channel Ci+1 by changing
+ *       *newChannel
+ *    <li>the data passed to the ith dataReady event is for channel Ci-1
+ *       (the data from the first dataReady event is ignored)
+ *    </ol>
+ * </ol>
+ *
+ * @author Hu Siquan <husq@xbow.com>
+ * @author David Gay
+ */        
+
+#include "Atm128Adc.h"
+
+interface Atm128AdcMultiple
+{
+  /**
+   * Initiates free-running ADC conversions, with the ability to switch 
+   * channels and reference-voltage with a one sample delay.
+   *
+   * @param channel Initial A/D conversion channel. The channel can 
+   *   be changed in the dataReady event, though these changes happen
+   *   with a one-sample delay (this is a hardware restriction).
+   * @param refVoltage Initial A/D reference voltage. See the
+   *   ATM128_ADC_VREF_xxx constants in Atm128ADC.h. Like the channel,
+   *   the reference voltage can be changed in the dataReady event with
+   *   a one-sample delay.
+   * @param leftJustify TRUE to place A/D result in high-order bits 
+   *   (i.e., shifted left by 6 bits), low to place it in the low-order bits
+   * @param prescaler Prescaler value for the A/D conversion clock. If you 
+   *  specify ATM128_ADC_PRESCALE, a prescaler will be chosen that guarantees
+   *  full precision. Other prescalers can be used to get faster conversions. 
+   *  See the ATmega128 manual for details.
+   * @return TRUE if the conversion will be precise, FALSE if it will be 
+   *   imprecise (due to a change in reference voltage, or switching to a
+   *   differential input channel)
+   */
+  async command bool getData(uint8_t channel, uint8_t refVoltage,
+                            bool leftJustify, uint8_t prescaler);
+  
+  /**
+   * Returns the next sample in a free-running conversion. Allow the user
+   * to switch channels and/or reference voltages with a one sample delay.
+   *
+   * @param data a 2 byte unsigned data value sampled by the ADC.
+   * @param precise if this conversion was precise, FALSE if it wasn't 
+   *   (we assume that the second conversion after a change of reference
+   *   voltage or after switching to a differential channel is precise)
+   * @param channel Channel this sample was from.
+   * @param newChannel Change this parameter to switch to a new channel
+   *   for the second next sample.
+   * @param newRefVoltage Change this parameter to change the reference 
+   *   voltage for the second next sample.
+   *
+   * @return TRUE to continue sampling, FALSE to stop.
+   */  
+  async event bool dataReady(uint16_t data, bool precise, uint8_t channel,
+                            uint8_t *newChannel, uint8_t *newRefVoltage);
+
+
+  /* Note: there is no cancel in free-running mode because you cannot tell
+     from a successful (or unsuccessful) cancellation whether there will
+     be another dataReady event. Thus you cannot tell when you can safely
+     reuse the ADC (short of waiting one ADC conversion period, in which
+     case you might as well use the result of dataReady to cancel).
+  */
+}