]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Change to follow TEP 109 .
authorpipeng <pipeng>
Wed, 14 Mar 2007 03:25:05 +0000 (03:25 +0000)
committerpipeng <pipeng>
Wed, 14 Mar 2007 03:25:05 +0000 (03:25 +0000)
14 files changed:
tos/sensorboards/mts300/AccelConfigP.nc
tos/sensorboards/mts300/AccelP.nc
tos/sensorboards/mts300/MagConfigP.nc
tos/sensorboards/mts300/MagP.nc
tos/sensorboards/mts300/MicC.nc
tos/sensorboards/mts300/MicDeviceP.nc
tos/sensorboards/mts300/MicP.nc
tos/sensorboards/mts300/PhotoC.nc
tos/sensorboards/mts300/PhotoTempP.nc
tos/sensorboards/mts300/SensorMts300C.nc
tos/sensorboards/mts300/SounderC.nc
tos/sensorboards/mts300/SounderP.nc
tos/sensorboards/mts300/TempC.nc
tos/sensorboards/mts300/mts300.h

index 6005babd16224bf14e73c2d248165e854668f092..d55464115c1dac10d5428359b6fda0fdac8c59ad 100644 (file)
@@ -1,44 +1,41 @@
-/* $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
-\r
-configuration AccelConfigP {\r
-  provides {\r
-    interface Init;\r
-    interface StdControl;\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 AccelP, MicaBusC;\r
-\r
-       Init = AccelP;\r
-       StdControl = AccelP;\r
-\r
-  ConfigX = AccelP.ConfigX;\r
-  ConfigY = AccelP.ConfigY;\r
-  ResourceX = AccelP.ResourceX;\r
-  ResourceY = AccelP.ResourceY;\r
-\r
-  AccelP.AccelPower -> MicaBusC.PW4;\r
-  AccelP.AccelAdcX -> MicaBusC.Adc3;\r
-  AccelP.AccelAdcY -> MicaBusC.Adc4;\r
-}\r
+/* $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
+ */
+
+configuration AccelConfigP { 
+  provides {
+    interface Resource[uint8_t client];
+    interface Atm128AdcConfig as ConfigX;
+    interface Atm128AdcConfig as ConfigY;
+  }
+}
+implementation {
+  components AccelP, MicaBusC, new TimerMilliC() as WarmupTimer,
+    new RoundRobinArbiterC(UQ_ACCEL_RESOURCE) as Arbiter,
+    new SplitControlPowerManagerC() as PowerManager;
+
+  Resource = Arbiter;
+  ConfigX = AccelP.ConfigX;
+  ConfigY = AccelP.ConfigY;
+
+  PowerManager.ResourceDefaultOwner -> Arbiter;
+  PowerManager.ArbiterInfo -> Arbiter;
+  PowerManager.SplitControl -> AccelP;
+
+  AccelP.Timer -> WarmupTimer;
+  AccelP.AccelPin -> MicaBusC.PW4;
+  AccelP.AccelAdcX -> MicaBusC.Adc3;
+  AccelP.AccelAdcY -> MicaBusC.Adc4;
+}
index cfe5c59720cfd87a3aa28cd47427926bc9238b92..c3742a7857d64080b00caad210faff0caa2cc914 100644 (file)
@@ -1,71 +1,76 @@
-#include "mts300.h"\r
-#include "Timer.h"\r
-\r
-module AccelP\r
-{\r
-  provides interface Init;\r
-  provides interface StdControl;\r
-\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 AccelPower;\r
-       uses interface MicaBusAdc as AccelAdcX;\r
-       uses interface MicaBusAdc as AccelAdcY;\r
-}\r
-\r
-implementation\r
-{\r
-  command error_t Init.init()\r
-  {\r
-    call AccelPower.makeOutput();\r
-               call AccelPower.clr();\r
-\r
-    return SUCCESS;\r
-       }\r
-\r
-  command error_t StdControl.start()\r
-  {\r
-    call AccelPower.set();\r
-    return SUCCESS;\r
-  }\r
-\r
-  command error_t StdControl.stop()\r
-  {\r
-    call AccelPower.clr();\r
-    call AccelPower.makeInput();\r
-\r
-    return SUCCESS;\r
-  }\r
-\r
-  async command uint8_t ConfigX.getChannel() {\r
-    return call AccelAdcX.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 AccelAdcY.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
+/* $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.
+ */
+/**
+ * ADXL202JE accelerometer ADC configuration and power management.
+ * @author David Gay <david.e.gay@intel.com>
+ */
+module AccelP
+{
+  provides {
+    interface SplitControl;
+    interface Atm128AdcConfig as ConfigX;
+    interface Atm128AdcConfig as ConfigY;
+  }
+  uses {
+    interface Timer<TMilli>;
+    interface GeneralIO as AccelPin;
+    interface MicaBusAdc as AccelAdcX;
+    interface MicaBusAdc as AccelAdcY;
+  }
+}
+implementation
+{
+  async command uint8_t ConfigX.getChannel() {
+    return call AccelAdcX.getChannel();
+  }
+
+  async command uint8_t ConfigX.getRefVoltage() {
+    return ATM128_ADC_VREF_OFF;
+  }
+
+  async command uint8_t ConfigX.getPrescaler() {
+    return ATM128_ADC_PRESCALE;
+  }
+
+  async command uint8_t ConfigY.getChannel() {
+    return call AccelAdcY.getChannel();
+  }
+
+  async command uint8_t ConfigY.getRefVoltage() {
+    return ATM128_ADC_VREF_OFF;
+  }
+
+  async command uint8_t ConfigY.getPrescaler() {
+    return ATM128_ADC_PRESCALE;
+  }
+
+  command error_t SplitControl.start() {
+    call AccelPin.makeOutput();
+    call AccelPin.set();
+    /* Startup time is 16.3ms for 0.1uF capacitors,
+       according to the ADXL202E data sheet */
+    call Timer.startOneShot(17); 
+    return SUCCESS;
+  }
+
+  event void Timer.fired() {
+    signal SplitControl.startDone(SUCCESS);
+  }
+
+  task void stopDone() {
+    call AccelPin.clr();
+    signal SplitControl.stopDone(SUCCESS);
+  }
+
+  command error_t SplitControl.stop() {
+    post stopDone();
+    return SUCCESS;
+  }
+}
index 6f44f72f14cc8fc28f6d47052bb06e19097ec01a..411fb95d041c89736280710a45795399a7a048f4 100644 (file)
@@ -11,7 +11,7 @@
  * 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
+ * @author Alif Chen\r
  */\r
 \r
 #include "mts300.h"\r
 \r
 configuration MagConfigP {\r
   provides {\r
-    interface Init;\r
-    interface StdControl;\r
     interface Mag;\r
-\r
+    interface Resource[uint8_t client];\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
+  components MagP, MicaBusC, new Atm128I2CMasterC() as I2CPot,\r
+               new TimerMilliC() as WarmupTimer,\r
+    new RoundRobinArbiterC(UQ_MAG_RESOURCE) as Arbiter,\r
+    new SplitControlPowerManagerC() as PowerManager;\r
 \r
-       Init = MagP;\r
-       StdControl = MagP;\r
        Mag = MagP;\r
 \r
+  Resource = Arbiter;\r
   ConfigX = MagP.ConfigX;\r
   ConfigY = MagP.ConfigY;\r
-  ResourceX = MagP.ResourceX;\r
-  ResourceY = MagP.ResourceY;\r
+\r
+  PowerManager.ResourceDefaultOwner -> Arbiter;\r
+  PowerManager.ArbiterInfo -> Arbiter;\r
+  PowerManager.SplitControl -> MagP;\r
 \r
   MagP.I2CPacket -> I2CPot;\r
-  MagP.Resource -> I2CPot;\r
+  MagP.I2CResource -> I2CPot;\r
 \r
+  MagP.Timer -> WarmupTimer;\r
   MagP.MagPower -> MicaBusC.PW5;\r
   MagP.MagAdcX -> MicaBusC.Adc6;\r
   MagP.MagAdcY -> MicaBusC.Adc5;\r
index a2fe23d9f83978c1188ea48f201909f4ce1debbc..0bef394778167cda7988627b7469084d31533fc5 100644 (file)
@@ -4,44 +4,42 @@
 \r
 module MagP\r
 {\r
-  provides interface Init;\r
-  provides interface StdControl;\r
+  provides interface SplitControl;\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 Timer<TMilli>;\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
+  uses interface Resource as I2CResource;\r
 }\r
 \r
 implementation\r
 {\r
   uint8_t gainData[2];\r
 \r
-  command error_t Init.init()\r
+  command error_t SplitControl.start()\r
   {\r
     call MagPower.makeOutput();\r
-               call MagPower.clr();\r
+    call MagPower.set();\r
 \r
+    call Timer.startOneShot(100); \r
     return SUCCESS;\r
-       }\r
+  }\r
 \r
-  command error_t StdControl.start()\r
-  {\r
-    call MagPower.set();\r
-    return SUCCESS;\r
+  event void Timer.fired() {\r
+    signal SplitControl.startDone(SUCCESS);\r
   }\r
 \r
-  command error_t StdControl.stop()\r
+  command error_t SplitControl.stop()\r
   {\r
     call MagPower.clr();\r
     call MagPower.makeInput();\r
 \r
+    signal SplitControl.stopDone(SUCCESS);\r
     return SUCCESS;\r
   }\r
 \r
@@ -49,19 +47,19 @@ implementation
   {\r
     gainData[0] = 1;    // pot subaddr\r
     gainData[1] = val;  // value to write\r
-    return call Resource.request();\r
+    return call I2CResource.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
+    return call I2CResource.request();\r
   }\r
   /**\r
   * Resource request\r
   *\r
   */\r
-  event void Resource.granted()\r
+  event void I2CResource.granted()\r
   {\r
     if ( call I2CPacket.write(0x3,TOS_MAG_POT_ADDR, 2, gainData) == SUCCESS)\r
     {\r
@@ -79,7 +77,7 @@ implementation
 \r
   async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)\r
   {\r
-    call Resource.release();\r
+    call I2CResource.release();\r
     if (gainData[0] ==1)\r
     {\r
       signal Mag.gainAdjustXDone(error);\r
@@ -115,8 +113,12 @@ implementation
     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
+   default event error_t Mag.gainAdjustXDone(bool result)\r
+   {\r
+     return result;\r
+   }\r
+   default event error_t Mag.gainAdjustYDone(bool result)\r
+   {\r
+     return result;\r
+   }\r
 }
\ No newline at end of file
index 0d096d3bc055c215f6208fc965abf6e95bfb02a6..c4de55055a8ce5504213eec7842b1c5c8741f18b 100644 (file)
 #include "mts300.h"
 
 generic configuration MicC() {
-  provides interface Init;
-  provides interface StdControl;
   provides interface Read<uint16_t>;
-  provides interface Mic;
-  provides interface MicInterrupt;
+  provides interface MicSetting;
 }
 implementation {
-  components new AdcReadClientC(), MicDeviceP;
+  enum {
+    ID = unique(UQ_MIC_RESOURCE)
+  };
+  components MicReadP, MicDeviceP, new AdcReadClientC();
 
-  Init = MicDeviceP;
-       StdControl = MicDeviceP;
-  Read = AdcReadClientC;
-  Mic = MicDeviceP;
-  MicInterrupt = MicDeviceP;
-  AdcReadClientC.Atm128AdcConfig -> MicDeviceP;
-  AdcReadClientC.ResourceConfigure -> MicDeviceP;
+  Read = MicReadP.Read[ID];
+  MicReadP.ActualRead[ID] -> AdcReadClientC;
+  AdcReadClientC.Atm128AdcConfig -> MicDeviceP.Atm128AdcConfig;
+  MicSetting = MicDeviceP;
 }
index f2f37546daf5b80e483b1af22c2c1c653777330a..e12ac6a601adbd27c1d37ae4bae46ab5d58fbcbc 100644 (file)
 #include "I2C.h"
 configuration MicDeviceP {
   provides {
-    interface Init;
-    interface StdControl;
-    interface Mic;
-    interface MicInterrupt;
-    interface ResourceConfigure;
+    interface Resource[uint8_t client];
     interface Atm128AdcConfig;
+    interface MicSetting;
   }
 }
 implementation {
   components MicP, MicaBusC, HplAtm128GeneralIOC as Pins,
-      HplAtm128InterruptC as IntPins, LedsC, NoLedsC,
-               new Atm128I2CMasterC() as I2CPot;
+    HplAtm128InterruptC as IntPins,
+               new Atm128I2CMasterC() as I2CPot,
+               new TimerMilliC() as WarmupTimer,
+    new RoundRobinArbiterC(UQ_MIC_RESOURCE) as Arbiter,
+    new SplitControlPowerManagerC() as PowerManager;
 
-       Init = MicP;
-       StdControl = MicP;
-       ResourceConfigure = MicP;
+  Resource = Arbiter;
        Atm128AdcConfig = MicP;
-       Mic = MicP;
-       MicInterrupt = MicP;
+       MicSetting = MicP;
+       
+  PowerManager.ResourceDefaultOwner -> Arbiter;
+  PowerManager.ArbiterInfo -> Arbiter;
+  PowerManager.SplitControl -> MicP;
 
+  MicP.Timer -> WarmupTimer;
   MicP.MicPower  -> MicaBusC.PW3;
   MicP.MicMuxSel -> MicaBusC.PW6;
   MicP.MicAdc -> MicaBusC.Adc2;
   MicP.I2CPacket -> I2CPot;
-  MicP.Resource -> I2CPot;
+  MicP.I2CResource -> I2CPot;
   MicP.AlertInterrupt -> IntPins.Int7;
-  MicP.DebugLeds -> NoLedsC;
 }
index 24e374773a860929076c63511f43221e6174b25e..4533631ca90bbfdd25f2d2a13cf2f66c424591bb 100644 (file)
 
 module MicP
 {
-  provides interface Init;
-  provides interface StdControl;
-  provides interface Mic;
-  provides interface MicInterrupt;
-  provides interface ResourceConfigure as MicResourceConfigure;
+  provides interface SplitControl;
+  provides interface MicSetting;
   provides interface Atm128AdcConfig as MicAtm128AdcConfig;
 
-  uses interface Leds as DebugLeds;
+  uses interface Timer<TMilli>;
        uses interface GeneralIO as MicPower;
        uses interface GeneralIO as MicMuxSel;
        uses interface MicaBusAdc as MicAdc;
   uses interface I2CPacket<TI2CBasicAddr>;
-  uses interface Resource;
+  uses interface Resource as I2CResource;
   uses interface HplAtm128Interrupt as AlertInterrupt;
 }
 implementation 
 {
   uint8_t gainData[2];
   
-  command error_t Init.init()
+  command error_t SplitControl.start()
   {
+    call AlertInterrupt.disable();
     call MicPower.makeOutput();
-               call MicPower.clr();
+    call MicPower.set();
                call MicMuxSel.makeOutput();    
                call MicMuxSel.clr();
-                               
-    call AlertInterrupt.disable();
-    return SUCCESS;
-       }
+               
+    call MicSetting.muxSel(1);  // Set the mux so that raw microhpone output is selected
+    call MicSetting.gainAdjust(64);  // Set the gain of the microphone.
 
-  command error_t StdControl.start()
-  {
-    call MicPower.set();
+    call Timer.startOneShot(1200); 
+//    signal SplitControl.startDone(SUCCESS);
     return SUCCESS;
   }
+
+  event void Timer.fired() {
+    signal SplitControl.startDone(SUCCESS);
+  }
   
-  command error_t StdControl.stop()
+  command error_t SplitControl.stop()
   {
     call AlertInterrupt.disable();
     call MicPower.clr();
     call MicPower.makeInput();
 
+    signal SplitControl.stopDone(SUCCESS);
     return SUCCESS;
   }
   
@@ -81,12 +82,11 @@ implementation
   * Resource request
   * 
   */  
-  event void Resource.granted()
+  event void I2CResource.granted()
   {
-    call DebugLeds.led0Off();
     if ( call I2CPacket.write(0x3,TOS_MIC_POT_ADDR, 2, gainData) == SUCCESS)
     {
-      call DebugLeds.led1On();
+      return;
     };
   }
 
@@ -94,7 +94,7 @@ implementation
   * mic control
   * 
   */  
-  command error_t Mic.muxSel(uint8_t sel)
+  command error_t MicSetting.muxSel(uint8_t sel)
   {
     if (sel == 0)
     {
@@ -109,15 +109,14 @@ implementation
     return FAIL;
   }
   
-  command error_t Mic.gainAdjust(uint8_t val)
+  command error_t MicSetting.gainAdjust(uint8_t val)
   {
-    call DebugLeds.led0On();
     gainData[0] = 0;    // pot subaddr
     gainData[1] = val;  // value to write
-    return call Resource.request();
+    return call I2CResource.request();
   }
   
-  command uint8_t Mic.readToneDetector()
+  command uint8_t MicSetting.readToneDetector()
   {
     bool bVal = call AlertInterrupt.getValue();
     return bVal ? 1 : 0;
@@ -127,26 +126,26 @@ implementation
   * mic interrupt control
   * 
   */
-  async command error_t MicInterrupt.enable()
+  async command error_t MicSetting.enable()
   {
     call AlertInterrupt.enable();
     return SUCCESS;
   }
   
-  async command error_t MicInterrupt.disable()
+  async command error_t MicSetting.disable()
   {
     call AlertInterrupt.disable();
     return SUCCESS;
   }
 
-  default async event error_t MicInterrupt.toneDetected()
+  default async event error_t MicSetting.toneDetected()
   {
     return SUCCESS;
   }
   
   async event void AlertInterrupt.fired()
   {
-    signal MicInterrupt.toneDetected();
+    signal MicSetting.toneDetected();
   }
   
   /**
@@ -169,15 +168,6 @@ implementation
     return ATM128_ADC_PRESCALE;
   }
   
-  async command void MicResourceConfigure.configure() 
-  {
-       call MicPower.set();
-  }
-  
-  async command void MicResourceConfigure.unconfigure() 
-  {
-//    call MicPower.clr();
-  }  
   /**
   * I2CPot2
   * 
@@ -189,8 +179,7 @@ implementation
   
   async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
   {
-    call DebugLeds.led1Off();
-    call Resource.release();
+    call I2CResource.release();
     return ;
   }
 }
index 38f788ea2ab3317f2b7c07165171b97577d9f35b..d6acb651efea1e5f43f47e228f1d1c913637ebf9 100644 (file)
@@ -1,49 +1,25 @@
-/**
- *  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.
+/* $Id$
+ * Copyright (c) 2006 Intel Corporation
+ * All rights reserved.
  *
- *  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.
+ * 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.
  */
- /*
- *  @author Hu Siquan <husq@xbow.com>
- *
- *  $Id$
+/**
+ * Photodiode of the mts300 sensor board.
+ * 
+ * @author David Gay
  */
 
 #include "mts300.h"
 
-generic configuration PhotoC()
-{
+generic configuration PhotoC() {
   provides interface Read<uint16_t>;
-  provides interface StdControl;
-  provides interface Init;
 }
-implementation
-{
-  components new AdcReadClientC(), PhotoTempDeviceP;
-
-  Init = PhotoTempDeviceP;
-  StdControl = PhotoTempDeviceP;
+implementation {
+  components ArbitratedPhotoDeviceP;
 
-  Read = AdcReadClientC;
-  AdcReadClientC.Atm128AdcConfig -> PhotoTempDeviceP.PhotoAtm128AdcConfig;
-  AdcReadClientC.ResourceConfigure -> PhotoTempDeviceP.PhotoResourceConfigure;
+  Read = ArbitratedPhotoDeviceP.Read[unique(UQ_PHOTO_RESOURCE)];
 }
index dc4a6387bb782e8b65852a94ff4b2929c2943972..185f6f7a447c59a24a76ed3d23dc2224f8112b23 100644 (file)
-/**\r
- *  Copyright (c) 2005-2006 Crossbow Technology, Inc.\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\r
- *  agreement is hereby granted, provided that the above copyright\r
- *  notice, the (updated) modification history and the author appear in\r
- *  all copies of this source code.\r
- *\r
- *  Permission is also granted to distribute this software under the\r
- *  standard BSD license as contained in the TinyOS distribution.\r
- *\r
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'\r
- *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- *  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS\r
- *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
- *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,\r
- *  OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
- *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
- *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r
- *  THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- *  @author Martin Turon <mturon@xbow.com>\r
- *  @author Hu Siquan <husq@xbow.com>\r
- *\r
- *  $Id$\r
- */\r
-\r
-#include "Timer.h"\r
-\r
-module PhotoTempP\r
-{\r
-  provides\r
-  {\r
-               interface Init;                                                                                         //!< Standard Initialization\r
-               interface StdControl;           //!< Start/Stop for Temp Sensor's Power Management\r
-    interface ResourceConfigure as TempResourceConfigure;\r
-    interface ResourceConfigure as PhotoResourceConfigure;\r
-    interface Atm128AdcConfig as TempAtm128AdcConfig;\r
-    interface Atm128AdcConfig as PhotoAtm128AdcConfig;\r
-  }\r
-  uses\r
-  {\r
-       interface GeneralIO as TempPower;\r
-       interface GeneralIO as LightPower;\r
-       interface MicaBusAdc as SensorAdc;\r
-       interface Leds as DebugLeds;\r
-    }\r
-}\r
-implementation\r
-{\r
-/*\r
-    enum\r
-    {\r
-       STATE_IDLE = 0,\r
-       STATE_LIGHT_WARMING,   //!< Powering on sensor\r
-       STATE_LIGHT_READY,     //!< Power up of sensor complete\r
-       STATE_LIGHT_SAMPLING,  //!< Sampling sensor\r
-       STATE_TEMP_WARMING,    //!< Powering on sensor\r
-       STATE_TEMP_READY,      //!< Power up of sensor complete\r
-       STATE_TEMP_SAMPLING,   //!< Sampling sensor\r
-    };\r
-\r
-    /// Yes, this could be a simple uint8_t.  There used to be more bits here,\r
-    /// but they were optimized out and removed.\r
-    union\r
-    {\r
-       uint8_t flat;\r
-       struct\r
-       {\r
-           uint8_t state       : 4;   //!< sensorboard state\r
-         } bits;\r
-    } g_flags;\r
-*/\r
-\r
-    void inline TOSH_uwait(int u_sec)\r
-    {\r
-      /* In most cases (constant arg), the test is elided at compile-time */\r
-      if (u_sec)\r
-        /* loop takes 4 cycles, aka 1us */\r
-        asm volatile (\r
-    "1:        sbiw    %0,1\n"\r
-    "  brne    1b" : "+w" (u_sec));\r
-    }\r
-   /**\r
-    * Initialize this component. Initialization should not assume that\r
-    * any component is running: init() cannot call any commands besides\r
-    * those that initialize other components.\r
-    *\r
-    */\r
-    command error_t Init.init()\r
-    {\r
-           return SUCCESS;\r
-    }\r
-\r
-\r
-    /**\r
-     * Start the component and its subcomponents.\r
-     *\r
-     * @return SUCCESS if the component was successfully started.\r
-     */\r
-    command error_t StdControl.start()\r
-    {\r
-      call TempPower.makeOutput();\r
-       call TempPower.clr();\r
-       call LightPower.makeOutput();\r
-       call LightPower.clr();\r
-       \r
-       return SUCCESS;\r
-    }\r
-\r
-    /**\r
-     * Stop the component and pertinent subcomponents (not all\r
-     * subcomponents may be turned off due to wakeup timers, etc.).\r
-     *\r
-     * @return SUCCESS if the component was successfully stopped.\r
-     */\r
-    command error_t StdControl.stop()\r
-    {\r
-       call TempPower.clr();\r
-       call LightPower.clr();\r
-       call TempPower.makeInput();\r
-       call LightPower.makeInput();\r
-       \r
-       return SUCCESS;\r
-    }\r
-\r
-    async command uint8_t TempAtm128AdcConfig.getChannel() \r
-    {\r
-      return call SensorAdc.getChannel();\r
-    }\r
-  \r
-    async command uint8_t TempAtm128AdcConfig.getRefVoltage() \r
-    {\r
-      return ATM128_ADC_VREF_OFF;\r
-    }\r
-  \r
-    async command uint8_t TempAtm128AdcConfig.getPrescaler() \r
-    {\r
-      return ATM128_ADC_PRESCALE;\r
-    }\r
-  \r
-    async command uint8_t PhotoAtm128AdcConfig.getChannel() \r
-    {\r
-      return call SensorAdc.getChannel();\r
-    }\r
-  \r
-    async command uint8_t PhotoAtm128AdcConfig.getRefVoltage() \r
-    {\r
-      return ATM128_ADC_VREF_OFF;\r
-    }\r
-  \r
-    async command uint8_t PhotoAtm128AdcConfig.getPrescaler() \r
-    {\r
-      return ATM128_ADC_PRESCALE;\r
-    }\r
-  \r
-    async command void TempResourceConfigure.configure() \r
-    {\r
-      call DebugLeds.led0On();\r
-               call LightPower.clr();\r
-               call LightPower.makeInput();\r
-               call TempPower.makeOutput();\r
-               call TempPower.set();\r
-               TOSH_uwait(1000);\r
-    }\r
-  \r
-    async command void TempResourceConfigure.unconfigure() \r
-    {\r
-      call DebugLeds.led0Off();\r
-               call TempPower.clr();\r
-               call TempPower.makeInput();\r
-    }\r
-  \r
-      /** Turns on the light sensor and turns the thermistor off. */\r
-    async command void PhotoResourceConfigure.configure() \r
-    {\r
-      call DebugLeds.led1On();\r
-               call TempPower.clr();\r
-               call TempPower.makeInput();\r
-               call LightPower.makeOutput();\r
-               call LightPower.set();\r
-               TOSH_uwait(1000);\r
-    }\r
-  \r
-    async command void PhotoResourceConfigure.unconfigure() \r
-    {\r
-      call DebugLeds.led1Off();\r
-               call LightPower.clr();\r
-               call LightPower.makeInput();\r
-    }\r
-}\r
+/* $Id$
+ * Copyright (c) 2007 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.
+ */
+/**
+ * MTS300 photo and temp sensor ADC configuration.
+ * @author David Gay <david.e.gay@intel.com>
+ */
+module PhotoTempP
+{
+  provides interface Atm128AdcConfig;
+  uses interface MicaBusAdc as PhotoTempAdc;
+}
+implementation
+{
+  async command uint8_t Atm128AdcConfig.getChannel() {
+    return call PhotoTempAdc.getChannel();
+  }
+
+  async command uint8_t Atm128AdcConfig.getRefVoltage() {
+    return ATM128_ADC_VREF_OFF;
+  }
+
+  async command uint8_t Atm128AdcConfig.getPrescaler() {
+    return ATM128_ADC_PRESCALE;
+  }
+}
index 12e093b2edef72a2e4f35412fdb74332a5bcaa2e..8cd1f2535e100b31c59df5cd103abf0c62f42885 100644 (file)
@@ -33,13 +33,12 @@ generic configuration SensorMts300C()
 {\r
   provides\r
   {\r
-       interface Init;                 //!< Standard Initialization\r
-       interface StdControl;           //!< Start/Stop for Power Management\r
+       interface Mts300Sounder as Sounder; //!< sounder\r
        interface Read<uint16_t> as Vref; //!< voltage\r
        interface Read<uint16_t> as Temp; //!< Thermister\r
        interface Read<uint16_t> as Light; //!< Photo sensor\r
        interface Read<uint16_t> as Microphone; //!< Mic sensor\r
-       interface Read<uint16_t> as AccelX; //!< Accelerometer sensor\r
+       interface Read<uint16_t> as AccelX; //!< Accelerometer sensor\r
        interface Read<uint16_t> as AccelY; //!< Accelerometer sensor\r
        interface Read<uint16_t> as MagX; //!< magnetometer sensor\r
        interface Read<uint16_t> as MagY; //!< magnetometer sensor\r
@@ -47,48 +46,23 @@ generic configuration SensorMts300C()
 }\r
 implementation\r
 {\r
-    components         SensorMts300P,  HplAtm128GeneralIOC as IO,\r
+    components SounderC,\r
     new VoltageC(),\r
+    new AccelXC(),\r
+    new AccelYC(),\r
     new PhotoC(),\r
     new TempC(),\r
     new MicC(),\r
-    new MagC(),\r
-    new AccelC(),\r
-         new TimerMilliC() as WarmUpTimer;\r
+    new MagXC(),\r
+    new MagYC();\r
 \r
-    Init       = SensorMts300P.Init;\r
-    Init       = PhotoC.Init;\r
-    Init       = MicC.Init;\r
-    StdControl = SensorMts300P.StdControl;\r
-    Vref       = SensorMts300P.Vref;\r
-    Temp       = SensorMts300P.Temp;\r
-    Light      = SensorMts300P.Light;\r
-    Microphone = SensorMts300P.Microphone;\r
-    AccelX     = SensorMts300P.AccelX;\r
-    AccelY     = SensorMts300P.AccelY;\r
-    MagX       = SensorMts300P.MagX;\r
-    MagY       = SensorMts300P.MagY;\r
-\r
-    SensorMts300P.WarmUpTimer -> WarmUpTimer;\r
-\r
-    SensorMts300P.VrefRead -> VoltageC.Read;\r
-    SensorMts300P.PhotoControl -> PhotoC.StdControl;\r
-    SensorMts300P.TempRead -> TempC.Read;\r
-    SensorMts300P.LightRead -> PhotoC.Read;\r
-    SensorMts300P.LightPower -> IO.PortE5;\r
-    SensorMts300P.TempPower -> IO.PortE6;\r
-\r
-    SensorMts300P.MicControl -> MicC.StdControl;\r
-    SensorMts300P.Mic -> MicC.Mic;\r
-    SensorMts300P.MicRead -> MicC.Read;\r
-\r
-    SensorMts300P.MagControl -> MagC.StdControl;\r
-    SensorMts300P.Mag -> MagC.Mag;\r
-    SensorMts300P.MagXRead -> MagC.MagX;\r
-    SensorMts300P.MagYRead -> MagC.MagY;\r
-\r
-    SensorMts300P.AccelControl -> AccelC.StdControl;\r
-    SensorMts300P.AccelXRead -> AccelC.AccelX;\r
-    SensorMts300P.AccelYRead -> AccelC.AccelY;\r
-    \r
+    Sounder    = SounderC;\r
+    Vref       = VoltageC;\r
+    Temp       = TempC;\r
+    Light      = PhotoC;\r
+    Microphone = MicC;\r
+    AccelX     = AccelXC;\r
+    AccelY     = AccelYC;\r
+    MagX       = MagXC;\r
+    MagY       = MagYC;\r
 }\r
index 52ec479c56154929cb7bc4c9e82a5f833dc7268d..a121e89e93aad727e277bed2189b3bc496fbaae8 100644 (file)
@@ -1,45 +1,12 @@
-/**
- *  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"
-
 configuration SounderC
 {
-  provides interface Init;
-  provides interface StdControl;
+  provides interface Mts300Sounder;
 }
 implementation
 {
-  components SounderP,         MicaBusC;
+  components SounderP, new TimerMilliC(), MicaBusC;
 
-       Init       = SounderP;
-  StdControl = SounderP;
+  Mts300Sounder = SounderP;
+  SounderP.Timer -> TimerMilliC;
   SounderP.SounderPin -> MicaBusC.PW2;
 }
index 7b71bc052b01ba49af3de05fb565ff3c7ff973e7..e5f2c06471b79aa097d2d999ee7c503512506c21 100644 (file)
@@ -1,65 +1,31 @@
-/**
- *  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"
-
-module SounderP 
+module SounderP
 {
-  provides interface Init;
-  provides interface StdControl;
-  uses interface GeneralIO as SounderPin;  
+  provides interface Mts300Sounder;
+  uses {
+    interface Timer<TMilli>;
+    interface GeneralIO as SounderPin;
+  }
 }
-
-implementation 
+implementation
 {
-  command error_t Init.init() 
-  {
-#if SOUNDER
-    call SounderPin.makeOutput();
-    call SounderPin.clr();
-#endif
-    return SUCCESS;
-  }
+  command void Mts300Sounder.beep(uint16_t length) {
+    if (call Timer.isRunning())
+      {
+       uint32_t remaining = call Timer.getdt(),
+         elapsed = call Timer.getNow() - call Timer.gett0();
 
-  command error_t StdControl.start() 
-  {
-#if SOUNDER
+       /* If more time left than we are requesting, just exit */
+       if (remaining > elapsed && (remaining - elapsed) > length)
+         return;
+
+       /* Override timer with new duration */
+      }
+    call Timer.startOneShot(length);
+    call SounderPin.makeOutput();
     call SounderPin.set();
-#endif
-    return SUCCESS;
   }
 
-  command error_t StdControl.stop() 
-  {
-#if SOUNDER
+  event void Timer.fired() {
     call SounderPin.clr();
-#endif
-    return SUCCESS;
   }
 }
index 7dc6ad626e3a261f452a123299e718066ac160d6..03eaf4e901347a7c4afcf992608512fe088bfcad 100644 (file)
@@ -1,42 +1,25 @@
-/**
- *  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;
-}
+/* $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
+ * Photodiode of the mts300 sensor board.\r
+ * \r
+ * @author David Gay\r
+ */\r
+\r
+#include "mts300.h"\r
+\r
+generic configuration TempC() {\r
+  provides interface Read<uint16_t>;\r
+}\r
+implementation {\r
+  components ArbitratedTempDeviceP;\r
+\r
+  Read = ArbitratedTempDeviceP.Read[unique(UQ_TEMP_RESOURCE)];\r
+}\r
index 9424ae287a7eeb54da2e049f4bdea4fb78ce6889..d2add79ece8c16ee46fccdeba3085de48e30ec6a 100644 (file)
 #define SOUNDER 1
 #endif
 
-#define MTS3X0_PHOTO_TEMP "mts300.photo.temp"
-#define MTS3X0_MAG_RESOURCE "mts300.mag"
+#define UQ_ACCEL_RESOURCE "mts300.accel"
+#define UQ_PHOTO_RESOURCE "mts300.photo"
+#define UQ_TEMP_RESOURCE "mts300.temp"
+#define UQ_PHOTOTEMP_RESOURCE "mts300.phototemp"
+#define UQ_MIC_RESOURCE "mts300.microphone"
+#define UQ_MAG_RESOURCE "mts300.mag"
 
 enum
 {