[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/tda5250/mac CsmaMacC.nc, 1.1.2.7, 1.1.2.8 CsmaMacP.nc, 1.1.2.8, 1.1.2.9

Philipp Huppertz phihup at users.sourceforge.net
Thu Aug 3 11:17:54 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26539/tos/chips/tda5250/mac

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	CsmaMacC.nc CsmaMacP.nc 
Log Message:
- updated eyes platform to use usart configure
- a few bug fixes

Index: CsmaMacC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/CsmaMacC.nc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** CsmaMacC.nc	21 Jun 2006 14:45:10 -0000	1.1.2.7
--- CsmaMacC.nc	3 Aug 2006 18:17:52 -0000	1.1.2.8
***************
*** 26,34 ****
   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
   * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  *
! */
  
  /**
!  * Confuguration for the CsmaMac.
   *
   * @author: Kevin Klues (klues at tkn.tu-berlin.de)
--- 26,33 ----
   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
   * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  */
  
  /**
!  * Configuration for the CsmaMac.
   *
   * @author: Kevin Klues (klues at tkn.tu-berlin.de)
***************
*** 36,39 ****
--- 35,40 ----
   * @author: Philipp Huppertz (huppertz at tkn.tu-berlin.de)
   */
+ 
+ // #define MAC_DEBUG
  configuration CsmaMacC {
    provides {
***************
*** 41,60 ****
      interface MacSend;
      interface MacReceive;
    }
    uses {
      interface PhySend as PacketSend;
      interface PhyReceive as PacketReceive;
!         
      interface Tda5250Control;  
      interface UartPhyControl;
    }
  }
  implementation {
    components  MainC,
        CsmaMacP,
        RssiFixedThresholdCMC as Cca,
        new Alarm32khzC() as Timer,
!       RandomLfsrC,
!       PlatformLedsC;
                
      MainC.SoftwareInit -> CsmaMacP;
--- 42,67 ----
      interface MacSend;
      interface MacReceive;
+     interface Packet;
    }
    uses {
      interface PhySend as PacketSend;
      interface PhyReceive as PacketReceive;
!     interface Packet as SubPacket;
      interface Tda5250Control;  
      interface UartPhyControl;
+     interface RadioTimeStamping;
    }
  }
  implementation {
    components  MainC,
+ //       Tda5250RadioC,    
        CsmaMacP,
        RssiFixedThresholdCMC as Cca,
        new Alarm32khzC() as Timer,
!       RandomLfsrC
! #ifdef MAC_DEBUG
!       ,PlatformLedsC
! #endif
!       ;
                
      MainC.SoftwareInit -> CsmaMacP;
***************
*** 66,70 ****
--- 73,80 ----
      Tda5250Control = CsmaMacP;
      UartPhyControl = CsmaMacP;
+     RadioTimeStamping = CsmaMacP;
      
+     CsmaMacP = Packet;
+     CsmaMacP = SubPacket;
      CsmaMacP = PacketSend;
      CsmaMacP = PacketReceive;
***************
*** 74,84 ****
--- 84,100 ----
      CsmaMacP.ChannelMonitorData -> Cca.ChannelMonitorData;
      CsmaMacP.ChannelMonitorControl -> Cca.ChannelMonitorControl;
+     CsmaMacP.RssiAdcResource -> Cca.RssiAdcResource;
+     
      CsmaMacP.Random -> RandomLfsrC;
  
+ //     CsmaMacP.RadioResourceRequested -> Tda5250RadioC.ResourceRequested;
+ 
      CsmaMacP.Timer -> Timer;
+ #ifdef MAC_DEBUG
      CsmaMacP.Led0 -> PlatformLedsC.Led0;
      CsmaMacP.Led1 -> PlatformLedsC.Led1;
      CsmaMacP.Led2 -> PlatformLedsC.Led2;
      CsmaMacP.Led3 -> PlatformLedsC.Led3;
+ #endif    
  }
  

