Add optional double-banking support to the Device mode Class Drivers, on a per-endpoi...
[pub/USBasp.git] / Projects / AVRISP / Lib / V2ProtocolTarget.c
index d06f065..9f8978a 100644 (file)
@@ -79,7 +79,7 @@ uint8_t V2Protocol_GetSPIPrescalerMask(void)
 /** Asserts or deasserts the target's reset line, using the correct polarity as set by the host using a SET PARAM command.\r
  *  When not asserted, the line is tristated so as not to intefere with normal device operation.\r
  *\r
- *  \param ResetTarget Boolean true when the target should be held in reset, false otherwise\r
+ *  \param[in] ResetTarget Boolean true when the target should be held in reset, false otherwise\r
  */\r
 void V2Protocol_ChangeTargetResetLine(bool ResetTarget)\r
 {\r
@@ -100,11 +100,11 @@ void V2Protocol_ChangeTargetResetLine(bool ResetTarget)
 /** Waits until the last issued target memory programming command has completed, via the check mode given and using\r
  *  the given parameters.\r
  *\r
- *  \param ProgrammingMode  Programming mode used and completion check to use, a mask of PROG_MODE_* constants\r
- *  \param PollAddress  Memory address to poll for completion if polling check mode used\r
- *  \param PollValue  Poll value to check against if polling check mode used\r
- *  \param DelayMS  Milliseconds to delay before returning if delay check mode used\r
- *  \param ReadMemCommand  Device low-level READ MEMORY command to send if value check mode used\r
+ *  \param[in] ProgrammingMode  Programming mode used and completion check to use, a mask of PROG_MODE_* constants\r
+ *  \param[in] PollAddress  Memory address to poll for completion if polling check mode used\r
+ *  \param[in] PollValue  Poll value to check against if polling check mode used\r
+ *  \param[in] DelayMS  Milliseconds to delay before returning if delay check mode used\r
+ *  \param[in] ReadMemCommand  Device low-level READ MEMORY command to send if value check mode used\r
  *\r
  *  \return V2 Protocol status \ref STATUS_CMD_OK if the no timeout occurred, \ref STATUS_RDY_BSY_TOUT or\r
  *          \ref STATUS_CMD_TOUT otherwise\r
@@ -155,14 +155,17 @@ uint8_t V2Protocol_WaitWhileTargetBusy(void)
 {\r
        TCNT0 = 0;\r
        \r
+       bool DeviceBusy;\r
+       \r
        do\r
        {\r
                SPI_SendByte(0xF0);\r
                SPI_SendByte(0x00);\r
 \r
                SPI_SendByte(0x00);\r
+               DeviceBusy = (SPI_ReceiveByte() & 0x01);\r
        }\r
-       while ((SPI_ReceiveByte() & 0x01) && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));\r
+       while (DeviceBusy && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));\r
 \r
        if (TCNT0 >= TARGET_BUSY_TIMEOUT_MS)\r
          return STATUS_RDY_BSY_TOUT;\r