]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
increase raw bit rate from 38400 to 49000 bits/s
authorandreaskoepke <andreaskoepke>
Tue, 27 Feb 2007 19:18:24 +0000 (19:18 +0000)
committerandreaskoepke <andreaskoepke>
Tue, 27 Feb 2007 19:18:24 +0000 (19:18 +0000)
tos/chips/tda5250/mac/CsmaMacP.nc
tos/chips/tda5250/mac/RedMacP.nc
tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc
tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc
tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h

index 495837b901130c52d00a736b100863a03cf45c04..68111568ce5aa54fcfc0653a0cc90aa9ed585297 100644 (file)
@@ -87,9 +87,16 @@ implementation
 {
 
     enum {
+        /*
         BYTE_TIME=13,                // byte at 38400 kBit/s, 4b6b encoded
         PREAMBLE_BYTE_TIME=9,        // byte at 38400 kBit/s, no coding
         PHY_HEADER_TIME=51,          // 6 Phy Preamble at 38400
+        */
+
+        BYTE_TIME=10,                // byte at 49000 kBit/s, 4b6b encoded
+        PREAMBLE_BYTE_TIME=7,        // byte at 49000 kBit/s, no coding
+        PHY_HEADER_TIME=40,          // 6 Phy Preamble at 49000
+
         SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(tda5250_header_t)*BYTE_TIME,
         SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 38400 kBit/s with 4b6b encoding
         MAXTIMERVALUE=0xFFFF,        // helps to compute backoff
index 8d31b8dea4e9536dc9a888d30707f4de724aca4b..38b6a48ec6d2c6c0991b005cf1e10a0348902ba9 100644 (file)
@@ -186,21 +186,27 @@ implementation
 
     /**************** Module Global Constants  *****************/
     enum {
+/*
         BYTE_TIME=13,                // byte at 38400 kBit/s, 4b6b encoded
         PREAMBLE_BYTE_TIME=9,        // byte at 38400 kBit/s, no coding
         PHY_HEADER_TIME=51,          // 6 Phy Preamble at 38400
+*/
+        BYTE_TIME=10,                // byte at 49000 kBit/s, 4b6b encoded
+        PREAMBLE_BYTE_TIME=7,        // byte at 49000 kBit/s, no coding
+        PHY_HEADER_TIME=40,          // 6 Phy Preamble at 49000
+
         SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(tda5250_header_t)*BYTE_TIME,
-        SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 38400 kBit/s with 4b6b encoding
-        MAX_TIME_VALUE=0xFFFFFFFF,
-        MAXTIMERVALUE=0xFFFF,        // helps to compute backoff
+        SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
+        // DEFAULT_SLEEP_TIME=1625,
         DEFAULT_SLEEP_TIME=3250,
         // DEFAULT_SLEEP_TIME=6500,
         // DEFAULT_SLEEP_TIME=9750,
+        // DEFAULT_SLEEP_TIME=16384,
         DATA_DETECT_TIME=17,
         RX_SETUP_TIME=111,    // time to set up receiver
         TX_SETUP_TIME=69,     // time to set up transmitter
-        ADDED_DELAY = 40,
-        RX_ACK_TIMEOUT = RX_SETUP_TIME + PHY_HEADER_TIME + 29 + 2*ADDED_DELAY,
+        ADDED_DELAY = 20,
+        RX_ACK_TIMEOUT = RX_SETUP_TIME + PHY_HEADER_TIME + 14 + 2*ADDED_DELAY,
         TX_GAP_TIME=RX_ACK_TIMEOUT + TX_SETUP_TIME + 11,
         // the duration of a send ACK
         ACK_DURATION = SUB_HEADER_TIME + SUB_FOOTER_TIME,
@@ -218,9 +224,10 @@ implementation
         INVALID_SNR = 0xffff,
         PREAMBLE_LONG = 6,
         PREAMBLE_SHORT = 2,
+        // reduced minimal backoff
+        ZERO_BACKOFF_MASK = 0xff
     };
     
-
     /**************** Module Global Variables  *****************/
     typedef union 
     {
@@ -347,6 +354,8 @@ implementation
     }
 
     /**************** Helper functions ************************/
+    void computeBackoff();
+    
     void checkSend() {
         storeOldState(10);
         if((shortRetryCounter) && (txBufPtr != NULL) && (isFlagSet(&flags, MESSAGE_PREPARED)) && 
@@ -360,7 +369,7 @@ implementation
 
     uint32_t backoff(uint8_t counter) {
         uint32_t rVal = call Random.rand16() &  MIN_BACKOFF_MASK;
-        return rVal << counter;
+        return (rVal << counter) + ZERO_BACKOFF_MASK;
     }
     
     bool needsAckTx(message_t* msg) {
@@ -422,7 +431,13 @@ implementation
             txMacHdr = macHdr;
             setFlag(&flags, MESSAGE_PREPARED);
             if((macState == SLEEP) && (!call Timer.isRunning()) && (!isFlagSet(&flags, RESUME_BACKOFF))) {
-                call Timer.start(backoff(longRetryCounter));
+                if((longRetryCounter == 1) &&
+                   (getHeader(msg)->dest != AM_BROADCAST_ADDR)) {
+                    call Timer.start((call Random.rand16() >> 3) & ZERO_BACKOFF_MASK);
+                }
+                else {
+                    call Timer.start(backoff(longRetryCounter));
+                }
             }
         }
     }
@@ -504,10 +519,10 @@ implementation
                 restLaufzeit = restLaufzeit - now;
             }
             else {
-                restLaufzeit +=  MAXTIMERVALUE - now;
+                restLaufzeit =  (uint16_t)(-1) - restLaufzeit + now;
             }
             if(restLaufzeit > MIN_BACKOFF_MASK << MAX_LONG_RETRY) {
-                restLaufzeit = backoff(0);
+                restLaufzeit = call Random.rand16() & ZERO_BACKOFF_MASK;
             }
             setFlag(&flags, RESUME_BACKOFF);
         }
@@ -780,16 +795,18 @@ implementation
             } else {
                 if(congestionLevel > 0) congestionLevel--;
             }
