]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Add mic and mag driver .
authorpipeng <pipeng>
Thu, 15 Feb 2007 10:33:37 +0000 (10:33 +0000)
committerpipeng <pipeng>
Thu, 15 Feb 2007 10:33:37 +0000 (10:33 +0000)
12 files changed:
tos/sensorboards/mts300/AccelC.nc [new file with mode: 0644]
tos/sensorboards/mts300/Mag.nc [new file with mode: 0644]
tos/sensorboards/mts300/MagC.nc [new file with mode: 0644]
tos/sensorboards/mts300/MagConfigP.nc [new file with mode: 0644]
tos/sensorboards/mts300/MagP.nc [new file with mode: 0644]
tos/sensorboards/mts300/Mic.nc [new file with mode: 0644]
tos/sensorboards/mts300/MicC.nc [new file with mode: 0644]
tos/sensorboards/mts300/MicDeviceP.nc [new file with mode: 0644]
tos/sensorboards/mts300/MicInterrupt.nc [new file with mode: 0644]
tos/sensorboards/mts300/MicP.nc [new file with mode: 0644]
tos/sensorboards/mts300/PhotoTempDeviceP.nc [new file with mode: 0644]
tos/sensorboards/mts300/TempC.nc [new file with mode: 0644]

diff --git a/tos/sensorboards/mts300/AccelC.nc b/tos/sensorboards/mts300/AccelC.nc
new file mode 100644 (file)
index 0000000..00102ab
--- /dev/null
@@ -0,0 +1,57 @@
+// $Id$\r
+\r
+/*                                                                     tab:4\r
+ * "Copyright (c) 2000-2003 The Regents of the University  of California.\r
+ * 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 THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\r
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT\r
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF\r
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO\r
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."\r
+ *\r
+ * Copyright (c) 2002-2003 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
+#include "mts300.h"\r
+\r
+generic configuration AccelC ()\r
+{\r
+  provides interface Init;\r
+  provides interface StdControl;\r
+  provides interface Read<uint16_t> as AccelX;\r
+  provides interface Read<uint16_t> as AccelY;\r
+}\r
+implementation\r
+{\r
+  components AccelConfigP,\r
+    new AdcReadClientC() as AdcX,\r
+    new AdcReadClientC() as AdcY;\r
+\r
+  Init = AccelConfigP;\r
+       StdControl = AccelConfigP;\r
+\r
+  AccelX = AdcX;\r
+  AdcX.Atm128AdcConfig -> AccelConfigP.ConfigX;\r
+  AdcX.ResourceConfigure -> AccelConfigP.ResourceX;\r
+\r
+  AccelY = AdcY;\r
+  AdcY.Atm128AdcConfig -> AccelConfigP.ConfigY;\r
+  AdcY.ResourceConfigure -> AccelConfigP.ResourceY;\r
+}\r
+\r
diff --git a/tos/sensorboards/mts300/Mag.nc b/tos/sensorboards/mts300/Mag.nc
new file mode 100644 (file)
index 0000000..676e634
--- /dev/null
@@ -0,0 +1,71 @@
+// $Id$\r
+\r
+/*                                                                     tab:4\r
+ * "Copyright (c) 2000-2003 The Regents of the University  of California.  \r
+ * 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 THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\r
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT\r
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF\r
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * \r
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO\r
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."\r
+ *\r
+ * Copyright (c) 2002-2003 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
+ * Authors:             Alec Woo\r
+ * Date lase modified:  8/20/02\r
+ *\r
+ * The MagSetting inteface provides an asynchronous mechanism for\r
+ * setting the gain offset for the Magnetometer on the mica sensorboard.\r
+ * This is particularly useful in calibrating the offset of the Magnetometer\r
+ * such that X and Y axis can stay in the center for idle signals.  \r
+ * If not calibrated, the data you get may rail.  (railing means\r
+ * the data either stays at the maximum (~785) or minimum (~240)). \r
+ *\r
+ * The gain adjust has 256 steps ranging from 0 to 255.\r
+ *\r
+ */\r
+\r
+/**\r
+ * @author Alec Woo\r
+ */\r
+\r
+interface Mag {\r
+  /* Effects:  adjust pot setting on the X axis of the magnetometer.\r
+   * Returns:  return SUCCESS of FAILED.\r
+   */\r
+  command error_t gainAdjustX(uint8_t val);\r
+\r
+  /* Effects:  adjust pot setting on the Y axis of the magnetometer.\r
+   * Returns:  return SUCCESS of FAILED.\r
+   */\r
+  command error_t gainAdjustY(uint8_t val);\r
+\r
+  /* Pot adjustment on the X axis of the magnetometer is finished.\r
+   * Returns:  return SUCCESS.\r
+   */\r
+  event error_t gainAdjustXDone(bool result);\r
+\r
+  /* Pot adjustment on the Y axis of the magnetometer is finished.\r
+   * Returns:  return SUCCESS.\r
+   */\r
+  event error_t gainAdjustYDone(bool result);\r
+}\r
diff --git a/tos/sensorboards/mts300/MagC.nc b/tos/sensorboards/mts300/MagC.nc
new file mode 100644 (file)
index 0000000..0945d43
--- /dev/null
@@ -0,0 +1,59 @@
+// $Id$\r
+\r
+/*                                                                     tab:4\r
+ * "Copyright (c) 2000-2003 The Regents of the University  of California.\r
+ * 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 THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\r
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT\r
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF\r
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO\r
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."\r
+ *\r
+ * Copyright (c) 2002-2003 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
+#include "mts300.h"\r
+\r
+generic configuration MagC ()\r
+{\r
+  provides interface Init;\r
+  provides interface StdControl;\r
+  provides interface Read<uint16_t> as MagX;\r
+  provides interface Read<uint16_t> as MagY;\r
+  provides interface Mag;\r
+}\r
+implementation\r
+{\r
+  components MagConfigP,\r
+    new AdcReadClientC() as AdcX,\r
+    new AdcReadClientC() as AdcY;\r
+\r
+  Init = MagConfigP;\r
+       StdControl = MagConfigP;\r
+  Mag = MagConfigP;\r
+\r
+  MagX = AdcX;\r
+  AdcX.Atm128AdcConfig -> MagConfigP.ConfigX;\r
+  AdcX.ResourceConfigure -> MagConfigP.ResourceX;\r
+\r
+  MagY = AdcY;\r
+  AdcY.Atm128AdcConfig -> MagConfigP.ConfigY;\r
+  AdcY.ResourceConfigure -> MagConfigP.ResourceY;\r
+}\r
+\r
diff --git a/tos/sensorboards/mts300/MagConfigP.nc b/tos/sensorboards/mts300/MagConfigP.nc
new file mode 100644 (file)
index 0000000..6f44f72
--- /dev/null
@@ -0,0 +1,50 @@
+/* $Id$\r
+ * Copyright (c) 2006 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
+ * Internal component for basicsb photodiode. Arbitrates access to the photo\r
+ * diode and automatically turns it on or off based on user requests.\r
+ *\r
+ * @author David Gay\r
+ */\r
+\r
+#include "mts300.h"\r
+#include "I2C.h"\r
+\r
+configuration MagConfigP {\r
+  provides {\r
+    interface Init;\r
+    interface StdControl;\r
+    interface Mag;\r
+\r
+    interface Atm128AdcConfig as ConfigX;\r
+    interface Atm128AdcConfig as ConfigY;\r
+    interface ResourceConfigure as ResourceX;\r
+    interface ResourceConfigure as ResourceY;\r
+  }\r
+}\r
+implementation {\r
+  components MagP, MicaBusC, new Atm128I2CMasterC() as I2CPot;\r
+\r
+       Init = MagP;\r
+       StdControl = MagP;\r
+       Mag = MagP;\r
+\r
+  ConfigX = MagP.ConfigX;\r
+  ConfigY = MagP.ConfigY;\r
+  ResourceX = MagP.ResourceX;\r
+  ResourceY = MagP.ResourceY;\r
+\r
+  MagP.I2CPacket -> I2CPot;\r
+  MagP.Resource -> I2CPot;\r
+\r
+  MagP.MagPower -> MicaBusC.PW5;\r
+  MagP.MagAdcX -> MicaBusC.Adc6;\r
+  MagP.MagAdcY -> MicaBusC.Adc5;\r
+}\r
diff --git a/tos/sensorboards/mts300/MagP.nc b/tos/sensorboards/mts300/MagP.nc
new file mode 100644 (file)
index 0000000..a2fe23d
--- /dev/null
@@ -0,0 +1,122 @@
+#include "mts300.h"\r
+#include "Timer.h"\r
+#include "I2C.h"\r
+\r
+module MagP\r
+{\r
+  provides interface Init;\r
+  provides interface StdControl;\r
+  provides interface Mag;\r
+  provides interface Atm128AdcConfig as ConfigX;\r
+  provides interface Atm128AdcConfig as ConfigY;\r
+  provides interface ResourceConfigure as ResourceX;\r
+  provides interface ResourceConfigure as ResourceY;\r
+\r
+       uses interface GeneralIO as MagPower;\r
+       uses interface MicaBusAdc as MagAdcX;\r
+       uses interface MicaBusAdc as MagAdcY;\r
+  uses interface I2CPacket<TI2CBasicAddr>;\r
+  uses interface Resource;\r
+}\r
+\r
+implementation\r
+{\r
+  uint8_t gainData[2];\r
+\r
+  command error_t Init.init()\r
+  {\r
+    call MagPower.makeOutput();\r
+               call MagPower.clr();\r
+\r
+    return SUCCESS;\r
+       }\r
+\r
+  command error_t StdControl.start()\r
+  {\r
+    call MagPower.set();\r
+    return SUCCESS;\r
+  }\r
+\r
+  command error_t StdControl.stop()\r
+  {\r
+    call MagPower.clr();\r
+    call MagPower.makeInput();\r
+\r
+    return SUCCESS;\r
+  }\r
+\r
+  command error_t Mag.gainAdjustX(uint8_t val)\r
+  {\r
+    gainData[0] = 1;    // pot subaddr\r
+    gainData[1] = val;  // value to write\r
+    return call Resource.request();\r
+  }\r
+  command error_t Mag.gainAdjustY(uint8_t val)\r
+  {\r
+    gainData[0] = 0;    // pot subaddr\r
+    gainData[1] = val;  // value to write\r
+    return call Resource.request();\r
+  }\r
+  /**\r
+  * Resource request\r
+  *\r
+  */\r
+  event void Resource.granted()\r
+  {\r
+    if ( call I2CPacket.write(0x3,TOS_MAG_POT_ADDR, 2, gainData) == SUCCESS)\r
+    {\r
+      return ;\r
+    }\r
+  }\r
+  /**\r
+  * I2CPot2\r
+  *\r
+  */\r
+  async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)\r
+  {\r
+    return ;\r
+  }\r
+\r
+  async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)\r
+  {\r
+    call Resource.release();\r
+    if (gainData[0] ==1)\r
+    {\r
+      signal Mag.gainAdjustXDone(error);\r
+    }\r
+    if (gainData[0] ==0)\r
+    {\r
+      signal Mag.gainAdjustYDone(error);\r
+    }\r
+    return ;\r
+  }\r
+\r
+  async command uint8_t ConfigX.getChannel() {\r
+    return call MagAdcX.getChannel();\r
+  }\r
+\r
+  async command uint8_t ConfigX.getRefVoltage() {\r
+    return ATM128_ADC_VREF_OFF;\r
+  }\r
+\r
+  async command uint8_t ConfigX.getPrescaler() {\r
+    return ATM128_ADC_PRESCALE;\r
+  }\r
+\r
+  async command uint8_t ConfigY.getChannel() {\r
+    return call MagAdcY.getChannel();\r
+  }\r
+\r
+  async command uint8_t ConfigY.getRefVoltage() {\r
+    return ATM128_ADC_VREF_OFF;\r
+  }\r
+\r
+  async command uint8_t ConfigY.getPrescaler() {\r
+    return ATM128_ADC_PRESCALE;\r
+  }\r
+\r
+  async command void ResourceX.configure() { }  \r
+  async command void ResourceX.unconfigure() { } \r
+  async command void ResourceY.configure() { }  \r
+  async command void ResourceY.unconfigure() {}\r
+}
\ No newline at end of file
diff --git a/tos/sensorboards/mts300/Mic.nc b/tos/sensorboards/mts300/Mic.nc
new file mode 100644 (file)
index 0000000..8c68a64
--- /dev/null
@@ -0,0 +1,72 @@
+// $Id$
+
+/*                                                                     tab:4
+ * "Copyright (c) 2000-2003 The Regents of the University  of California.  
+ * 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 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.
+ */
+
+/*
+ * Authors:            Alec Woo
+ * Date last modified:  8/20/02
+ * 
+ * The microphone on the mica sensor board has two methods for control and
+ * one method to read the binary output of the tone detector.  (Note:  The tone
+ * detector's binary output can be configured as an interrupt.  Please see MicInterrupt.ti)
+ *
+ * muxSel allows users to switch the ADC to sample from phase lock loop output of
+ * the tone detector (by setting the value to 0 (default))  or the raw voice-band output 
+ * of the micrphone (by setting the value to 1).
+ *
+ * gainAdjust allows users to adjust the amplification gain on the microphone. The range
+ * is 0 to 255 with 0 being the minmum and 255 being the maximum amplification.  Note that
+ * setting amplification too high can result in clipping (signal distortion).
+ *
+ * If an audio signal at 4.3kHz is picked up by the microphone, the tone
+ * detect will decode it and generate a binary ouput (0 meaning tone is detected, 1 meaning
+ * tone is not detected).  Users can read this output simply by calling readToneDetector().
+ *
+ */
+
+/**
+ * @author Alec Woo
+ */
+
+interface Mic {
+  /* Effect:  Set the multiplexer's setting on the microphone
+   * Return:  returns SUCCESS or FAIL
+   */
+  command error_t muxSel(uint8_t sel);
+  /* Effect:  Set the amplificatoin gain  on the microphone
+   * Return:  returns SUCCESS or FAIL
+   */
+  command error_t gainAdjust(uint8_t val);
+
+  /* Effect:  returns the binary tone detector's output
+   * Return:  0 meaning tone is detected, 1 meanning tone is not detected
+   */
+  command uint8_t readToneDetector();
+}
diff --git a/tos/sensorboards/mts300/MicC.nc b/tos/sensorboards/mts300/MicC.nc
new file mode 100644 (file)
index 0000000..0d096d3
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ *  Copyright (c) 2005-2006 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 (updated) modification history and the author appear in
+ *  all copies of this source code.
+ *
+ *  Permission is also granted to distribute this software under the
+ *  standard BSD license as contained in the TinyOS distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
+ *  OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ *  THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ /*
+ *  @author Hu Siquan <husq@xbow.com>
+ *
+ *  $Id$
+ */
+
+#include "mts300.h"
+
+generic configuration MicC() {
+  provides interface Init;
+  provides interface StdControl;
+  provides interface Read<uint16_t>;
+  provides interface Mic;
+  provides interface MicInterrupt;
+}
+implementation {
+  components new AdcReadClientC(), MicDeviceP;
+
+  Init = MicDeviceP;
+       StdControl = MicDeviceP;
+  Read = AdcReadClientC;
+  Mic = MicDeviceP;
+  MicInterrupt = MicDeviceP;
+  AdcReadClientC.Atm128AdcConfig -> MicDeviceP;
+  AdcReadClientC.ResourceConfigure -> MicDeviceP;
+}
diff --git a/tos/sensorboards/mts300/MicDeviceP.nc b/tos/sensorboards/mts300/MicDeviceP.nc
new file mode 100644 (file)
index 0000000..f2f3754
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ *  Copyright (c) 2005-2006 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 (updated) modification history and the author appear in
+ *  all copies of this source code.
+ *
+ *  Permission is also granted to distribute this software under the
+ *  standard BSD license as contained in the TinyOS distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
+ *  OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ *  THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  @author Hu Siquan <husq@xbow.com>
+ *
+ *  $Id$
+ */
+
+#include "mts300.h"
+#include "I2C.h"
+configuration MicDeviceP {
+  provides {
+    interface Init;
+    interface StdControl;
+    interface Mic;
+    interface MicInterrupt;
+    interface ResourceConfigure;
+    interface Atm128AdcConfig;
+  }
+}
+implementation {
+  components MicP, MicaBusC, HplAtm128GeneralIOC as Pins,
+      HplAtm128InterruptC as IntPins, LedsC, NoLedsC,
+               new Atm128I2CMasterC() as I2CPot;
+
+       Init = MicP;
+       StdControl = MicP;
+       ResourceConfigure = MicP;
+       Atm128AdcConfig = MicP;
+       Mic = MicP;
+       MicInterrupt = MicP;
+
+  MicP.MicPower  -> MicaBusC.PW3;
+  MicP.MicMuxSel -> MicaBusC.PW6;
+  MicP.MicAdc -> MicaBusC.Adc2;
+  MicP.I2CPacket -> I2CPot;
+  MicP.Resource -> I2CPot;
+  MicP.AlertInterrupt -> IntPins.Int7;
+  MicP.DebugLeds -> NoLedsC;
+}
diff --git a/tos/sensorboards/mts300/MicInterrupt.nc b/tos/sensorboards/mts300/MicInterrupt.nc
new file mode 100644 (file)
index 0000000..780f70c
--- /dev/null
@@ -0,0 +1,67 @@
+// $Id$
+
+/*                                                                     tab:4
+ * "Copyright (c) 2000-2003 The Regents of the University  of California.  
+ * 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 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.
+ */
+/*
+ * Authors:            Alec Woo
+ * Date last modified:  8/20/02
+ * 
+ * The microphone on the mica sensor board has the tone detector interrupt.
+ * If an audio signal at 4.3kHz is picked up by the microphone, the tone
+ * detect will decode it and generate a toneDetected interrupt if the
+ * interrupt is enabled.
+ *
+ */
+
+/**
+ * @author Alec Woo
+ */
+
+
+
+interface MicInterrupt
+{
+  /* Effects: disable interrupts
+     Returns: SUCCESS
+  */
+  async command error_t disable();
+
+  /* Effects: enable interrupts
+     Returns: SUCCESS
+  */
+  async command error_t enable();
+
+  /* Interrupt signal for tone detected.  Note that MicInterrupt is automatically disabled
+   * before this event is signaled.  (Upper layer needs to reenable this interrupt for future
+   * tone detect.
+   *
+   *  Returns: SUCCESS
+   */
+  async event error_t toneDetected();
+}
diff --git a/tos/sensorboards/mts300/MicP.nc b/tos/sensorboards/mts300/MicP.nc
new file mode 100644 (file)
index 0000000..24e3747
--- /dev/null
@@ -0,0 +1,201 @@
+/**
+ *  Copyright (c) 2005-2006 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 (updated) modification history and the author appear in
+ *  all copies of this source code.
+ *
+ *  Permission is also granted to distribute this software under the
+ *  standard BSD license as contained in the TinyOS distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS 
+ *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, 
+ *  OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
+ *  THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  @author Hu Siquan <husq@xbow.com> 
+ *
+ *  $Id$
+ */
+
+#include "Timer.h"
+#include "I2C.h"
+
+module MicP
+{
+  provides interface Init;
+  provides interface StdControl;
+  provides interface Mic;
+  provides interface MicInterrupt;
+  provides interface ResourceConfigure as MicResourceConfigure;
+  provides interface Atm128AdcConfig as MicAtm128AdcConfig;
+
+  uses interface Leds as DebugLeds;
+       uses interface GeneralIO as MicPower;
+       uses interface GeneralIO as MicMuxSel;
+       uses interface MicaBusAdc as MicAdc;
+  uses interface I2CPacket<TI2CBasicAddr>;
+  uses interface Resource;
+  uses interface HplAtm128Interrupt as AlertInterrupt;
+}
+implementation 
+{
+  uint8_t gainData[2];
+  
+  command error_t Init.init()
+  {
+    call MicPower.makeOutput();
+               call MicPower.clr();
+               call MicMuxSel.makeOutput();    
+               call MicMuxSel.clr();
+                               
+    call AlertInterrupt.disable();
+    return SUCCESS;
+       }
+
+  command error_t StdControl.start()
+  {
+    call MicPower.set();
+    return SUCCESS;
+  }
+  
+  command error_t StdControl.stop()
+  {
+    call AlertInterrupt.disable();
+    call MicPower.clr();
+    call MicPower.makeInput();
+
+    return SUCCESS;
+  }
+  
+  /**
+  * Resource request
+  * 
+  */  
+  event void Resource.granted()
+  {
+    call DebugLeds.led0Off();
+    if ( call I2CPacket.write(0x3,TOS_MIC_POT_ADDR, 2, gainData) == SUCCESS)
+    {
+      call DebugLeds.led1On();
+    };
+  }
+
+  /**
+  * mic control
+  * 
+  */  
+  command error_t Mic.muxSel(uint8_t sel)
+  {
+    if (sel == 0)
+    {
+      call MicMuxSel.clr();
+      return SUCCESS;
+    }
+    else if (sel == 1)
+    {
+      call MicMuxSel.set();
+      return SUCCESS;
+    }
+    return FAIL;
+  }
+  
+  command error_t Mic.gainAdjust(uint8_t val)
+  {
+    call DebugLeds.led0On();
+    gainData[0] = 0;    // pot subaddr
+    gainData[1] = val;  // value to write
+    return call Resource.request();
+  }
+  
+  command uint8_t Mic.readToneDetector()
+  {
+    bool bVal = call AlertInterrupt.getValue();
+    return bVal ? 1 : 0;
+  }
+  
+  /**
+  * mic interrupt control
+  * 
+  */
+  async command error_t MicInterrupt.enable()
+  {
+    call AlertInterrupt.enable();
+    return SUCCESS;
+  }
+  
+  async command error_t MicInterrupt.disable()
+  {
+    call AlertInterrupt.disable();
+    return SUCCESS;
+  }
+
+  default async event error_t MicInterrupt.toneDetected()
+  {
+    return SUCCESS;
+  }
+  
+  async event void AlertInterrupt.fired()
+  {
+    signal MicInterrupt.toneDetected();
+  }
+  
+  /**
+  *
+  *
+  */
+  
+  async command uint8_t MicAtm128AdcConfig.getChannel() 
+  {
+    return call MicAdc.getChannel();
+  }
+  
+  async command uint8_t MicAtm128AdcConfig.getRefVoltage() 
+  {
+    return ATM128_ADC_VREF_OFF;
+  }
+  
+  async command uint8_t MicAtm128AdcConfig.getPrescaler() 
+  {
+    return ATM128_ADC_PRESCALE;
+  }
+  
+  async command void MicResourceConfigure.configure() 
+  {
+       call MicPower.set();
+  }
+  
+  async command void MicResourceConfigure.unconfigure() 
+  {
+//    call MicPower.clr();
+  }  
+  /**
+  * I2CPot2
+  * 
+  */
+  async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
+  {
+    return ;
+  }
+  
+  async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
+  {
+    call DebugLeds.led1Off();
+    call Resource.release();
+    return ;
+  }
+}
+
+
+
+
+
diff --git a/tos/sensorboards/mts300/PhotoTempDeviceP.nc b/tos/sensorboards/mts300/PhotoTempDeviceP.nc
new file mode 100644 (file)
index 0000000..9678df5
--- /dev/null
@@ -0,0 +1,51 @@
+/* $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 basicsb photodiode. Arbitrates access to the photo
+ * diode and automatically turns it on or off based on user requests.
+ * 
+ * @author David Gay
+ */
+
+#include "mts300.h"
+
+configuration PhotoTempDeviceP 
+{
+  provides 
+  {
+    interface Init;
+    interface StdControl;
+    interface ResourceConfigure as PhotoResourceConfigure;
+    interface Atm128AdcConfig as PhotoAtm128AdcConfig;
+    interface ResourceConfigure as TempResourceConfigure;
+    interface Atm128AdcConfig as TempAtm128AdcConfig;    
+  }
+}
+implementation 
+{
+  components PhotoTempP, MicaBusC, HplAtm128GeneralIOC as Pins;
+//  components new FcfsArbiterC(MTS3X0_PHOTO_TEMP) as Arbiter;  
+  components LedsC, NoLedsC;
+  
+  Init = PhotoTempP;
+  StdControl = PhotoTempP;
+
+  PhotoResourceConfigure = PhotoTempP.PhotoResourceConfigure;
+  PhotoAtm128AdcConfig   = PhotoTempP.PhotoAtm128AdcConfig;
+
+  TempResourceConfigure  = PhotoTempP.TempResourceConfigure;
+  TempAtm128AdcConfig    = PhotoTempP.TempAtm128AdcConfig;
+
+  PhotoTempP.LightPower  -> Pins.PortE5;
+  PhotoTempP.TempPower   -> Pins.PortE6;
+  PhotoTempP.SensorAdc -> MicaBusC.Adc1;
+  
+  DEBUG_LEDS(PhotoTempP);
+}
diff --git a/tos/sensorboards/mts300/TempC.nc b/tos/sensorboards/mts300/TempC.nc
new file mode 100644 (file)
index 0000000..7dc6ad6
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ *  Copyright (c) 2005-2006 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 (updated) modification history and the author appear in
+ *  all copies of this source code.
+ *
+ *  Permission is also granted to distribute this software under the
+ *  standard BSD license as contained in the TinyOS distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS 
+ *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, 
+ *  OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
+ *  THE POSSIBILITY OF SUCH DAMAGE.
+ */ 
+ /*
+ *  @author Hu Siquan <husq@xbow.com>
+ *
+ *  $Id$
+ */
+
+#include "mts300.h"
+
+generic configuration TempC() {
+  provides interface Read<uint16_t>;
+}
+implementation {
+  components new AdcReadClientC(), PhotoTempDeviceP;
+
+  Read = AdcReadClientC;
+  AdcReadClientC.Atm128AdcConfig -> PhotoTempDeviceP.TempAtm128AdcConfig;
+  AdcReadClientC.ResourceConfigure -> PhotoTempDeviceP.TempResourceConfigure;
+}