Index: CsmaMacP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/CsmaMacP.nc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** CsmaMacP.nc	21 Jun 2006 14:45:10 -0000	1.1.2.8
--- CsmaMacP.nc	3 Aug 2006 18:17:52 -0000	1.1.2.9
***************
*** 30,33 ****
--- 30,34 ----
  
  
+ 
  #include "radiopacketfunctions.h"
  #include "flagfunctions.h"
***************
*** 40,43 ****
--- 41,46 ----
    * @author Philipp Huppertz (huppertz at tkn.tu-berlin.de)
  */
+ 
+ // #define MACM_DEBUG                 // debug...
  module CsmaMacP {
      provides {
***************
*** 46,49 ****
--- 49,53 ----
          interface MacSend;
          interface MacReceive;
+         interface Packet;
      }
      uses {
***************
*** 51,71 ****
          interface PhySend as PacketSend;
          interface PhyReceive as PacketReceive;
          
          interface Tda5250Control as RadioModes;  
  
          interface UartPhyControl;
!       
          interface ChannelMonitor;
          interface ChannelMonitorControl;  
          interface ChannelMonitorData;
  
          interface Random;
          
          interface Alarm<T32khz, uint16_t> as Timer;
! 
          interface GeneralIO as Led0;
          interface GeneralIO as Led1;
          interface GeneralIO as Led2;
          interface GeneralIO as Led3;
      }
  }
--- 55,80 ----
          interface PhySend as PacketSend;
          interface PhyReceive as PacketReceive;
+         interface RadioTimeStamping;
          
          interface Tda5250Control as RadioModes;  
+ //         interface ResourceRequested as RadioResourceRequested;
  
          interface UartPhyControl;
!         interface Packet as SubPacket;
!         
          interface ChannelMonitor;
          interface ChannelMonitorControl;  
          interface ChannelMonitorData;
+         interface Resource as RssiAdcResource;
  
          interface Random;
          
          interface Alarm<T32khz, uint16_t> as Timer;
! #ifdef MACM_DEBUG
          interface GeneralIO as Led0;
          interface GeneralIO as Led1;
          interface GeneralIO as Led2;
          interface GeneralIO as Led3;
+ #endif
      }
  }
***************
*** 74,78 ****
  #define CSMA_ACK 100
  #define BYTE_TIME 17
- // #define MACM_DEBUG                    // debug...
  #define MAX_LONG_RETRY 3              // Missing acks, or short retry limit hits -> increase long retry 
  #define MAX_SHORT_RETRY 5             // busy channel -> increase short retry
--- 83,86 ----
***************
*** 195,206 ****
--- 203,232 ----
      task void SetRxModeTask();
      task void SetTxModeTask();
+ 
+ 
+     task void ReleaseAdcTask() {
+         macState_t ms;
+         atomic ms = macState;
+         if((ms >= CCA)  && (ms != INIT) && (call RssiAdcResource.isOwner())) {
+             call RssiAdcResource.release();
+         }
+     }
      
      void setRxMode();
      void setTxMode();
  
+     void requestAdc() {
+         if(!call RssiAdcResource.isOwner()) {
+             if(call RssiAdcResource.immediateRequest() != SUCCESS) {
+                 call RssiAdcResource.request();
+             }
+         }
+     }
+     
      void setRxMode() {
          if(call RadioModes.RxMode() == FAIL) {
              post SetRxModeTask();
          }
+         if((macState == SW_CCA) || (macState == INIT)) requestAdc();
      }
      
***************
*** 220,223 ****
--- 246,250 ----
              post SetTxModeTask();
          }
+         post ReleaseAdcTask();
      }
      
***************
*** 266,270 ****
              clearFlag(&flags, CHECK_RX_LIVENESS);
              clearFlag(&flags, DIFS_TIMER_FIRED);
