Make sure that the NVM bus/controller busy waits in the AVRISP MKII clone project...
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / XPROG / XPROGTarget.c
index bd269ed..6f0d87a 100644 (file)
@@ -453,22 +453,33 @@ static void XPROGTarget_SetRxMode(void)
        {\r
                BITBANG_PDIDATA_DDR  &= ~BITBANG_PDIDATA_MASK;\r
                BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;\r
+\r
+               /* Wait until DATA line has been pulled up to idle by the target */\r
+               while (!(BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK) && TimeoutMSRemaining)\r
+               {\r
+                       /* Manage software timeout */\r
+                       if (TIFR0 & (1 << OCF0A))\r
+                       {\r
+                               TIFR0 |= (1 << OCF0A);\r
+                               TimeoutMSRemaining--;\r
+                       }\r
+               }\r
        }\r
        else\r
        {\r
                BITBANG_TPIDATA_DDR  &= ~BITBANG_TPIDATA_MASK;\r
-               BITBANG_TPIDATA_PORT &= ~BITBANG_TPIDATA_MASK;  \r
-       }\r
-       \r
-       /* Wait until DATA line has been pulled up to idle by the target */\r
-       while (!(BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK) && TimeoutMSRemaining)\r
-       {\r
-               /* Manage software timeout */\r
-               if (TIFR0 & (1 << OCF0A))\r
+               BITBANG_TPIDATA_PORT &= ~BITBANG_TPIDATA_MASK;\r
+\r
+               /* Wait until DATA line has been pulled up to idle by the target */\r
+               while (!(BITBANG_TPIDATA_PIN & BITBANG_TPIDATA_MASK) && TimeoutMSRemaining)\r
                {\r
-                       TIFR0 |= (1 << OCF0A);\r
-                       TimeoutMSRemaining--;\r
-               }\r
+                       /* Manage software timeout */\r
+                       if (TIFR0 & (1 << OCF0A))\r
+                       {\r
+                               TIFR0 |= (1 << OCF0A);\r
+                               TimeoutMSRemaining--;\r
+                       }\r
+               }       \r
        }       \r
 #endif\r
 \r