Fixed USB_GetHIDReportSize() returning the number of bits in the specified report...
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / XPROG / TINYNVM.c
index 9055920..91ed775 100644 (file)
@@ -167,10 +167,6 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint
        \r
        while (WriteLength)\r
        {\r
-               /* Wait until the NVM controller is no longer busy */\r
-               if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
-                 return false;\r
-\r
                /* Write the low byte of data to the target */\r
                XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);\r
                XPROGTarget_SendByte(*(WriteBuffer++));\r
@@ -179,6 +175,10 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint
                XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);\r
                XPROGTarget_SendByte(*(WriteBuffer++));\r
 \r
+               /* Wait until the NVM controller is no longer busy */\r
+               if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
+                 return false;\r
+\r
                /* Need to decrement the write length twice, since we read out a whole word */\r
                WriteLength -= 2;\r
        }\r