]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc
stm25p: fix seek error
[tinyos-2.x.git] / tos / platforms / eyesIFX / byte_radio / Uart4b6bPhyP.nc
index 07a1106f05868718aed53d873faa3fee935ddec6..8976f47d6b34fe8c9bbaa6a05dabde7b957a185e 100644 (file)
@@ -47,10 +47,21 @@ module Uart4b6bPhyP {
     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,
@@ -72,7 +83,7 @@ implementation
     /* constants */
     enum {
         PREAMBLE_LENGTH=2,
-        BYTE_TIME=9,
+        BYTE_TIME=TDA5250_32KHZ_BYTE_TIME+3,
         PREAMBLE_BYTE=0x55,
         SYNC_BYTE=0xFF,
         SFD_BYTE=0x83,
@@ -96,6 +107,9 @@ implementation
             numPreambles = PREAMBLE_LENGTH;
             byteTime = BYTE_TIME;
         }
+#ifdef UART_DEBUG
+        call SerialDebug.putShortDesc("U4b6bP");
+#endif
         return SUCCESS;
     }
     
@@ -123,8 +137,9 @@ implementation
         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() {
@@ -182,6 +197,7 @@ implementation
         phyState = STATE_PREAMBLE;
         call RxByteTimer.stop();
         signal PhyPacketRx.recvFooterDone(SUCCESS);
+        sdDebug(20);
     }
 
     
@@ -198,7 +214,7 @@ implementation
     void TransmitNextByte() {
         switch(phyState) {
             case STATE_PREAMBLE:
-                if(preambleCount > 0) {
+                if(preambleCount > 1) {
                     preambleCount--;
                 } else {
                     phyState = STATE_SYNC;
@@ -288,6 +304,7 @@ implementation
                             bufByte |= data & 0x03;
                             bufByte <<= 2;
                             phyState = STATE_DATA_MIDDLE;
+                            call RxByteTimer.stop();
                             signal PhyPacketRx.recvHeaderDone(SUCCESS);
                             call RxByteTimer.start(byteTime);
                         }
@@ -297,6 +314,7 @@ implementation
                     }
                     else {
                         phyState = STATE_DATA_HIGH;
+                        call RxByteTimer.stop();
                         signal PhyPacketRx.recvHeaderDone(SUCCESS);
                         call RxByteTimer.start(byteTime);
                     }
@@ -318,6 +336,7 @@ implementation
                     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);
@@ -333,6 +352,7 @@ implementation
                         decodedByte = sixBitToNibble[data & 0x3f];
                         if(decodedByte != ILLEGAL_CODE) {
                             phyState = STATE_DATA_HIGH;
+                            call RxByteTimer.stop();
                             signal SerializerRadioByteComm.rxByteReady(bufByte | decodedByte);
                             call RxByteTimer.start(byteTime);
                         }