From: andreaskoepke Date: Tue, 27 Feb 2007 19:18:24 +0000 (+0000) Subject: increase raw bit rate from 38400 to 49000 bits/s X-Git-Tag: tinyos/2.0.1~156 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=a9632e7a519a6e65552bd9aaa2d02aab001221b1;p=tinyos-2.x.git increase raw bit rate from 38400 to 49000 bits/s --- diff --git a/tos/chips/tda5250/mac/CsmaMacP.nc b/tos/chips/tda5250/mac/CsmaMacP.nc index 495837b9..68111568 100644 --- a/tos/chips/tda5250/mac/CsmaMacP.nc +++ b/tos/chips/tda5250/mac/CsmaMacP.nc @@ -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 diff --git a/tos/chips/tda5250/mac/RedMacP.nc b/tos/chips/tda5250/mac/RedMacP.nc index 8d31b8de..38b6a48e 100644 --- a/tos/chips/tda5250/mac/RedMacP.nc +++ b/tos/chips/tda5250/mac/RedMacP.nc @@ -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); diff --git a/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc b/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc index febe95c1..07a1106f 100644 --- a/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc +++ b/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc @@ -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, diff --git a/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc b/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc index 3021ff79..2294ef6a 100644 --- a/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc +++ b/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc @@ -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 diff --git a/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h b/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h index b04824cb..31b03199 100644 --- a/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h +++ b/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h @@ -39,8 +39,14 @@ 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