From 4c72ab7118395fe791aef9aafe29d501a94f6967 Mon Sep 17 00:00:00 2001 From: andreaskoepke Date: Thu, 5 Apr 2007 06:38:45 +0000 Subject: [PATCH] switch to metric MHz for SMCLK, adjust constants, include SmclkManager reduce baud rate for radio -- it can not handle more than 23kBit/s with a 50kHz frequency shift --- tos/chips/tda5250/Tda5250RadioP.nc | 3 +- tos/chips/tda5250/mac/CsmaMacP.nc | 32 ++--- tos/chips/tda5250/mac/RedMacC.nc | 4 +- tos/chips/tda5250/mac/RedMacP.nc | 128 ++++++++++-------- tos/lib/byte_radio/LinkLayerC.nc | 1 - tos/lib/byte_radio/LinkLayerP.nc | 16 +-- tos/lib/byte_radio/MacReceive.nc | 2 +- tos/lib/byte_radio/PacketSerializerP.nc | 8 +- tos/platforms/eyesIFX/RadioDataLinkC.nc | 2 + .../eyesIFX/byte_radio/Uart4b6bPhyC.nc | 3 - .../eyesIFX/byte_radio/Uart4b6bPhyP.nc | 4 +- .../eyesIFX/byte_radio/UartManchPhyP.nc | 6 +- .../eyesIFX/chips/msp430/Msp430DcoSpec.h | 45 ++++++ .../tda5250/tda5250BusResourceSettings.h | 8 +- .../chips/tda5250/tda5250RegDefaultSettings.h | 23 +++- tos/platforms/eyesIFX/eyesIFXSerialP.nc | 7 +- 16 files changed, 181 insertions(+), 111 deletions(-) create mode 100644 tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h diff --git a/tos/chips/tda5250/Tda5250RadioP.nc b/tos/chips/tda5250/Tda5250RadioP.nc index 9b82771c..a1ea56a8 100644 --- a/tos/chips/tda5250/Tda5250RadioP.nc +++ b/tos/chips/tda5250/Tda5250RadioP.nc @@ -137,9 +137,8 @@ implementation { switch(mode) { case RADIO_MODE_ON_TRANSITION: call HplTda5250Config.reset(); - // call HplTda5250Config.SetRFPower(240); + call HplTda5250Config.SetRFPower(INITIAL_RF_POWER); // call HplTda5250Config.SetClockOnDuringPowerDown(); - call HplTda5250Config.SetRFPower(255); call ConfigResource.release(); atomic radioMode = RADIO_MODE_ON; post startDoneTask(); diff --git a/tos/chips/tda5250/mac/CsmaMacP.nc b/tos/chips/tda5250/mac/CsmaMacP.nc index 585e6c2b..e19e50d1 100644 --- a/tos/chips/tda5250/mac/CsmaMacP.nc +++ b/tos/chips/tda5250/mac/CsmaMacP.nc @@ -87,31 +87,19 @@ 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=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 - 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 - - /* - BYTE_TIME=12, // byte at 40960 kBit/s, 4b6b encoded - PREAMBLE_BYTE_TIME=8, // byte at 40960 kBit/s, no coding - PHY_HEADER_TIME=48, // 6 Phy Preamble at 40960 - */ - 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 + SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc MAXTIMERVALUE=0xFFFF, // helps to compute backoff DATA_DETECT_TIME=17, - RX_SETUP_TIME=111, // time to set up receiver - TX_SETUP_TIME=69, // time to set up transmitter + RX_SETUP_TIME=102, // time to set up receiver + TX_SETUP_TIME=58, // time to set up transmitter ADDED_DELAY = 30, - RX_ACK_TIMEOUT=RX_SETUP_TIME + PHY_HEADER_TIME + 19 + 2*ADDED_DELAY, - TX_GAP_TIME=RX_ACK_TIMEOUT + TX_SETUP_TIME + 11, + RX_ACK_TIMEOUT=RX_SETUP_TIME + PHY_HEADER_TIME + 2*ADDED_DELAY, + TX_GAP_TIME=RX_ACK_TIMEOUT + TX_SETUP_TIME + 33, MAX_SHORT_RETRY=7, MAX_LONG_RETRY=4, BACKOFF_MASK=0xFFF, // minimum time around one packet time @@ -340,10 +328,10 @@ implementation restLaufzeit = restLaufzeit - now; } else { - restLaufzeit += MAXTIMERVALUE - now; + restLaufzeit = (uint16_t)(-1) - restLaufzeit + now; } if(restLaufzeit > BACKOFF_MASK) { - restLaufzeit = backoff(0); + restLaufzeit = call Random.rand16() & 0xFF; } setFlag(&flags, RESUME_BACKOFF); } diff --git a/tos/chips/tda5250/mac/RedMacC.nc b/tos/chips/tda5250/mac/RedMacC.nc index 227372fe..ce862cb9 100644 --- a/tos/chips/tda5250/mac/RedMacC.nc +++ b/tos/chips/tda5250/mac/RedMacC.nc @@ -95,8 +95,8 @@ implementation { RedMacP.Timer -> Timer; RedMacP.SampleTimer -> SampleTimer; RedMacP.Counter32khz16 -> Counter; -/* - components PlatformLedsC; + +/* components PlatformLedsC; RedMacP.Led0 -> PlatformLedsC.Led0; RedMacP.Led1 -> PlatformLedsC.Led1; RedMacP.Led2 -> PlatformLedsC.Led2; diff --git a/tos/chips/tda5250/mac/RedMacP.nc b/tos/chips/tda5250/mac/RedMacP.nc index a21e1b8c..c7cd5153 100644 --- a/tos/chips/tda5250/mac/RedMacP.nc +++ b/tos/chips/tda5250/mac/RedMacP.nc @@ -74,6 +74,12 @@ module RedMacP { interface Alarm as SampleTimer; interface Counter as Counter32khz16; async command am_addr_t amAddress(); +/* + interface GeneralIO as Led0; + interface GeneralIO as Led1; + interface GeneralIO as Led2; + interface GeneralIO as Led3; +*/ #ifdef REDMAC_DEBUG interface SerialDebug; #endif @@ -103,52 +109,41 @@ implementation void sdDebug(uint16_t p) { call SerialDebug.putPlace(p); } + uint8_t repCounter; #else void sdDebug(uint16_t p) {}; #endif /**************** 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 -/* - BYTE_TIME=12, // byte at 40960 kBit/s, 4b6b encoded - PREAMBLE_BYTE_TIME=8, // byte at 40960 kBit/s, no coding - PHY_HEADER_TIME=48, // 6 Phy Preamble at 40960 -*/ - SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(tda5250_header_t)*BYTE_TIME, + 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=15, // difference between sendSFD and rxSFD, to do: measure! + + 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=3250, // DEFAULT_SLEEP_TIME=6500, // DEFAULT_SLEEP_TIME=9750, DEFAULT_SLEEP_TIME=16384, + // DEFAULT_SLEEP_TIME=32768U, DATA_DETECT_TIME=17, - RX_SETUP_TIME=111, // time to set up receiver - TX_SETUP_TIME=69, // time to set up transmitter - ADDED_DELAY = PREAMBLE_BYTE_TIME, - RX_ACK_TIMEOUT = RX_SETUP_TIME + PHY_HEADER_TIME + 2*ADDED_DELAY + 19, - TX_GAP_TIME=RX_ACK_TIMEOUT + TX_SETUP_TIME + 11, + RX_SETUP_TIME=102, // time to set up receiver + TX_SETUP_TIME=58, // time to set up transmitter + ADDED_DELAY = 30, + RX_ACK_TIMEOUT = RX_SETUP_TIME + PHY_HEADER_TIME + ADDED_DELAY + 30, + TX_GAP_TIME = RX_ACK_TIMEOUT + TX_SETUP_TIME + 33, // the duration of a send ACK ACK_DURATION = SUB_HEADER_TIME + SUB_FOOTER_TIME, - MAX_SHORT_RETRY=7, - MAX_LONG_RETRY=2, + MAX_SHORT_RETRY=9, + MAX_LONG_RETRY=1, MAX_AGE=2*MAX_LONG_RETRY*MAX_SHORT_RETRY, MSG_TABLE_ENTRIES=20, TOKEN_ACK_FLAG = 64, TOKEN_ACK_MASK = 0x3f, - /* correct the difference between the transmittedSFD and the receivedSFD - that appears due to buffering, measured value on an osci is 320us, so this - value is actually 10.48576 - */ - TIME_CORRECTION = 10, INVALID_SNR = 0xffff, // PREAMBLE_LONG = 5, // PREAMBLE_SHORT = 2, @@ -292,16 +287,17 @@ implementation checkCounter = 0; setRxMode(); } - else { - if(txBufPtr) sdDebug(41); - if(shortRetryCounter) sdDebug(42); - if(isFlagSet(&flags, MESSAGE_PREPARED)) sdDebug(43); +/* else { + if(txBufPtr) // sdDebug(41); + if(shortRetryCounter) // sdDebug(42); + if(isFlagSet(&flags, MESSAGE_PREPARED)) // sdDebug(43); if(txBufPtr) { - if(macState == SLEEP) sdDebug(44); - if(!isFlagSet(&flags, RESUME_BACKOFF)) sdDebug(45); - if(!call Timer.isRunning()) sdDebug(46); + if(macState == SLEEP) // sdDebug(44); + if(!isFlagSet(&flags, RESUME_BACKOFF)) // sdDebug(45); + if(!call Timer.isRunning()) // sdDebug(46); } } +*/ } uint32_t backoff(uint8_t counter) { @@ -415,8 +411,8 @@ implementation clearFlag(&flags, MESSAGE_PREPARED); clearFlag(&flags, CANCEL_SEND); } - sdDebug(3000 + e); - sdDebug(4000 + getHeader(m)->type); + // sdDebug(3000 + e); + // sdDebug(4000 + getHeader(m)->type); signal MacSend.sendDone(m, e); } @@ -426,7 +422,7 @@ implementation longRetryCounter++; shortRetryCounter = 1; if(longRetryCounter > MAX_LONG_RETRY) { - sdDebug(60); + // sdDebug(60); signalSendDone(FAIL); } } @@ -438,7 +434,7 @@ implementation longRetryCounter++; shortRetryCounter = 1; if(longRetryCounter > MAX_LONG_RETRY) { - sdDebug(70); + // sdDebug(70); signalSendDone(FAIL); } else { post PrepareMsgTask(); @@ -534,6 +530,9 @@ implementation getHeader(&ackMsg)->src = call amAddress(); getHeader(&ackMsg)->dest = getHeader(msg)->src; getHeader(&ackMsg)->type = getHeader(msg)->type; +#ifdef REDMAC_DEBUG + repCounter = ((red_mac_header_t *)call SubPacket.getPayload(msg, NULL))->repetitionCounter; +#endif } uint32_t calcGeneratedTime(red_mac_header_t *m) { @@ -720,7 +719,7 @@ implementation } async event void RadioModes.SleepModeDone() { - sdDebug(160); + // sdDebug(160); atomic { clearFlag(&flags, SWITCHING); if(isFlagSet(&flags, ACTION_DETECTED)) { @@ -728,7 +727,7 @@ implementation } else { if(congestionLevel > 0) congestionLevel--; } - if(congestionLevel > 3) sdDebug(2000 + congestionLevel); + // if(congestionLevel > 3) // sdDebug(2000 + congestionLevel); if(macState == SLEEP) { // sdDebug(161); if(!call Timer.isRunning()) { @@ -763,7 +762,7 @@ implementation atomic { if((shortRetryCounter == 0) && (txBufPtr == NULL)) { clearFlag(&flags, MESSAGE_PREPARED); - sdDebug(5000 + getHeader(msg)->type); + // sdDebug(5000 + getHeader(msg)->type); shortRetryCounter = 1; longRetryCounter = 1; txBufPtr = msg; @@ -786,23 +785,23 @@ implementation error_t err = FAIL; atomic { if(msg == txBufPtr) { - sdDebug(320); + // sdDebug(320); setFlag(&flags, CANCEL_SEND); shortRetryCounter = MAX_SHORT_RETRY + 2; longRetryCounter = MAX_LONG_RETRY + 2; if(macState == SLEEP) { - sdDebug(321); + // sdDebug(321); signalSendDone(ECANCEL); } else { - sdDebug(322); + // sdDebug(322); } - sdDebug(1000 + macState); + // sdDebug(1000 + macState); err = SUCCESS; } else { - sdDebug(323); - sdDebug(1100 + macState); + // sdDebug(323); + // sdDebug(1100 + macState); } } return err; @@ -857,7 +856,8 @@ implementation (getMetadata(m))->strength = 1; } } - (getMetadata(msg))->time = calcGeneratedTime((red_mac_header_t*) payload); + getMetadata(msg)->time = calcGeneratedTime((red_mac_header_t*) payload); + getMetadata(msg)->ack = WAS_NOT_ACKED; m = signal MacReceive.receiveDone(msg); // assume a buffer swap -- if buffer is not swapped, assume that the // message was not successfully delivered to upper layers @@ -924,8 +924,9 @@ implementation signal Teamgeist.gotAck(txBufPtr, getHeader(msg)->src, getMetadata(txBufPtr)->strength); } - sdDebug(203); + // sdDebug(203); signalSendDone(SUCCESS); + // sdDebug(30000 + getHeader(msg)->src); action = SLEEP; } else { @@ -935,7 +936,7 @@ implementation } else { if(call Timer.isRunning()) { - // sdDebug(204); + sdDebug(204); action = RX_ACK; } else { @@ -950,9 +951,15 @@ implementation action = INIT; } if(action == CCA_ACK) { - prepareAck(msg); macState = CCA_ACK; - call Timer.start(RX_SETUP_TIME - TX_SETUP_TIME + (ADDED_DELAY>>level)); + if(call Random.rand16() & 2) { + call Timer.start(RX_SETUP_TIME - TX_SETUP_TIME + 16 - level*8 + ADDED_DELAY); + } + else { + macState = TX_ACK; + call Timer.start(RX_SETUP_TIME - TX_SETUP_TIME + 16); + } + prepareAck(msg); } else if(action == RX_ACK) { macState = RX_ACK; @@ -969,7 +976,7 @@ implementation } else { setFlag(&flags, RESUME_BACKOFF); - restLaufzeit = nav + backoff(longRetryCounter); + restLaufzeit = call Random.rand16() & ZERO_BACKOFF_MASK; } setSleepMode(); } @@ -984,16 +991,20 @@ implementation async event void PacketSend.sendDone(message_t* msg, error_t error) { if(macState == TX) { - // sdDebug(220); macState = RX_ACK; setRxMode(); call Timer.start(RX_ACK_TIMEOUT); + sdDebug(220); checkCounter = 0; } else if(macState == TX_ACK) { checkCounter = 0; macState = RX; setRxMode(); + sdDebug(221); +#ifdef REDMAC_DEBUG + // sdDebug(40000U + repCounter); +#endif } } @@ -1084,6 +1095,7 @@ implementation // sdDebug(244); macState = TX_ACK; setTxMode(); + sdDebug(20000 + getHeader(&ackMsg)->dest); } } @@ -1103,13 +1115,13 @@ implementation } else if(macState == RX_ACK) { if(prepareRepetition()) { - // sdDebug(253); + sdDebug(253); macState = TX; setTxMode(); } else { if(needsAckTx(txBufPtr)) { - // sdDebug(254); + sdDebug(254); updateLongRetryCounters(); } else { @@ -1120,6 +1132,10 @@ implementation setSleepMode(); } } + else if(macState == TX_ACK) { + setTxMode(); + sdDebug(10000 + getHeader(&ackMsg)->dest); + } else if(macState == SLEEP) { if(isFlagSet(&flags, SWITCHING)) { // sdDebug(256); @@ -1263,7 +1279,7 @@ implementation } default async event void ChannelCongestion.congestionEvent(uint8_t level) {} - + /***** unused Radio Modes events **************************/ async event void RadioModes.TimerModeDone() {} diff --git a/tos/lib/byte_radio/LinkLayerC.nc b/tos/lib/byte_radio/LinkLayerC.nc index 02dd7682..0bed3137 100644 --- a/tos/lib/byte_radio/LinkLayerC.nc +++ b/tos/lib/byte_radio/LinkLayerC.nc @@ -53,7 +53,6 @@ implementation { components LinkLayerP as Llc, MainC; - MainC.SoftwareInit -> Llc; SplitControl = Llc; MacSplitControl = Llc.MacSplitControl; diff --git a/tos/lib/byte_radio/LinkLayerP.nc b/tos/lib/byte_radio/LinkLayerP.nc index 023d10f8..84361ec9 100644 --- a/tos/lib/byte_radio/LinkLayerP.nc +++ b/tos/lib/byte_radio/LinkLayerP.nc @@ -60,9 +60,6 @@ implementation message_t* rxBufPtr; message_t rxBuf; - /* packet vars */ - uint8_t seqNo; // for later use ... - /* state vars */ error_t splitStateError; // state of SplitControl interfaces bool rxBusy; // blocks an incoming packet if the rxBuffer is in use @@ -84,7 +81,6 @@ implementation atomic { rxBufPtr = &rxBuf; txBufPtr = 0; - seqNo = 0; splitStateError = EOFF; rxBusy = FALSE; } @@ -161,8 +157,11 @@ implementation } command error_t Send.send(message_t *msg, uint8_t len) { - ++seqNo; // where to put? - return call SendDown.send(msg, len); + if(getMetadata(msg)->ack != NO_ACK_REQUESTED) { + // ensure reasonable value + getMetadata(msg)->ack = ACK_REQUESTED; + } + return call SendDown.send(msg, len); } command error_t Send.cancel(message_t* msg) { @@ -212,7 +211,8 @@ implementation atomic { if (rxBusy) { msgPtr = msg; - } else { + } + else { rxBusy = TRUE; msgPtr = rxBufPtr; rxBufPtr = msg; @@ -221,7 +221,7 @@ implementation } return msgPtr; } - + command void* Receive.getPayload(message_t* msg, uint8_t* len) { return call Packet.getPayload(msg, len); } diff --git a/tos/lib/byte_radio/MacReceive.nc b/tos/lib/byte_radio/MacReceive.nc index 8ad9302c..54d7cba6 100644 --- a/tos/lib/byte_radio/MacReceive.nc +++ b/tos/lib/byte_radio/MacReceive.nc @@ -62,5 +62,5 @@ interface MacReceive { * received packet. */ async event message_t* receiveDone(message_t* msg); - + } diff --git a/tos/lib/byte_radio/PacketSerializerP.nc b/tos/lib/byte_radio/PacketSerializerP.nc index e495ef59..2d21c682 100644 --- a/tos/lib/byte_radio/PacketSerializerP.nc +++ b/tos/lib/byte_radio/PacketSerializerP.nc @@ -100,7 +100,7 @@ implementation { } async event void PhyPacketTx.sendHeaderDone() { - TransmitNextByte(); + TransmitNextByte(); } async event void RadioByteComm.txByteReady(error_t error) { @@ -114,7 +114,9 @@ implementation { void TransmitNextByte() { message_radio_header_t* header = getHeader((message_t*) txBufPtr); if (byteCnt < header->length + sizeof(message_header_t) ) { // send (data + header), compute crc - if(byteCnt == sizeof(message_header_t)) signal RadioTimeStamping.transmittedSFD(0, (message_t*)txBufPtr); + if(byteCnt == sizeof(message_header_t)) { + signal RadioTimeStamping.transmittedSFD(0, (message_t*)txBufPtr); + } crc = crcByte(crc, ((uint8_t *)(txBufPtr))[byteCnt]); call RadioByteComm.txByte(((uint8_t *)(txBufPtr))[byteCnt++]); } else if (byteCnt == (header->length + sizeof(message_header_t))) { @@ -124,7 +126,7 @@ implementation { ++byteCnt; call RadioByteComm.txByte((uint8_t)(crc >> 8)); } else { /* (byteCnt > (header->length + sizeof(message_header_t)+1)) */ - call PhyPacketTx.sendFooter(); + call PhyPacketTx.sendFooter(); } } diff --git a/tos/platforms/eyesIFX/RadioDataLinkC.nc b/tos/platforms/eyesIFX/RadioDataLinkC.nc index ae0a096b..d9109daf 100644 --- a/tos/platforms/eyesIFX/RadioDataLinkC.nc +++ b/tos/platforms/eyesIFX/RadioDataLinkC.nc @@ -87,4 +87,6 @@ implementation PacketSerializer.PhyPacketRx -> UartPhy.PhyPacketRx; UartPhy.RadioByteComm -> Radio.RadioByteComm; + + components SmclkManagerC; } diff --git a/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyC.nc b/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyC.nc index 364bb494..fe2fb3be 100644 --- a/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyC.nc +++ b/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyC.nc @@ -54,7 +54,6 @@ implementation components new Alarm32khz16C() as RxByteTimer, Uart4b6bPhyP, - // PlatformLedsC, MainC; MainC.SoftwareInit -> Uart4b6bPhyP; @@ -65,6 +64,4 @@ implementation UartPhyControl = Uart4b6bPhyP; Uart4b6bPhyP.RxByteTimer -> RxByteTimer; -// PlatformLedsC.Led3 <- Uart4b6bPhyP.Led3; -// PlatformLedsC.Led1 <- Uart4b6bPhyP.Led1; } diff --git a/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc b/tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc index 07a1106f..4b830dfe 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=9, + BYTE_TIME=21, PREAMBLE_BYTE=0x55, SYNC_BYTE=0xFF, SFD_BYTE=0x83, @@ -198,7 +198,7 @@ implementation void TransmitNextByte() { switch(phyState) { case STATE_PREAMBLE: - if(preambleCount > 0) { + if(preambleCount > 1) { preambleCount--; } else { phyState = STATE_SYNC; diff --git a/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc b/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc index 2294ef6a..0b39150e 100644 --- a/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc +++ b/tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc @@ -74,8 +74,8 @@ implementation STATE_FOOTER_DONE } phyState_t; -#define PREAMBLE_LENGTH 4 -#define BYTE_TIME 9 +#define PREAMBLE_LENGTH 2 +#define BYTE_TIME 21 #define PREAMBLE_BYTE 0x55 #define SYNC_BYTE 0xFF #define SFD_BYTE 0x50 @@ -198,7 +198,7 @@ implementation atomic { switch(phyState) { case STATE_PREAMBLE: - if(preambleCount > 0) { + if(preambleCount > 1) { preambleCount--; } else { phyState = STATE_SYNC; diff --git a/tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h b/tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h new file mode 100644 index 00000000..98bf085a --- /dev/null +++ b/tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h @@ -0,0 +1,45 @@ +/* -*- mode:c++; indent-tabs-mode: nil -*- + * Copyright (c) 2007, Technische Universitaet Berlin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - Neither the name of the Technische Universitaet Berlin nor the names + * of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES {} LOSS OF USE, DATA, + * OR PROFITS {} OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Override default dco clock spec. + * + * SMCLK runs on 1MHz for this platform, its * source may be the radio -- a + * more reliable source. + * + * @author: Andreas Koepke (koepke@tkn.tu-berlin.de) + */ + + +#ifndef MS430DCOSPEC_H +#define MS430DCOSPEC_H + +#define TARGET_DCO_HZ 4000000 // the cpu clock rate in Hz + +#endif diff --git a/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h b/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h index 31b03199..213d30a0 100644 --- a/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h +++ b/tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h @@ -39,14 +39,12 @@ 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 + // real milli seconds + UBR_1MHZ_23405=0x002A, UMCTL_1MHZ_23405=0xDD, // 23405 bit/s }; -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} }; +msp430_uart_union_config_t tda5250_uart_config = { {ubr: UBR_1MHZ_23405, umctl: UMCTL_1MHZ_23405, 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 diff --git a/tos/platforms/eyesIFX/chips/tda5250/tda5250RegDefaultSettings.h b/tos/platforms/eyesIFX/chips/tda5250/tda5250RegDefaultSettings.h index 7392c5ad..ab971287 100644 --- a/tos/platforms/eyesIFX/chips/tda5250/tda5250RegDefaultSettings.h +++ b/tos/platforms/eyesIFX/chips/tda5250/tda5250RegDefaultSettings.h @@ -43,10 +43,29 @@ // Default values of data registers -#define TDA5250_REG_DEFAULT_SETTING_CONFIG 0x84F9 +/** regulate distance by switching the amplifiers */ +// longest distance +#define FULL_RANGE 0x84F9 +// shorter distance; low rx, high tx energy consumption (30m) +#define MED_RANGE_LP 0x84E9 +// shorter distance; high rx, low tx energy consumption (25m) +#define MED_RANGE_HP 0x84F8 +// shortest: low rx; low tx energy consumption (1m to 3m range) +#define TABLE_TOP 0x84E8 + +/** regulate distance using variable resistor */ +#define RF_DAMPING_0dB 255 +#define RF_DAMPING_5dB 248 +#define RF_DAMPING_10dB 245 +#define RF_DAMPING_15dB 241 +#define RF_DAMPING_20dB 239 + +#define INITIAL_RF_POWER RF_DAMPING_0dB + +#define TDA5250_REG_DEFAULT_SETTING_CONFIG FULL_RANGE #define TDA5250_REG_DEFAULT_SETTING_FSK 0x0A0C #define TDA5250_REG_DEFAULT_SETTING_XTAL_TUNING 0x0012 -#define TDA5250_REG_DEFAULT_SETTING_LPF 0x6A +#define TDA5250_REG_DEFAULT_SETTING_LPF 0x68 #define TDA5250_REG_DEFAULT_SETTING_ON_TIME 0xFEC0 #define TDA5250_REG_DEFAULT_SETTING_OFF_TIME 0xF380 #define TDA5250_REG_DEFAULT_SETTING_COUNT_TH1 0x0000 diff --git a/tos/platforms/eyesIFX/eyesIFXSerialP.nc b/tos/platforms/eyesIFX/eyesIFXSerialP.nc index dc93e52a..933b288e 100644 --- a/tos/platforms/eyesIFX/eyesIFXSerialP.nc +++ b/tos/platforms/eyesIFX/eyesIFXSerialP.nc @@ -4,7 +4,12 @@ module eyesIFXSerialP { uses interface Resource; } implementation { - msp430_uart_union_config_t msp430_uart_eyes_config = { {ubr: UBR_1MHZ_57600, umctl: UMCTL_1MHZ_57600, 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: 1} }; + enum { + // true mega hertz + UBR_1MHZ_57601=0x0011, UMCTL_1MHZ_57601=0x52 // 57600 bit/s + }; + + msp430_uart_union_config_t msp430_uart_eyes_config = { {ubr: UBR_1MHZ_57601, umctl: UMCTL_1MHZ_57601, 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: 1} }; command error_t StdControl.start(){ return call Resource.immediateRequest(); -- 2.39.2