]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
add a special short cut
authorandreaskoepke <andreaskoepke>
Fri, 13 Jun 2008 13:40:59 +0000 (13:40 +0000)
committerandreaskoepke <andreaskoepke>
Fri, 13 Jun 2008 13:40:59 +0000 (13:40 +0000)
tos/chips/tda5250/HplTda5250ConfigP.nc
tos/chips/tda5250/RfPower.nc [new file with mode: 0644]
tos/chips/tda5250/Tda5250RadioC.nc
tos/chips/tda5250/Tda5250RadioP.nc

index de8f61a15e06cd3f1afe99cf4367cb0ca8cf34c0..bf1ae116bed60b339122ec93c7994e4e174375f5 100644 (file)
@@ -80,9 +80,9 @@ implementation {
   /****************************************************************
   Global Variables Declared
   *****************************************************************/
-  norace uint16_t currentConfig;
+  norace uint16_t currentConfig = TDA5250_REG_DEFAULT_SETTING_CONFIG;
   uint8_t currentClockDiv;
-  norace uint8_t currentLpf;
+  norace uint8_t currentLpf = TDA5250_REG_DEFAULT_SETTING_LPF;
 
 
   /****************************************************************
diff --git a/tos/chips/tda5250/RfPower.nc b/tos/chips/tda5250/RfPower.nc
new file mode 100644 (file)
index 0000000..b976d03
--- /dev/null
@@ -0,0 +1,33 @@
+/* -*- mode: c++ -*-
+ * Copyright (c) 2007, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * 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
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) 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.
+ *
+ */
+interface RfPower {
+    async command error_t set(uint8_t setting);
+}
index 0989c774a44e78abef46478fd7b375a35add3dea..fafba5bc89f8007a248221471f3e7f143924022f 100644 (file)
@@ -47,6 +47,9 @@ configuration Tda5250RadioC {
     interface ResourceRequested;
     interface RadioByteComm;
     interface ClkDiv;
+#ifdef LNDW
+    interface RfPower;
+#endif
   }
 }
 implementation {
@@ -65,7 +68,9 @@ implementation {
   RadioByteComm = Tda5250RadioP;
   SplitControl = Tda5250RadioP;
   ClkDiv = Tda5250RadioP;
-
+#ifdef LNDW
+  RfPower = Tda5250RadioP;
+#endif
   Tda5250RadioP.DelayTimer -> DelayTimer;
   
   Tda5250RadioP.ConfigResource -> HplTda5250ConfigC;
index a1ea56a82814a46faeae1de3bfc57c1a1eae58f0..975fcaa63a54289dcec488190ea5dde638a3aa56 100644 (file)
@@ -55,6 +55,9 @@ module Tda5250RadioP {
         interface RadioByteComm;
         interface ResourceRequested;
         interface ClkDiv;
+#ifdef LNDW
+        interface RfPower;
+#endif
     }
     uses {
         interface HplTda5250Config;
@@ -79,6 +82,27 @@ implementation {
     radioMode_t radioMode;    // Current Mode of the Radio
     float onTime, offTime;
 
+#ifdef LNDW
+    norace bool rfpowerdirty = FALSE;
+    norace uint8_t rfpower = INITIAL_RF_POWER;
+    task void setRfPower() {
+        uint8_t rp, rd;
+        atomic {
+            rp = rfpower;
+            rd = rfpowerdirty;
+        }
+        if(rd) {
+            if(call ConfigResource.immediateRequest() == SUCCESS)  {
+                call HplTda5250Config.SetRFPower(rp);                
+                atomic rfpowerdirty = FALSE;
+            }
+            else {
+                post setRfPower();
+            }
+        }
+    }
+#endif
+    
     /**************** Radio Init *****************/
     command error_t Init.init() {
         radioMode = RADIO_MODE_OFF;
@@ -156,6 +180,7 @@ implementation {
                 call HplTda5250Config.SetSleepMode();
                 atomic radioMode = RADIO_MODE_SLEEP;
                 signal Tda5250Control.SleepModeDone();
+                if(rfpowerdirty) post setRfPower();
                 break;
             case RADIO_MODE_TX_TRANSITION:
                 call HplTda5250Config.SetSlaveMode();
@@ -454,4 +479,13 @@ implementation {
       }
       default async event void ClkDiv.stopping() {
       }
+#ifdef LNDW
+      async command error_t RfPower.set(uint8_t setting) {
+          atomic {
+              rfpower = setting;
+              rfpowerdirty = TRUE;
+          }
+          return SUCCESS;
+      }
+#endif
 }