]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/tda5250/Tda5250RadioP.nc
add a special short cut
[tinyos-2.x.git] / tos / chips / tda5250 / Tda5250RadioP.nc
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
 }