uses {
interface RadioByteComm;
interface Alarm<T32khz, uint16_t> as RxByteTimer;
+#ifdef UART_DEBUG
+ interface SerialDebug;
+#endif
}
}
implementation
{
+#ifdef UART_DEBUG
+ void sdDebug(uint16_t p) {
+ call SerialDebug.putPlace(p);
+ }
+#else
+ void sdDebug(uint16_t p) {};
+#endif
+
/* Module Definitions */
typedef enum {
STATE_PREAMBLE,
/* constants */
enum {
PREAMBLE_LENGTH=2,
- BYTE_TIME=9,
+ BYTE_TIME=TDA5250_32KHZ_BYTE_TIME+3,
PREAMBLE_BYTE=0x55,
SYNC_BYTE=0xFF,
SFD_BYTE=0x83,
numPreambles = PREAMBLE_LENGTH;
byteTime = BYTE_TIME;
}
+#ifdef UART_DEBUG
+ call SerialDebug.putShortDesc("U4b6bP");
+#endif
return SUCCESS;
}
call RxByteTimer.stop();
if(phyState >= STATE_DATA_HIGH) {
signal PhyPacketRx.recvFooterDone(FAIL);
+ sdDebug(10);
}
- phyState = STATE_PREAMBLE;
+ phyState = STATE_PREAMBLE;
}
async event void RxByteTimer.fired() {
phyState = STATE_PREAMBLE;
call RxByteTimer.stop();
signal PhyPacketRx.recvFooterDone(SUCCESS);
+ sdDebug(20);
}
void TransmitNextByte() {
switch(phyState) {
case STATE_PREAMBLE:
- if(preambleCount > 0) {
+ if(preambleCount > 1) {
preambleCount--;
} else {
phyState = STATE_SYNC;
bufByte |= data & 0x03;
bufByte <<= 2;
phyState = STATE_DATA_MIDDLE;
+ call RxByteTimer.stop();
signal PhyPacketRx.recvHeaderDone(SUCCESS);
call RxByteTimer.start(byteTime);
}
}
else {
phyState = STATE_DATA_HIGH;
+ call RxByteTimer.stop();
signal PhyPacketRx.recvHeaderDone(SUCCESS);
call RxByteTimer.start(byteTime);
}
decodedByte = sixBitToNibble[((bufByte & 0x0f)<<2) | (data >> 4)];
if(decodedByte != ILLEGAL_CODE) {
phyState = STATE_DATA_LOW;
+ call RxByteTimer.stop();
signal SerializerRadioByteComm.rxByteReady((bufByte & 0xf0) | decodedByte);
bufByte = (data & 0x0f) << 2;
call RxByteTimer.start(byteTime);
decodedByte = sixBitToNibble[data & 0x3f];
if(decodedByte != ILLEGAL_CODE) {
phyState = STATE_DATA_HIGH;
+ call RxByteTimer.stop();
signal SerializerRadioByteComm.rxByteReady(bufByte | decodedByte);
call RxByteTimer.start(byteTime);
}