X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fxe1205%2Fphy%2FXE1205PhyP.nc;h=7aedd4fd5df7882ac90ff54d9727709f5f6801cf;hb=dc4b87309a061e2a97f0a859ad5442f07930a1fd;hp=d43dc4685a7ec63f63d4aa8267dcf342cf89d99f;hpb=37eb2fbdf917d2540ea6b01d29cbf041494eb8e4;p=tinyos-2.x.git diff --git a/tos/chips/xe1205/phy/XE1205PhyP.nc b/tos/chips/xe1205/phy/XE1205PhyP.nc index d43dc468..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() @@ -246,7 +250,7 @@ implementation { } } - command uint8_t XE1205PhyRssi.readRxRssi() { + async command uint8_t XE1205PhyRssi.readRxRssi() { return rssiTab[(rssiH<<2) |rssiL]; } @@ -385,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; @@ -494,7 +498,6 @@ implementation { call XE1205PatternConf.loadAckPatternHasBus(); armPatternDetect(); call SpiResourceTX.release(); - call Alarm32khz16.start(usecs_to_jiffies(8000)); atomic { call Interrupt0.enableRisingEdge(); @@ -556,12 +559,9 @@ implementation { } else { enableAck = FALSE; - signal XE1205PhyRxTx.sendFrameDone(SUCCESS); + signal XE1205PhyRxTx.rxAckEnd(rxFrame, rxFrameLen + headerLen, SUCCESS); } - - - return; @@ -593,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); @@ -611,7 +611,7 @@ implementation { return; case RADIO_RSSI: - readRssi(); + readRssi(); return; case RADIO_RX_ACK: // ack timeout @@ -633,11 +633,10 @@ implementation { } - signal XE1205PhyRxTx.sendFrameDone(FAIL); + signal XE1205PhyRxTx.sendFrameDone(ENOACK); return; default: - - + return; }