]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Change to use driver which follow TEP 109 .
authorpipeng <pipeng>
Wed, 14 Mar 2007 03:22:37 +0000 (03:22 +0000)
committerpipeng <pipeng>
Wed, 14 Mar 2007 03:22:37 +0000 (03:22 +0000)
apps/tests/mica2/mts300/TestMts300C.nc
apps/tests/mica2/mts300/TestMts300P.nc

index c08f06f9cbad451955e043cef93fe5b8e0a69bba..f7da8d792cc78abb3f0151ad95149b9a037de82b 100644 (file)
@@ -1,41 +1,3 @@
-// $Id$\r
-\r
-/*\r
- *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
- *  downloading, copying, installing or using the software you agree to\r
- *  this license.  If you do not agree to this license, do not download,\r
- *  install, copy or use the software.\r
- *\r
- *  Copyright (c) 2004-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\r
- *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\r
- *  PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE INTEL OR ITS\r
- *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
- *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
- *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
- *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-/**\r
- *  TinyOS 1.x to TinyOS 2.x translation layer.\r
- *\r
- *  @author Alif <rlchen@xbow.com.cn>  \r
- */\r
 \r
 #include "XMTS300.h"\r
 #include "mts300.h"\r
@@ -53,12 +15,11 @@ implementation
 \r
 // sensorboard devices\r
   components new SensorMts300C();\r
-  components SounderC;\r
 \r
   TestMts300P -> MainC.Boot;\r
 \r
   TestMts300P.MTS300Timer -> MTS300Timer;\r
-  TestMts300P.Leds -> NoLedsC;\r
+  TestMts300P.Leds -> LedsC;\r
 \r
   // communication\r
   TestMts300P.RadioControl -> Radio;\r
@@ -70,9 +31,9 @@ implementation
   TestMts300P.UartPacket -> Serial;\r
 \r
   // sensor components\r
-  MainC.SoftwareInit -> SensorMts300C;\r
-  TestMts300P.MTS300Control -> SensorMts300C.StdControl;\r
   TestMts300P.Vref -> SensorMts300C.Vref;\r
+  TestMts300P.Sounder -> SensorMts300C.Sounder;\r
+  \r
   TestMts300P.Light -> SensorMts300C.Light;\r
   TestMts300P.Temp -> SensorMts300C.Temp;\r
   TestMts300P.Microphone -> SensorMts300C.Microphone;\r
@@ -80,7 +41,4 @@ implementation
   TestMts300P.AccelY -> SensorMts300C.AccelY;\r
   TestMts300P.MagX -> SensorMts300C.MagX;\r
   TestMts300P.MagY -> SensorMts300C.MagY;\r
-\r
-  MainC.SoftwareInit -> SounderC;\r
-  TestMts300P.Sounder -> SounderC;\r
 }\r
index 2f46d90e27c00fe3641b9ad19ceb1b2f7649405d..334c032f95108db32f2a12de64a5583566d96925 100644 (file)
@@ -1,42 +1,3 @@
-// $Id$\r
-\r
-/*\r
- *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
- *  downloading, copying, installing or using the software you agree to\r
- *  this license.  If you do not agree to this license, do not download,\r
- *  install, copy or use the software.\r
- *\r
- *  Copyright (c) 2004-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\r
- *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\r
- *  PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE INTEL OR ITS\r
- *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
- *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
- *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
- *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-/**\r
- *  TinyOS 1.x to TinyOS 2.x translation layer.\r
- *\r
- *  @author Alif <rlchen@xbow.com.cn>  \r
- */\r
\r
 #include "Timer.h"\r
 #include "XMTS300.h"\r
 #include "mts300.h"\r
@@ -57,8 +18,7 @@ module TestMts300P
     interface Packet as UartPacket;\r
     interface AMSend as UartSend;\r
     // sensor components\r
-    interface StdControl as MTS300Control;\r
-    interface StdControl as Sounder;\r
+    interface Mts300Sounder as Sounder;\r
        interface Read<uint16_t> as Vref; //!< voltage\r
     interface Read<uint16_t> as Light;\r
     interface Read<uint16_t> as Temp;\r
@@ -105,6 +65,29 @@ implementation
   norace uint16_t accel_ave_x, accel_ave_y;\r
   norace uint8_t accel_ave_points;\r
 \r
+\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  packet sending\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+  task void send_msg()\r
+  {\r
+    atomic packet_ready = FALSE;\r
+    // check length of the allocated buffer to see if it is enough for our packet\r
+    if (call RadioPacket.maxPayloadLength() < sizeof(Mts300Msg))\r
+    {\r
+      return ;\r
+    }\r
+    // OK, the buffer is large enough\r
+    //pMsg->vref = counter;\r
+    if (call UartSend.send(AM_BROADCAST_ADDR, &packet, sizeof(Mts300Msg)) == SUCCESS)\r
+    {\r
+      sending_packet = TRUE;\r
+      call Leds.led2On();\r
+    }\r
+  }\r
+\r
 //////////////////////////////////////////////////////////////////////////////\r
 //\r
 //  basic control routines\r
@@ -143,9 +126,8 @@ implementation
   {\r
     if (err == SUCCESS)\r
     {\r
-      call MTS300Control.start();\r
-      call Sounder.start();\r
-      call MTS300Timer.startPeriodic( 300 );\r
+      call Sounder.beep(1000);\r
+      call MTS300Timer.startPeriodic( 1000 );\r
     }\r
     else\r
     {\r
@@ -182,12 +164,6 @@ implementation
     }\r
 \r
     call Leds.led1Toggle();\r
-    counter++;\r
-\r
-    if(counter==1)\r
-    {\r
-      call Sounder.stop();\r
-    }\r
 \r
     if (sending_packet) return ;\r
 \r
@@ -197,23 +173,6 @@ implementation
       call Vref.read();\r
       return ;\r
     }\r
-\r
-    if (packet_ready)\r
-    {\r
-      atomic packet_ready = FALSE;\r
-      // check length of the allocated buffer to see if it is enough for our packet\r
-      if (call RadioPacket.maxPayloadLength() < sizeof(Mts300Msg))\r
-      {\r
-        return ;\r
-      }\r
-      // OK, the buffer is large enough\r
-      //pMsg->vref = counter;\r
-      if (call UartSend.send(AM_BROADCAST_ADDR, &packet, sizeof(Mts300Msg)) == SUCCESS)\r
-      {\r
-        sending_packet = TRUE;\r
-        call Leds.led2On();\r
-      }\r
-    }\r
   }\r
 \r
   /**\r
@@ -230,7 +189,6 @@ implementation
     {\r
       pMsg->vref = 0;\r
     }\r
-//    atomic packet_ready = TRUE;\r
       atomic state = STATE_LIGHT_START;\r
       call Light.read();\r
   }\r
@@ -251,9 +209,10 @@ implementation
     }\r
     atomic state = STATE_TEMP_START;\r
     call Temp.read();\r
+//    atomic state = STATE_MIC_START;\r
+//    call Microphone.read();\r
   }\r
 \r
-\r
   /**\r
    * Temperature data read\r
    *\r
@@ -345,7 +304,6 @@ implementation
     {\r
       pMsg->accelY = 0;\r
     }\r
-//    atomic packet_ready = TRUE;\r
     atomic state = STATE_MAGX_START;\r
     call MagX.read();\r
   }\r
@@ -383,6 +341,7 @@ implementation
       pMsg->magY = 0;\r
     }\r
     atomic packet_ready = TRUE;\r
+    post send_msg();\r
   }\r
 \r
   /**\r