Fix inverted bit-banged USART logic in the AVRISP project for PDI programming. Add...
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 9 Dec 2009 12:01:01 +0000 (12:01 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 9 Dec 2009 12:01:01 +0000 (12:01 +0000)
LUFA/Drivers/USB/LowLevel/Endpoint.h
LUFA/ManPages/ChangeLog.txt
Projects/AVRISP/Lib/PDIProtocol.c
Projects/AVRISP/Lib/PDITarget.c
Projects/AVRISP/Lib/PDITarget.h
Projects/AVRISP/makefile

index 8ff9306..ef23253 100644 (file)
                                 */\r
                                static inline void Endpoint_SetEndpointDirection(uint8_t DirectionMask);\r
                        #else\r
-                               #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)\r
+                               #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
                                        #define Endpoint_BytesInEndpoint()        UEBCX\r
                                #elif defined(USB_SERIES_4_AVR)\r
                                        #define Endpoint_BytesInEndpoint()        (((uint16_t)UEBCHX << 8) | UEBCLX)                            \r
index f7af9a1..143b5a1 100644 (file)
@@ -56,6 +56,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
   *\r
   *  \section Sec_ChangeLog091122 Version 091122\r
   *\r
index d98c51c..864d4e9 100644 (file)
@@ -110,9 +110,7 @@ static void PDIProtocol_EnterXPROGMode(void)
        /* Must hold DATA line high for at least 90nS to enable PDI interface */\r
        PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;\r
        asm volatile ("NOP"::);\r
-       #if (F_CPU > 8000000)\r
        asm volatile ("NOP"::);\r
-       #endif\r
        \r
        /* Toggle CLOCK line 16 times within 100uS of the original 90nS timeout to keep PDI interface enabled */\r
        for (uint8_t i = 0; i < 16; i++)\r
@@ -120,7 +118,7 @@ static void PDIProtocol_EnterXPROGMode(void)
        \r
        /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
        PDITarget_SendByte(PDI_CMD_KEY);        \r
-       for (uint8_t i = 0; i < 8; i++)\r
+       for (uint8_t i = 0; i < sizeof(PDI_NVMENABLE_KEY); i++)\r
          PDITarget_SendByte(PDI_NVMENABLE_KEY[i]);\r
 \r
        /* Read out the STATUS register to check that NVM access was successfully enabled */\r
index 98d4bde..03dd779 100644 (file)
@@ -52,9 +52,9 @@ void PDITarget_SendByte(uint8_t Byte)
        for (uint8_t i = 0; i < 8; i++)\r
        {\r
                if (Byte & 0x01)\r
-                 PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;\r
-               else\r
                  PDIDATA_LINE_PORT &= ~PDIDATA_LINE_MASK;\r
+               else\r
+                 PDIDATA_LINE_PORT |=  PDIDATA_LINE_MASK;\r
                  \r
                Byte >>= 1;\r
 \r
index 294d1a9..00ce68b 100644 (file)
@@ -65,7 +65,7 @@
                        #define PDIDATA_LINE_PORT     PORTB\r
                        #define PDIDATA_LINE_DDR      DDRB\r
                        #define PDIDATA_LINE_PIN      PINB\r
-                       #define PDIDATA_LINE_MASK     (1 << 2)\r
+                       #define PDIDATA_LINE_MASK     (1 << 3)\r
                        \r
                        #define PDICLOCK_LINE_PORT    RESET_LINE_PORT\r
                        #define PDICLOCK_LINE_DDR     RESET_LINE_DDR\r
@@ -91,7 +91,9 @@
                #define PDI_NVMENABLE_KEY     (uint8_t[]){0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF}\r
 \r
                #define TOGGLE_PDI_CLOCK      MACROS{ PDICLOCK_LINE_PORT ^= PDICLOCK_LINE_MASK; \\r
-                                                     PDICLOCK_LINE_PORT ^= PDICLOCK_LINE_MASK; }MACROE\r
+                                                     asm volatile ("NOP" ::);                  \\r
+                                                     PDICLOCK_LINE_PORT ^= PDICLOCK_LINE_MASK; \\r
+                                                     asm volatile ("NOP" ::);                  }MACROE\r
                \r
        /* Function Prototypes: */\r
                void    PDITarget_SendByte(uint8_t Byte);\r
index 6eebb2b..b215a22 100644 (file)
@@ -60,7 +60,7 @@
 \r
 \r
 # MCU name\r
-MCU = at90usb1287\r
+MCU = at90usb162\r
 \r
 \r
 # Target board (see library "Board Types" documentation, USER or blank for projects not requiring\r