Fix TeensyHID bootloader for the largest AVRs - only the ATMEGA128x needs the alterna...
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / XPROG / TINYNVM.c
index 7b9ff09..817f223 100644 (file)
@@ -94,13 +94,6 @@ bool TINYNVM_WaitWhileNVMBusBusy(void)
                        TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
                        return true;\r
                }\r
-\r
-               /* Manage software timeout */\r
-               if (TIFR0 & (1 << OCF0A))\r
-               {\r
-                       TIFR0 |= (1 << OCF0A);\r
-                       TimeoutMSRemaining--;\r
-               }\r
        }\r
 \r
        return false;\r
@@ -131,13 +124,6 @@ bool TINYNVM_WaitWhileNVMControllerBusy(void)
                        TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
                        return true;\r
                }\r
-\r
-               /* Manage software timeout */\r
-               if (TIFR0 & (1 << OCF0A))\r
-               {\r
-                       TIFR0 |= (1 << OCF0A);\r
-                       TimeoutMSRemaining--;\r
-               }\r
        }\r
 \r
        return false;\r
@@ -164,14 +150,14 @@ bool TINYNVM_ReadMemory(const uint16_t ReadAddress, uint8_t* ReadBuffer, uint16_
        /* Send the address of the location to read from */\r
        TINYNVM_SendPointerAddress(ReadAddress);\r
        \r
-       while (ReadSize--)\r
+       while (ReadSize-- && TimeoutMSRemaining)\r
        {\r
                /* Read the byte of data from the target */\r
                XPROGTarget_SendByte(TPI_CMD_SLD | TPI_POINTER_INDIRECT_PI);\r
                *(ReadBuffer++) = XPROGTarget_ReceiveByte();\r
        }\r
        \r
-       return true;\r
+       return (TimeoutMSRemaining != 0);\r
 }\r
 \r
 /** Writes word addressed memory to the target's memory spaces.\r