!             /*           if(!call UartPhyControl.isBusy()) { */
                  if(isFlagSet(&flags, RSSI_STABLE)) {
                      macState = CCA;
--- 293,297 ----
              clearFlag(&flags, CHECK_RX_LIVENESS);
              clearFlag(&flags, DIFS_TIMER_FIRED);
!             if(!call UartPhyControl.isBusy()) {
                  if(isFlagSet(&flags, RSSI_STABLE)) {
                      macState = CCA;
***************
*** 278,282 ****
                      storeOldState(131);
                  }
!  /*           }
              else {
                  storeOldState(132);
--- 305,309 ----
                      storeOldState(131);
                  }
!             }
              else {
                  storeOldState(132);
***************
*** 285,290 ****
                  call Timer.start(backoff());
              }
!                 */
!       }
      }
      
--- 312,316 ----
                  call Timer.start(backoff());
              }
!         }
      }
      
***************
*** 349,352 ****
--- 375,399 ----
      }
      
+     /****** Packet interface ********************/
+     command void Packet.clear(message_t* msg) {
+         call SubPacket.clear(msg);
+     }
+     
+     command uint8_t Packet.payloadLength(message_t* msg) {
+         return call SubPacket.payloadLength(msg);
+     }
+     
+     command void Packet.setPayloadLength(message_t* msg, uint8_t len) {
+         call SubPacket.setPayloadLength(msg,len);
+     }
+     
+     command uint8_t Packet.maxPayloadLength() {
+         return call SubPacket.maxPayloadLength();
+     }
+     
+     command void* Packet.getPayload(message_t* msg, uint8_t* len) {
+         return call SubPacket.getPayload(msg, len);
+     }
+    
      /****** Radio(Mode) events *************************/
      async event void RadioModes.RssiStable() {
***************
*** 354,365 ****
              setFlag(&flags, RSSI_STABLE);
              if(macState == SW_CCA)  {
!                 storeOldState(10);
!                 macState = CCA;
!                 signalMacState();
!                 call Timer.start(DIFS);
!                 call ChannelMonitor.start();
              } else if(macState == INIT) {
                  storeOldState(11);
!                 call ChannelMonitorControl.updateNoiseFloor();
              } else {
                  storeOldState(13);
--- 401,424 ----
              setFlag(&flags, RSSI_STABLE);
              if(macState == SW_CCA)  {
!                 if(call UartPhyControl.isBusy()) {
!                     macState = RX;
!                     signalMacState();
!                     setFlag(&flags, CHECK_RX_LIVENESS);
!                     call Timer.start(CHECK_RX_LIVENESS_INTERVALL);
!                 }
!                 else {
!                     storeOldState(10);
!                     macState = CCA;
!                     signalMacState();
!                     call Timer.start(DIFS);
!                     call ChannelMonitor.start();
!                 }
              } else if(macState == INIT) {
                  storeOldState(11);
!                 if(call RssiAdcResource.isOwner()) {
!                     call ChannelMonitorControl.updateNoiseFloor();
!                 } else {
!                     call RssiAdcResource.request();
!                 }
              } else {
                  storeOldState(13);
***************
*** 460,465 ****
              call Timer.stop();
              clearFlag(&flags, CHECK_RX_LIVENESS);
-             if(isFlagSet(&flags, BUSY_DETECTED_VIA_RSSI)) call ChannelMonitor.rxSuccess();
-             call  ChannelMonitorData.getSnr();
          }
          if(macState <= RX) {
--- 519,522 ----
***************
*** 559,569 ****
              storeOldState(90);
              if(isFlagSet(&flags, CHECK_RX_LIVENESS)) {
!                 /* if(call UartPhyControl.isBusy()) {
                      call Timer.start(CHECK_RX_LIVENESS_INTERVALL);
                  }
                  else {
!                 */
!                     call ChannelMonitor.start();
!                     /*} */
              } else {
                  checkSend();
--- 616,627 ----
              storeOldState(90);
              if(isFlagSet(&flags, CHECK_RX_LIVENESS)) {
!                 if(call UartPhyControl.isBusy()) {
                      call Timer.start(CHECK_RX_LIVENESS_INTERVALL);
                  }
                  else {
!                     storeOldState(111);
!                     clearFlag(&flags, CHECK_RX_LIVENESS);
!                     call Timer.start(backoff());                    
!                 }
              } else {
                  checkSend();
***************
*** 578,584 ****
          }
          else if(macState == CCA) {
!             storeOldState(92);
!             setFlag(&flags, DIFS_TIMER_FIRED);
!             call ChannelMonitor.start();
          }
          else {
--- 636,652 ----
          }
          else if(macState == CCA) {
!             if(call UartPhyControl.isBusy()) {
!                 storeOldState(100);
!                 macState = RX;
!                 signalMacState();
!                 updateRetryCounters();
!                 call Timer.start(backoff());
!             }
!             else {
!                 storeOldState(112);
!                 macState = SW_TX;
!                 signalMacState();
!                 setTxMode();
!             }
          }
          else {
***************
*** 591,594 ****
--- 659,669 ----
  
      async event void ChannelMonitor.channelBusy() {
+         setFlag(&flags, BUSY_DETECTED_VIA_RSSI);
+         /*
+           if(!call UartPhyControl.isBusy()) {
+             call Led3.set();
+         } else {
+             call Led3.clr();
+         }
          atomic {
              if(macState == CCA) {
***************
*** 609,620 ****
              }
          }
      }
  
      async event void ChannelMonitor.channelIdle() {
!         storeOldState(110);
          if((macState == RX) && (isFlagSet(&flags, CHECK_RX_LIVENESS))) {
!                 storeOldState(111);
!                 clearFlag(&flags, CHECK_RX_LIVENESS);
!                 call Timer.start(backoff());
          }
          else if(macState == CCA) {
--- 684,701 ----
              }
          }
+         */
      }
  
      async event void ChannelMonitor.channelIdle() {
! /*        storeOldState(110);
!         if(call UartPhyControl.isBusy()) {
!             call Led3.set();
!         } else {
!             call Led3.clr();
!         }
          if((macState == RX) && (isFlagSet(&flags, CHECK_RX_LIVENESS))) {
!             storeOldState(111);
!             clearFlag(&flags, CHECK_RX_LIVENESS);
!             call Timer.start(backoff());
          }
          else if(macState == CCA) {
***************
*** 627,630 ****
--- 708,712 ----
            }
          }
+ */
      }
  
***************
*** 657,660 ****
--- 739,780 ----
      async event void RadioModes.SelfPollingModeDone() {}
      async event void RadioModes.PWDDDInterrupt() {}
+ 
+     /***** abused TimeStamping events **************************/
+     async event void RadioTimeStamping.receivedSFD( uint16_t time ) {
+         if(isFlagSet(&flags, BUSY_DETECTED_VIA_RSSI)) call ChannelMonitor.rxSuccess();
+         if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
+     }
+     
+     async event void RadioTimeStamping.transmittedSFD( uint16_t time, message_t* p_msg ) {}
+ 
+     /***** Rssi Resource events ******************/
+     event void RssiAdcResource.granted() {
+         macState_t ms;
+         atomic ms = macState;
+         if((ms == SW_CCA) || (ms == CCA)) {
+             storeOldState(144);
+         }
+         else if(ms == INIT) {
+             storeOldState(145);
+             call ChannelMonitorControl.updateNoiseFloor();            
+         }
+         else {
+             storeOldState(146);
+             call RssiAdcResource.release();
+         }
+     }
+     
+     /***** RadioData Resource events **************/
+ //     async event void RadioResourceRequested.requested() {
+ //       atomic {
+ //         /* This gives other devices the chance to get the Resource
+ //            because RxMode implies a new arbitration round.  */
+ //         if (macState == RX) setRxMode();
+ //       }
+ //     }
+ //     
+ //     // we don't care about urgent Resource requestes
+ //     async event void RadioResourceRequested.immediateRequested() {}
  }
  
+ 



More information about the Tinyos-2-commits mailing list