Fix PDITarget_ReceiveByte() not discarding the start bit properly, and reading in...
[pub/USBasp.git] / Projects / AVRISP / Lib / PDITarget.c
index 7b35a33..a0bbf7d 100644 (file)
@@ -98,14 +98,16 @@ uint8_t PDITarget_ReceiveByte(void)
        // One Start Bit\r
        while (PDIDATA_LINE_PIN & PDIDATA_LINE_MASK);\r
          TOGGLE_PDI_CLOCK;\r
-               \r
+\r
+       TOGGLE_PDI_CLOCK;\r
+       \r
        // Eight Data Bits\r
        for (uint8_t i = 0; i < 8; i++)\r
        {\r
-               if (PDIDATA_LINE_PIN & PDIDATA_LINE_MASK)\r
-                       ReceivedByte |= 0x01;\r
+               if (!(PDIDATA_LINE_PIN & PDIDATA_LINE_MASK))\r
+                       ReceivedByte |= 0x80;\r
 \r
-               ReceivedByte <<= 1;\r
+               ReceivedByte >>= 1;\r
 \r
                TOGGLE_PDI_CLOCK;       \r
        }\r