]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
solve dependencies on baudrate automagically
authorandreaskoepke <andreaskoepke>
Wed, 5 Mar 2008 11:20:43 +0000 (11:20 +0000)
committerandreaskoepke <andreaskoepke>
Wed, 5 Mar 2008 11:20:43 +0000 (11:20 +0000)
tos/chips/tda5250/mac/CsmaMacC.nc
tos/chips/tda5250/mac/CsmaMacP.nc
tos/chips/tda5250/mac/RedMacP.nc
tos/chips/tda5250/mac/SpeckMacDP.nc
tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc
tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc

index 6413c88d1b0de5a735f00263f8fc88ed56abb73d..1b2cfba4db52ce624549e6c05e67f2bdba7f370a 100644 (file)
@@ -61,6 +61,7 @@ implementation {
       new TimerMilliC() as ReRxTimer,
       DuplicateC,
       TimeDiffC,
+      LocalTimeC,
       RandomLfsrC
 #ifdef MAC_DEBUG
       ,PlatformLedsC
@@ -101,7 +102,8 @@ implementation {
 
     CsmaMacP.Duplicate -> DuplicateC;
     CsmaMacP.TimeDiff16 -> TimeDiffC;
-    
+    CsmaMacP.LocalTime32kHz -> LocalTimeC;
+
 #ifdef MAC_DEBUG
     CsmaMacP.Led0 -> PlatformLedsC.Led0;
     CsmaMacP.Led1 -> PlatformLedsC.Led1;
index e3297a82762fa602c54b3e97c78c64bbe6411364..2a236528e5b090301e2a242f2342d126118f2071 100644 (file)
@@ -76,7 +76,8 @@ module CsmaMacP {
         
         interface Alarm<T32khz, uint16_t> as Timer;
         async command am_addr_t amAddress();
-
+        interface LocalTime<T32khz> as LocalTime32kHz;
+        
 #ifdef MACM_DEBUG
         interface GeneralIO as Led0;
         interface GeneralIO as Led1;
@@ -89,18 +90,13 @@ implementation
 {
 
     enum {
-        /*
-          BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
-          PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
-          PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
-          TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
-        */
-        
-        BYTE_TIME=14,                 // byte at 35108 kBit/s, 4b6b encoded
-        PREAMBLE_BYTE_TIME=9,         // byte at 35108 kBit/s, no coding
-        PHY_HEADER_TIME=56,           // 6 Phy Preamble at 35108 bits/s
-        TIME_CORRECTION=11,           // difference between txSFD and rxSFD: to do
 
+        BYTE_TIME=ENCODED_32KHZ_BYTE_TIME,           // phy encoded
+        PREAMBLE_BYTE_TIME=TDA5250_32KHZ_BYTE_TIME,  // no coding
+        PHY_HEADER_TIME=6*PREAMBLE_BYTE_TIME,        // 6 Phy Preamble
+        TIME_CORRECTION=TDA5250_32KHZ_BYTE_TIME+2,   // difference between txSFD and rxSFD
+
+        
         SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(tda5250_header_t)*BYTE_TIME,
         SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
         MAXTIMERVALUE=0xFFFF,        // helps to compute backoff
@@ -163,6 +159,8 @@ implementation
     uint16_t restLaufzeit;
 
     uint16_t rssiValue = 0;
+
+    uint32_t rxTime = 0;
     
     /****** debug vars & defs & functions  ***********************/
 #ifdef MACM_DEBUG
@@ -386,11 +384,13 @@ implementation
     }
 
     bool isNewMsg(message_t* msg) {
-        return call Duplicate.isNew(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
+        return call Duplicate.isNew(getHeader(msg)->src, getHeader(msg)->dest,
+                                    (getHeader(msg)->token) & TOKEN_ACK_MASK);
     }
     
     void rememberMsg(message_t* msg) {
-        call Duplicate.remember(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
+        call Duplicate.remember(getHeader(msg)->src, getHeader(msg)->dest,
+                                (getHeader(msg)->token) & TOKEN_ACK_MASK);
     }
     
     void checkSend() {
@@ -668,6 +668,7 @@ implementation
             storeOldState(61);
             macState = RX_P;
             signalMacState();
+            requestAdc();
         }
         else if(macState <= RX_ACK) {
             storeOldState(62);
@@ -782,6 +783,7 @@ implementation
             storeOldState(94);
             signalFailure(11);
         }
+        post ReleaseAdcTask();
         return m;        
     }
 
@@ -809,6 +811,7 @@ implementation
         else {
             signalFailure(13);
         }
+        post ReleaseAdcTask();
     }
        
     
@@ -953,7 +956,10 @@ implementation
     /***** abused TimeStamping events **************************/
     async event void RadioTimeStamping.receivedSFD( uint16_t time ) {
         if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
-        if(macState == RX_P) call ChannelMonitor.rxSuccess();
+        if(macState == RX_P) {
+            rxTime = call LocalTime32kHz.get();
+            call ChannelMonitor.rxSuccess();
+        }
     }
     
     async event void RadioTimeStamping.transmittedSFD( uint16_t time, message_t* p_msg ) {}
index db94c075783e4f29ae9f780cb6f4b629128b49af..c34bcdae217faabb68141578f86cea69dda4b981 100644 (file)
@@ -138,24 +138,19 @@ implementation
 
     /**************** Module Global Constants  *****************/
     enum {
-/*
-        BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
-        PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
-        PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
-        TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
-*/
-        BYTE_TIME=14,                 // byte at 35108 kBit/s, 4b6b encoded
-        PREAMBLE_BYTE_TIME=9,         // byte at 35108 kBit/s, no coding
-        PHY_HEADER_TIME=56,           // 6 Phy Preamble at 35108 bits/s
-        TIME_CORRECTION=11,           // difference between txSFD and rxSFD: to do
         
+        BYTE_TIME=ENCODED_32KHZ_BYTE_TIME,           // phy encoded
+        PREAMBLE_BYTE_TIME=TDA5250_32KHZ_BYTE_TIME,  // no coding
+        PHY_HEADER_TIME=6*PREAMBLE_BYTE_TIME,        // 6 Phy Preamble
+        TIME_CORRECTION=TDA5250_32KHZ_BYTE_TIME+2,   // difference between txSFD and rxSFD
+
         SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
         SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
         // DEFAULT_SLEEP_TIME=1625,
-        // DEFAULT_SLEEP_TIME=2048,
+        DEFAULT_SLEEP_TIME=2048,
         // DEFAULT_SLEEP_TIME=4096,
         // DEFAULT_SLEEP_TIME=8192,
-        DEFAULT_SLEEP_TIME=16384,
+        // DEFAULT_SLEEP_TIME=16384,
         // DEFAULT_SLEEP_TIME=32768U,
         // DEFAULT_SLEEP_TIME=65535U,
         DATA_DETECT_TIME=17,
@@ -370,8 +365,8 @@ implementation
                 if(isFlagSet(&flags, TEAMGEIST_ACTIVE) &&
                    (getHeader(msg)->type == teamgeistType)) {
                     if(rssiValue != INVALID_SNR) snr = rssiValue;
-                    rVal = signal Teamgeist.needsAck(msg, getHeader(msg)->src, getHeader(msg)->dest, snr);
                     *level = 2;
+                    rVal = signal Teamgeist.needsAck(msg, getHeader(msg)->src, getHeader(msg)->dest, snr);
                 }
             }
         }
@@ -547,11 +542,14 @@ implementation
     }
     
     bool isNewMsg(message_t* msg) {
-        return call Duplicate.isNew(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
+        return call Duplicate.isNew(getHeader(msg)->src,
+                                    getHeader(msg)->dest,
+                                    (getHeader(msg)->token) & TOKEN_ACK_MASK);
    }
 
     void rememberMsg(message_t* msg) {
-        call Duplicate.remember(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
+        call Duplicate.remember(getHeader(msg)->src, getHeader(msg)->dest,
+                                (getHeader(msg)->token) & TOKEN_ACK_MASK);
     }
 
     void prepareAck(message_t* msg) {
@@ -577,6 +575,7 @@ implementation
 #endif
         return lt;
     }
+
     /**************** Init ************************/
     
     command error_t Init.init(){
@@ -675,8 +674,6 @@ implementation
             if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
         }
         else if(macState == RX_ACK) {
-            // if(call RssiAdcResource.isOwner()) call ChannelMonitor.start();
-            // sdDebug(132);
         }
         else if(macState == RX_ACK_P) {
         }
@@ -860,7 +857,7 @@ implementation
         rxStat.duplicate = PERF_UNKNOWN;
         rxStat.repCounter = 0xff;
 #endif
-        // sdDebug(190);
+        sdDebug(190);
         if(macState == RX_P) {
             // sdDebug(191);
             if(error == SUCCESS) {
@@ -894,14 +891,16 @@ implementation
 #endif
                             }
                         }
-#ifdef REDMAC_PERFORMANCE
                         else {
+#ifdef REDMAC_PERFORMANCE
                             rxStat.duplicate = PERF_REPEATED_MSG;
+#endif
                         }
-#endif                  
                         if(needsAckRx(msg, &level) && (action != RX)) {
-                            // sdDebug(197);
                             action = CCA_ACK;
+                            if(level == 2) {
+                                getMetadata(msg)->ack = WAS_ACKED;
+                            }
                         }
                         else {
                             // sdDebug(198);
@@ -1038,8 +1037,10 @@ implementation
         }
         else if(macState == TX_ACK) {
             checkCounter = 0;
-            macState = RX;
-            setRxMode();
+            macState = SLEEP;
+            setSleepMode();
+            // macState = RX;
+            // setRxMode();
             // sdDebug(221);
 #ifdef REDMAC_DEBUG            
             // sdDebug(40000U + repCounter);
@@ -1053,6 +1054,7 @@ implementation
         if(macState == RX_P) {
             rxTime = call LocalTime32kHz.get();
             call ChannelMonitor.rxSuccess();
+            sdDebug(221);
         }
     }
     
@@ -1203,9 +1205,8 @@ implementation
             // sdDebug(260);
         }
     }
-
+    
     /****** SampleTimer ******************************/
-
     async event void SampleTimer.fired() {
         call SampleTimer.start(localSleeptime);
         // sdDebug(270);
@@ -1326,7 +1327,7 @@ implementation
     async command void MacEval.increaseBackoff(bool value) {
         atomic INCREASE_BACKOFF = value;
     }
-    async command void MacEval.addNav(bool value) {
+    async command void MacEval.addNav(uint8_t value) {
         atomic ADD_NAV = value;
     }
     async command void MacEval.setLongRetry(uint8_t lr) {
index f5ff82b50994ea914330588e21cca342681d71fd..5988ed47ef6772cabde438cad89f83543d88a65a 100644 (file)
@@ -132,17 +132,12 @@ implementation
 
     /**************** Module Global Constants  *****************/
     enum {
-/*
-        BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
-        PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
-        PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
-        TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
-*/
-        BYTE_TIME=14,                 // byte at 35108 kBit/s, 4b6b encoded
-        PREAMBLE_BYTE_TIME=9,         // byte at 35108 kBit/s, no coding
-        PHY_HEADER_TIME=56,           // 6 Phy Preamble at 35108 bits/s
-        TIME_CORRECTION=11,           // difference between txSFD and rxSFD: to do
-                
+        
+        BYTE_TIME=ENCODED_32KHZ_BYTE_TIME,           // phy encoded
+        PREAMBLE_BYTE_TIME=TDA5250_32KHZ_BYTE_TIME,  // no coding
+        PHY_HEADER_TIME=6*PREAMBLE_BYTE_TIME,        // 6 Phy Preamble
+        TIME_CORRECTION=TDA5250_32KHZ_BYTE_TIME+2,   // difference between txSFD and rxSFD
+        
         SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
         SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
         DEFAULT_SLEEP_TIME=1625,
@@ -508,11 +503,13 @@ implementation
     }
     
     bool isNewMsg(message_t* msg) {
-        return call Duplicate.isNew(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
+        return call Duplicate.isNew(getHeader(msg)->src, getHeader(msg)->dest,
+                                    (getHeader(msg)->token) & TOKEN_ACK_MASK);
     }
     
     void rememberMsg(message_t* msg) {
-        call Duplicate.remember(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
+        call Duplicate.remember(getHeader(msg)->src, getHeader(msg)->dest,
+                                (getHeader(msg)->token) & TOKEN_ACK_MASK);
     }
 
     void prepareAck(message_t* msg) {
index dce79576a1fb2df597f2cebc611ac65ccf759a65..b8c9d6132d8649b256904333ce32ce2233036c15 100644 (file)
@@ -83,7 +83,7 @@ implementation
     /* constants */
     enum {
         PREAMBLE_LENGTH=2,
-        BYTE_TIME=ENCODED_32KHZ_BYTE_TIME+3,
+        BYTE_TIME=TDA5250_32KHZ_BYTE_TIME+3,
         PREAMBLE_BYTE=0x55,
         SYNC_BYTE=0xFF,
         SFD_BYTE=0x83,
index c52a9f5c6fa3a5f1406ce78b717dd342f03b68fb..c79b96e7e981063e4f1fc1307091b2877f697274 100644 (file)
@@ -75,7 +75,7 @@ implementation
     } phyState_t;
 
 #define PREAMBLE_LENGTH   2
-#define BYTE_TIME         TDA5250_32KHZ_BYTE_TIME
+#define BYTE_TIME         TDA5250_32KHZ_BYTE_TIME+3
 #define PREAMBLE_BYTE     0x55
 #define SYNC_BYTE         0xFF
 #define SFD_BYTE          0x50