Fix PDITarget_ReceiveByte() not discarding the start bit properly, and reading in...
[pub/USBasp.git] / Projects / AVRISP / Lib / PDIProtocol.c
index 3e16407..864d4e9 100644 (file)
@@ -28,7 +28,7 @@
   this software.\r
 */\r
 \r
-#if defined(ENABLE_PDI_PROTOCOL)\r
+#if defined(ENABLE_PDI_PROTOCOL) || defined(__DOXYGEN__)\r
 \r
 #warning PDI Programming Protocol support is incomplete and not currently suitable for use.\r
 \r
@@ -109,7 +109,8 @@ static void PDIProtocol_EnterXPROGMode(void)
        \r
        /* Must hold DATA line high for at least 90nS to enable PDI interface */\r
        PDIDATA_LINE_PORT |= PDIDATA_LINE_MASK;\r
-       _delay_us(1);\r
+       asm volatile ("NOP"::);\r
+       asm volatile ("NOP"::);\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
@@ -117,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