-            if((macState == SLEEP) && (!call Timer.isRunning())) {
-                if(isFlagSet(&flags, RESUME_BACKOFF)) {
-                    storeOldState(61);
-                    clearFlag(&flags, RESUME_BACKOFF);
-                    call Timer.start(restLaufzeit);
-                    restLaufzeit = 0;
-                }
-                else {
-                    storeOldState(62);
-                    checkSend();
+            if(macState == SLEEP) {
+                if(!call Timer.isRunning()) {
+                    if(isFlagSet(&flags, RESUME_BACKOFF)) {
+                        storeOldState(61);
+                        clearFlag(&flags, RESUME_BACKOFF);
+                        call Timer.start(restLaufzeit);
+                        restLaufzeit = 0;
+                    }
+                    else {
+                        storeOldState(62);
+                        checkSend();
+                    }
                 }
             }
             else if(macState == INIT) {
@@ -1064,7 +1081,7 @@ implementation
             }
             else {
                 // assume a clock wrap here
-                txMacHdr->time = MAX_TIME_VALUE - mTime + now;
+                txMacHdr->time = (uint32_t)(-1) - mTime + now;
             }
         }
     }
@@ -1074,16 +1091,16 @@ implementation
         atomic {
             time.lo = call Counter32khz16.get();
             time.hi = counter2sec;
+            if(call Counter32khz16.isOverflowPending()) ++time.hi;
         }
         return time.op;
     }
     
     async event void Counter32khz16.overflow() {
-        counter2sec++;
+        ++counter2sec;
     }
 
-    
-    
+
     /****** Timer ******************************/
 
     void checkOnBusy() {
@@ -1110,7 +1127,7 @@ implementation
             }
             else {
                 storeOldState(154);
-                call Timer.start(TX_GAP_TIME>>1);
+                call Timer.start(TX_GAP_TIME >> 1);
                 requestAdc();
             }
         }
@@ -1118,7 +1135,7 @@ implementation
             checkCounter++;
             if(checkCounter < 3) {
                 storeOldState(158);                
-                call Timer.start((TX_GAP_TIME + backoff(0))>>1);
+                call Timer.start(TX_GAP_TIME >> 1);
                 requestAdc();
             }
             else {
@@ -1171,7 +1188,7 @@ implementation
         else if(macState == SLEEP) {
              if(isFlagSet(&flags, SWITCHING)) {
                  storeOldState(106);
-                 call Timer.start(backoff(0));
+                 call Timer.start(call Random.rand16() & 0x0f);
              }
              else {
                  storeOldState(107);
index febe95c1dd05414698215a7b70d25125226ba7b9..07a1106f05868718aed53d873faa3fee935ddec6 100644 (file)
@@ -72,7 +72,7 @@ implementation
     /* constants */
     enum {
         PREAMBLE_LENGTH=2,
-        BYTE_TIME=11,
+        BYTE_TIME=9,
         PREAMBLE_BYTE=0x55,
         SYNC_BYTE=0xFF,
         SFD_BYTE=0x83,
index 3021ff79a8dac3f0e75e4638d7b5c34eedf6e6b8..2294ef6a4d1eba7a13c563182d2eef010d4d51e4 100644 (file)
@@ -75,7 +75,7 @@ implementation
     } phyState_t;
 
 #define PREAMBLE_LENGTH   4
-#define BYTE_TIME         18
+#define BYTE_TIME         9
 #define PREAMBLE_BYTE     0x55
 #define SYNC_BYTE         0xFF
 #define SFD_BYTE          0x50
index b04824cb70b5f364690fed7f88e1ffb8ffd1f014..31b03199787e94a6439ed84ae2082e04dc26f102 100644 (file)
 enum {
     TDA5250_UART_BUS_ID = unique(MSP430_UARTO_BUS)
 };
-
+/*
 msp430_uart_union_config_t tda5250_uart_config = { {ubr: UBR_1MHZ_38400, umctl: UMCTL_1MHZ_38400, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0, urxe: 1, utxe: 0} };
+*/
+
+enum {
+    UBR_1MHZ_49000=0x0015,  UMCTL_1MHZ_49000=0x92
+};
 
+msp430_uart_union_config_t tda5250_uart_config = { {ubr: UBR_1MHZ_49000, umctl: UMCTL_1MHZ_49000, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0, urxe: 1, utxe: 0} };
 
 #endif