X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fxe1205%2Fphy%2FXE1205PhyP.nc;h=7aedd4fd5df7882ac90ff54d9727709f5f6801cf;hb=dc4b87309a061e2a97f0a859ad5442f07930a1fd;hp=377ad953ea75bcbd57de65b10428968b6143a9a5;hpb=f05e333221d21758aa1d1ab77929e5d0238f5370;p=tinyos-2.x.git diff --git a/tos/chips/xe1205/phy/XE1205PhyP.nc b/tos/chips/xe1205/phy/XE1205PhyP.nc index 377ad953..7aedd4fd 100644 --- a/tos/chips/xe1205/phy/XE1205PhyP.nc +++ b/tos/chips/xe1205/phy/XE1205PhyP.nc @@ -73,7 +73,11 @@ implementation { uint8_t rxFrameLen = 0; uint8_t nextTxLen=0; uint8_t nextRxLen; - char rxFrame[xe1205_mtu]; + // Bugfix 29.1.2010: Plus 2 Bytes for the xe1205_phy_header_t + // defined in XE1205SendReceiveP.nc + // This is just a hack to make it work, this entire code needs + // to be cleaned up & documented! + char rxFrame[xe1205_mtu + 2]; uint8_t headerLen = 4; uint16_t stats_rxOverruns; @@ -142,7 +146,9 @@ implementation { call SpiResourceConfig.release(); atomic { if (state == RADIO_STARTING){ - post startDone();} + + post startDone(); + } if (state == RADIO_RX_ACK) { enableAck=FALSE; signal XE1205PhyRxTx.sendFrameDone(FAIL); @@ -161,17 +167,15 @@ implementation { command error_t SplitControl.start() { - atomic { - if (state == RADIO_LISTEN){ post startDone(); return SUCCESS;} - if (state != RADIO_SLEEP) return EBUSY; - state = RADIO_STARTING; - } - call XE1205PhySwitch.rxMode(); - call XE1205PhySwitch.antennaRx(); - - - call Alarm32khz16.start(usecs_to_jiffies(XE1205_Sleep_to_RX_Time)); - return SUCCESS; + atomic { + if (state == RADIO_LISTEN){ post startDone(); return SUCCESS;} + if (state != RADIO_SLEEP) return EBUSY; + state = RADIO_STARTING; + } + call XE1205PhySwitch.rxMode(); + call XE1205PhySwitch.antennaRx(); + call Alarm32khz16.start(usecs_to_jiffies(XE1205_Sleep_to_RX_Time)); + return SUCCESS; } command error_t SplitControl.stop() @@ -239,14 +243,14 @@ implementation { // so that we know precisely when last byte was received if (n > 16) { - if (n < 32) nextRxLen = n - 16; else nextRxLen = 15; + if (n < 32) nextRxLen = n - 15; else nextRxLen = 15; } else { nextRxLen = n; } } - command uint8_t XE1205PhyRssi.readRxRssi() { + async command uint8_t XE1205PhyRssi.readRxRssi() { return rssiTab[(rssiH<<2) |rssiL]; } @@ -282,9 +286,6 @@ implementation { error_t getRssi() { error_t err; - if(call SpiResourceRssi.immediateRequest() != SUCCESS) { - return FAIL; - } err = call XE1205RssiConf.setRssiMode(TRUE); err = ecombine(err,call XE1205RssiConf.setRssiRange(FALSE)); rssiRange=RSSI_RANGE_LOW; @@ -301,6 +302,11 @@ implementation { if (call XE1205PhyRxTx.off()) { return EOFF; } + + if(call SpiResourceRssi.immediateRequest() != SUCCESS) { + return FAIL; + } + err=getRssi(); if (SUCCESS ==err) { state = RADIO_RSSI; @@ -383,19 +389,19 @@ implementation { switch (state) { case RADIO_RX_ACK: - + call Alarm32khz16.stop(); case RADIO_LISTEN: rxByte=1; atomic state = RADIO_RX_HEADER; status = call SpiResourceRX.immediateRequest(); atomic { - if (status != SUCCESS) { - state = RADIO_LISTEN; - call Interrupt0.disable(); // because pattern detector won't be rearmed right away - call SpiResourceConfig.request(); - return; - } + if (status != SUCCESS) { + state = RADIO_LISTEN; + call Interrupt0.disable(); // because pattern detector won't be rearmed right away + call SpiResourceConfig.request(); + return; + } } call Alarm32khz16.start(3000); return; @@ -492,7 +498,6 @@ implementation { call XE1205PatternConf.loadAckPatternHasBus(); armPatternDetect(); call SpiResourceTX.release(); - call Alarm32khz16.start(usecs_to_jiffies(8000)); atomic { call Interrupt0.enableRisingEdge(); @@ -554,12 +559,9 @@ implementation { } else { enableAck = FALSE; - signal XE1205PhyRxTx.sendFrameDone(SUCCESS); + signal XE1205PhyRxTx.rxAckEnd(rxFrame, rxFrameLen + headerLen, SUCCESS); } - - - return; @@ -591,9 +593,9 @@ implementation { case RADIO_RX_HEADER: case RADIO_RX_PACKET: if (rssiRange!=RSSI_OFF) { - readRssi(); - return; - } + readRssi(); + return; + } stats_rxOverruns++; signal XE1205PhyRxTx.rxFrameEnd(NULL, 0, FAIL); @@ -609,7 +611,7 @@ implementation { return; case RADIO_RSSI: - readRssi(); + readRssi(); return; case RADIO_RX_ACK: // ack timeout @@ -631,11 +633,10 @@ implementation { } - signal XE1205PhyRxTx.sendFrameDone(FAIL); + signal XE1205PhyRxTx.sendFrameDone(ENOACK); return; default: - - + return; }