Fix PDITarget_ReceiveByte() not discarding the start bit properly, and reading in...
[pub/USBasp.git] / Projects / AVRISP / Lib / PDIProtocol.c
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
        /* 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
        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
        \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
        \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
          PDITarget_SendByte(PDI_NVMENABLE_KEY[i]);\r
 \r
        /* Read out the STATUS register to check that NVM access was successfully enabled */\r