[Tinyos-2-commits] [tinyos-main] r5766 committed - ucmini: modify the I2C sensors power on/off sequence

tinyos-main at googlecode.com tinyos-main at googlecode.com
Fri Sep 30 09:46:35 PDT 2011


Revision: 5766
Author:   mmaroti
Date:     Fri Sep 30 09:45:55 2011
Log:      ucmini: modify the I2C sensors power on/off sequence
http://code.google.com/p/tinyos-main/source/detail?r=5766

Modified:
  /trunk/tos/platforms/ucmini/I2CBusC.nc
  /trunk/tos/platforms/ucmini/I2CBusP.nc

=======================================
--- /trunk/tos/platforms/ucmini/I2CBusC.nc	Sun Sep  4 02:04:37 2011
+++ /trunk/tos/platforms/ucmini/I2CBusC.nc	Fri Sep 30 09:45:55 2011
@@ -46,12 +46,9 @@
    I2CBusP.Power -> IO.PortF1;
  #endif

-  components Sht21C, Bh1750fviC, new Ms5607C(FALSE);
+  components Sht21C, Bh1750fviC, new Ms5607C(FALSE), new TimerMilliC();
    I2CBusP.TemphumSplit -> Sht21C.SplitControl;
    I2CBusP.LightSplit   -> Bh1750fviC.SplitControl;
    I2CBusP.PressureSplit-> Ms5607C.SplitControl;
-
-  components DiagMsgC, LedsC;
-  I2CBusP.DiagMsg -> DiagMsgC;
-  I2CBusP.Leds -> LedsC;
-}
+  I2CBusP.Timer->TimerMilliC;
+}
=======================================
--- /trunk/tos/platforms/ucmini/I2CBusP.nc	Sun Sep  4 02:04:37 2011
+++ /trunk/tos/platforms/ucmini/I2CBusP.nc	Fri Sep 30 09:45:55 2011
@@ -36,135 +36,44 @@
    uses interface SplitControl as TemphumSplit;
    uses interface SplitControl as LightSplit;
    uses interface SplitControl as PressureSplit;
+  uses interface Timer<TMilli>;
    uses interface GeneralIO as Power;
-
-  uses interface DiagMsg;
-  uses interface Leds;
  }
  implementation {
-/*
-cnt bits:
-1:Temphum started
-2:Temphum startDone
-4:Light started
-8:Light startDone
-16:Pressure started
-32:Pressure startDone
-64:bus is on:all lower bits should be 1
-128:bus is off: all lower bits should be 0
-
-*/
-  uint8_t cnt=128;
-  bool startError;

    command error_t SplitControl.start() {
-    error_t error;
-    if(cnt&64)
-      return EALREADY;
-    else if(!(cnt&128) )
-      return EBUSY;
-    cnt=0;
-    startError=FALSE;
      call Power.makeOutput();
      call Power.set();

-    error=call TemphumSplit.start();
-    if(error==SUCCESS){
-      cnt|=1; //call Leds.led0On();
-      error=call LightSplit.start();
-    }
-    if(error==SUCCESS){
-      cnt|=4; //call Leds.led1On();
-      error=call PressureSplit.start();
-    }
-    if(error==SUCCESS){
-      cnt|=16; //call Leds.led2On();
-      return SUCCESS;
-    }
-    else {
-      startError=TRUE;//we should go to OFF state
-      call Power.clr();
-      return error;
-    }
+    call TemphumSplit.start();
+    call LightSplit.start();
+    call PressureSplit.start();
+    call Timer.startOneShot(15);//sht21 boot-up time is the slowest
+    return SUCCESS;
+  }
+
+  event void Timer.fired(){
+    signal SplitControl.startDone(SUCCESS);
    }

    task void stopDone(){
-    cnt=128;
      signal SplitControl.stopDone(SUCCESS);
    }

    command error_t SplitControl.stop() {
-    if(cnt&128)
-      return EALREADY;
-    else if(!(cnt&64))
-      return EBUSY;
-    cnt=0;
+    call Timer.stop();
+    call Power.makeOutput();
      call Power.clr();
      post stopDone();
      return SUCCESS;
    }

-  event void TemphumSplit.startDone(error_t error) {
-    if(error!=SUCCESS){
-      call TemphumSplit.start();
-      return;
-    } call Leds.led0On();
-    if(startError){
-      cnt&=~1;
-      if(cnt==0)
-	cnt=128;
-      return;
-    }
-    cnt |= 2;
-    if(cnt == 63){
-      cnt|=64;
-      signal SplitControl.startDone(SUCCESS);
-    } else signal SplitControl.startDone(FAIL);
-  }
-
-  event void LightSplit.startDone(error_t error) {
-    if(error!=SUCCESS){
-      call LightSplit.start();
-      return;
-    } call Leds.led1On();
-    if(startError){
-      cnt&=~4;
-      if(cnt==0)
-	cnt=128;
-      return;
-    }
-    cnt |= 8;
-    if(cnt == 63){
-      cnt|=64;
-      signal SplitControl.startDone(SUCCESS);
-    } else signal SplitControl.startDone(FAIL);
-  }
-
-  event void PressureSplit.startDone(error_t error) {
-    if(error!=SUCCESS){
-      call PressureSplit.start();
-      return;
-    } call Leds.led2On();
-    if(startError){
-      cnt&=~16;
-      if(cnt==0)
-	cnt=128;
-      return;
-    }
-    cnt |= 32;
-    if(cnt == 63){
-      cnt|=64;
-      signal SplitControl.startDone(SUCCESS);
-    } else signal SplitControl.startDone(FAIL);
-  }
-
-
+  event void TemphumSplit.startDone(error_t error) {}
+  event void LightSplit.startDone(error_t error) {}
+  event void PressureSplit.startDone(error_t error) {}
    event void TemphumSplit.stopDone(error_t error) {}
-
    event void LightSplit.stopDone(error_t error) {}
-
-  event void PressureSplit.stopDone(error_t error) {}
-
-  default event void SplitControl.startDone(error_t error) {call  
Leds.led3On(); }
+  event void PressureSplit.stopDone(error_t error) {}
+  default event void SplitControl.startDone(error_t error) { }
    default event void SplitControl.stopDone(error_t error) { }
  }


More information about the Tinyos-2-commits mailing list