Device mode class driver callbacks are now fired before the control request status...
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / XPROG / XMEGANVM.c
index 7ca0c5e..1671d29 100644 (file)
@@ -89,13 +89,6 @@ bool XMEGANVM_WaitWhileNVMBusBusy(void)
                        TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
                        return true;\r
                }\r
                        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
        }\r
        \r
        return false;\r
@@ -127,13 +120,6 @@ bool XMEGANVM_WaitWhileNVMControllerBusy(void)
                        TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
                        return true;\r
                }\r
                        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
        }\r
        \r
        return false;\r
@@ -183,7 +169,7 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
        for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)\r
          ((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();\r
        \r
        for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)\r
          ((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();\r
        \r
-       return true;\r
+       return (TimeoutMSRemaining != 0);\r
 }\r
 \r
 /** Reads memory from the target's memory spaces.\r
 }\r
 \r
 /** Reads memory from the target's memory spaces.\r
@@ -215,10 +201,10 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16
                \r
        /* Send a LD command with indirect access and postincrement to read out the bytes */\r
        XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);\r
                \r
        /* Send a LD command with indirect access and postincrement to read out the bytes */\r
        XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);\r
-       while (ReadSize--)\r
+       while (ReadSize-- && TimeoutMSRemaining)\r
          *(ReadBuffer++) = XPROGTarget_ReceiveByte();\r
        \r
          *(ReadBuffer++) = XPROGTarget_ReceiveByte();\r
        \r
-       return true;\r
+       return (TimeoutMSRemaining != 0);\r
 }\r
 \r
 /** Writes byte addressed memory to the target's memory spaces.\r
 }\r
 \r
 /** Writes byte addressed memory to the target's memory spaces.\r