[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/xe1205/phy XE1205PhyP.nc, 1.1.2.1, 1.1.2.2 XE1205PhyRxTx.nc, 1.1.2.1, 1.1.2.2

Henri DF henridf at users.sourceforge.net
Wed Aug 9 14:03:43 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/xe1205/phy
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv13625/phy

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	XE1205PhyP.nc XE1205PhyRxTx.nc 
Log Message:
- add timer for radio to warm up and corresponding RADIO_STARTING state
- add off() command to check if radio is powered down or not

Index: XE1205PhyP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/xe1205/phy/XE1205PhyP.nc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** XE1205PhyP.nc	24 Apr 2006 16:06:48 -0000	1.1.2.1
--- XE1205PhyP.nc	9 Aug 2006 21:03:40 -0000	1.1.2.2
***************
*** 75,79 ****
    uint16_t stats_rxOverruns;
  
!   typedef enum {
      RADIO_LISTEN=0, 
      RADIO_RX_HEADER=1, 
--- 75,79 ----
    uint16_t stats_rxOverruns;
  
!   typedef enum { // remember to update busy() and off(), start(), stop() if states are added
      RADIO_LISTEN=0, 
      RADIO_RX_HEADER=1, 
***************
*** 82,86 ****
      RADIO_TX=4,
      RADIO_SLEEP=5, 
!     RADIO_STARTING=6
    } phy_state_t;
  
--- 82,86 ----
      RADIO_TX=4,
      RADIO_SLEEP=5, 
!     RADIO_STARTING=6 
    } phy_state_t;
  
***************
*** 89,92 ****
--- 89,104 ----
    void armPatternDetect();
  
+   ////////////////////////////////////////////////////////////////////////////////////
+   //
+   // jiffy/microseconds/bytetime conversion functions.
+   //
+   ////////////////////////////////////////////////////////////////////////////////////
+ 
+   // 1 jiffie = 1/32768 = 30.52us; 
+   // we approximate to 32us for quicker computation and also to account for interrupt/processing overhead.
+   inline uint32_t usecs_to_jiffies(uint32_t usecs) {
+     return usecs >> 5;
+   }
+ 
    command error_t Init.init() 
    { 
***************
*** 99,102 ****
--- 111,118 ----
    }
  
+   task void startDone() {
+     signal SplitControl.startDone(SUCCESS);
+   }
+ 
    event void SpiResourceTX.granted() {  }
    event void SpiResourceRX.granted() {  }
***************
*** 104,108 ****
--- 120,126 ----
      armPatternDetect();
      call SpiResourceConfig.release();
+ 
      atomic {
+       if (state == RADIO_STARTING) post startDone();
        call Interrupt0.enableRisingEdge();
        state = RADIO_LISTEN;
***************
*** 111,118 ****
  
  
-   task void startDone() {
-     signal SplitControl.startDone(SUCCESS);
-   }
- 
    task void stopDone() {
      signal SplitControl.stopDone(SUCCESS);
--- 129,132 ----
***************
*** 121,129 ****
    command error_t SplitControl.start() 
    {
!     atomic state = RADIO_STARTING;
      call XE1205PhySwitch.rxMode();
      call XE1205PhySwitch.antennaRx();
!     call SpiResourceConfig.request();
!     post startDone();
      return SUCCESS;
    }
--- 135,147 ----
    command error_t SplitControl.start() 
    {
!     atomic {
!       if (state != RADIO_SLEEP) return EBUSY;
!       state = RADIO_STARTING;
!     }
! 
      call XE1205PhySwitch.rxMode();
      call XE1205PhySwitch.antennaRx();
! 
!     call Alarm32khz16.start(usecs_to_jiffies(XE1205_Sleep_to_RX_Time));
      return SUCCESS;
    }
***************
*** 131,137 ****
    command error_t SplitControl.stop() 
    {
!     call XE1205PhySwitch.sleepMode();
!     call XE1205PhySwitch.antennaOff();
!     atomic state = RADIO_SLEEP;
      post stopDone();
      return SUCCESS;
--- 149,159 ----
    command error_t SplitControl.stop() 
    {
!     atomic {
!       call XE1205PhySwitch.sleepMode();
!       call XE1205PhySwitch.antennaOff();
!       state = RADIO_SLEEP;
!       call Interrupt0.disable();
!       call Interrupt1.disable();
!     }
      post stopDone();
      return SUCCESS;
***************
*** 142,146 ****
  
    async command bool XE1205PhyRxTx.busy() {
!     atomic return state != RADIO_LISTEN; // xxx need to deal with sleep state
    }
  
--- 164,175 ----
  
    async command bool XE1205PhyRxTx.busy() {
!     atomic return (state != RADIO_LISTEN &&
! 		   state != RADIO_SLEEP &&
! 		   state != RADIO_STARTING);
!   }
! 
!   async command bool XE1205PhyRxTx.off() {
!     atomic return (state == RADIO_SLEEP ||
! 		   state == RADIO_STARTING);
    }
  
***************
*** 396,409 ****
  
    async event void Alarm32khz16.fired() {
!     stats_rxOverruns++;
!     signal XE1205PhyRxTx.rxFrameEnd(NULL, 0, FAIL);
!     armPatternDetect(); 
!     call SpiResourceRX.release();
!     atomic {
!       call Interrupt0.enableRisingEdge();
!       state = RADIO_LISTEN;
      }
    }
  
  }
  
--- 425,451 ----
  
    async event void Alarm32khz16.fired() {
! 
!     switch(state) {
! 
!     case RADIO_STARTING:
!       call SpiResourceConfig.request();
!       return;
! 
!     case RADIO_RX_HEADER:
!       stats_rxOverruns++;
!       signal XE1205PhyRxTx.rxFrameEnd(NULL, 0, FAIL);
!       armPatternDetect(); 
!       call SpiResourceRX.release();
!       atomic {
! 	call Interrupt0.enableRisingEdge();
! 	state = RADIO_LISTEN;
!       }
!       return;
!     default:
      }
+ 
    }
  
+ 
  }
  

Index: XE1205PhyRxTx.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/xe1205/phy/XE1205PhyRxTx.nc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** XE1205PhyRxTx.nc	24 Apr 2006 16:06:48 -0000	1.1.2.1
--- XE1205PhyRxTx.nc	9 Aug 2006 21:03:40 -0000	1.1.2.2
***************
*** 120,123 ****
--- 120,130 ----
    async command bool busy();
  
+   /** 
+    * Check on/off state of phy.
+    *
+    * @return TRUE if phy is idle, standby, starting, or stopping, FALSE otherwise.
+    *
+    */
+   async command bool off();
  
  



More information about the Tinyos-2-commits mailing list