Add even parity bit to the software USART framing in the AVRISP project's PDI program...
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 9 Dec 2009 12:31:55 +0000 (12:31 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 9 Dec 2009 12:31:55 +0000 (12:31 +0000)
LUFA/ManPages/ChangeLog.txt
Projects/AVRISP/Lib/PDITarget.c

index 143b5a1..0daed31 100644 (file)
@@ -39,6 +39,8 @@
   *    with the rest of the library errorcodes\r
   *  - Make MIDI device demos also turn off the on board LEDs if MIDI Note On messages are sent with a velocity of zero,\r
   *    which some devices use instead of Note Off messages (thanks to Robin Green)\r
+  *  - The CDC demos are now named "VirtualSerial" instead to indicate the demos' function rather than its implemented USB class,\r
+  *    to reduce confusion and to be in line with the rest of the LUFA demos\r
   *\r
   *  <b>Fixed:</b>\r
   *  - Added missing CDC_Host_CreateBlockingStream() function code to the CDC Host Class driver\r
@@ -56,7 +58,7 @@
   *  - Fixed TeensyHID bootloader not properly shutting down the USB interface to trigger a disconnection on the host before resetting\r
   *  - Fixed MassStorageHost Class driver demo not having USB_STREAM_TIMEOUT_MS compile time option set properly to prevent slow \r
   *    devices from timing out the data pipes\r
-  *  - Fixed the definition of the Endpoint_BytesInEndpoint() macro for the U4 parts\r
+  *  - Fixed the definition of the Endpoint_BytesInEndpoint() macro for the U4 series AVR parts\r
   *\r
   *  \section Sec_ChangeLog091122 Version 091122\r
   *\r
index 03dd779..7b35a33 100644 (file)
  */\r
 void PDITarget_SendByte(uint8_t Byte)\r
 {\r
+       uint8_t LogicOneBits = 0;\r
+\r
+       // One Start Bit\r
        PDIDATA_LINE_PORT &= ~PDIDATA_LINE_MASK;\r
 \r
        TOGGLE_PDI_CLOCK;\r
-\r
+       \r
+       // Eight Data Bits\r
        for (uint8_t i = 0; i < 8; i++)\r
        {\r
                if (Byte & 0x01)\r
-                 PDIDATA_LINE_PORT &= ~PDIDATA_LINE_MASK;\r
+               {\r
+                       PDIDATA_LINE_PORT &= ~PDIDATA_LINE_MASK;\r
+                       LogicOneBits++;\r
+               }\r
                else\r
-                 PDIDATA_LINE_PORT |=  PDIDATA_LINE_MASK;\r
-                 \r
+               {\r
+                       PDIDATA_LINE_PORT |=  PDIDATA_LINE_MASK;\r
+               }\r
+               \r
                Byte >>= 1;\r
 \r
                TOGGLE_PDI_CLOCK;\r
        }\r
 \r
-       PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;\r
+       // Even Parity Bit\r
+       if (LogicOneBits & 0x01)\r
+         PDIDATA_LINE_PORT &= ~PDIDATA_LINE_MASK;\r
+       else\r
+         PDIDATA_LINE_PORT |=  PDIDATA_LINE_MASK;\r
+\r
+       TOGGLE_PDI_CLOCK;\r
 \r
+       // Two Stop Bits\r
+       PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;\r
+       \r
        TOGGLE_PDI_CLOCK;\r
        TOGGLE_PDI_CLOCK;\r
 }\r
@@ -77,9 +95,11 @@ uint8_t PDITarget_ReceiveByte(void)
 \r
        PDIDATA_LINE_DDR &= ~PDIDATA_LINE_MASK;\r
 \r
+       // One Start Bit\r
        while (PDIDATA_LINE_PIN & PDIDATA_LINE_MASK);\r
          TOGGLE_PDI_CLOCK;\r
-         \r
+               \r
+       // Eight Data Bits\r
        for (uint8_t i = 0; i < 8; i++)\r
        {\r
                if (PDIDATA_LINE_PIN & PDIDATA_LINE_MASK)\r
@@ -90,6 +110,10 @@ uint8_t PDITarget_ReceiveByte(void)
                TOGGLE_PDI_CLOCK;       \r
        }\r
 \r
+       // Even Parity Bit (discarded)\r
+       TOGGLE_PDI_CLOCK;\r
+\r
+       // Two Stop Bits\r
        TOGGLE_PDI_CLOCK;\r
        TOGGLE_PDI_CLOCK;\r
        \r