X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/35dac470f243d234d72f34cbaeb1d6c8a15bc435..d1608d4af321529f0ddef9defcd97669ae9018c3:/Projects/AVRISP/Lib/ISP/ISPTarget.c?ds=inline diff --git a/Projects/AVRISP/Lib/ISP/ISPTarget.c b/Projects/AVRISP/Lib/ISP/ISPTarget.c index e99e3e53c..29cb18e62 100644 --- a/Projects/AVRISP/Lib/ISP/ISPTarget.c +++ b/Projects/AVRISP/Lib/ISP/ISPTarget.c @@ -122,26 +122,15 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1 break; case PROG_MODE_WORD_VALUE_MASK: case PROG_MODE_PAGED_VALUE_MASK: - TCNT0 = 0; - TIFR0 = (1 << OCF1A); - - uint8_t TimeoutMS = TARGET_BUSY_TIMEOUT_MS; - do { SPI_SendByte(ReadMemCommand); SPI_SendByte(PollAddress >> 8); SPI_SendByte(PollAddress & 0xFF); - - if (TIFR0 & (1 << OCF1A)) - { - TIFR0 = (1 << OCF1A); - TimeoutMS--; - } } - while ((SPI_TransferByte(0x00) != PollValue) && TimeoutMS); + while ((SPI_TransferByte(0x00) != PollValue) && TimeoutMSRemaining); - if (!(TimeoutMS)) + if (!(TimeoutMSRemaining)) ProgrammingStatus = STATUS_CMD_TOUT; break; @@ -161,27 +150,16 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1 */ uint8_t ISPTarget_WaitWhileTargetBusy(void) { - TCNT0 = 0; - TIFR0 = (1 << OCF1A); - - uint8_t TimeoutMS = TARGET_BUSY_TIMEOUT_MS; - do { SPI_SendByte(0xF0); SPI_SendByte(0x00); SPI_SendByte(0x00); - - if (TIFR0 & (1 << OCF1A)) - { - TIFR0 = (1 << OCF1A); - TimeoutMS--; - } } - while ((SPI_ReceiveByte() & 0x01) && TimeoutMS); + while ((SPI_ReceiveByte() & 0x01) && TimeoutMSRemaining); - if (!(TimeoutMS)) + if (!(TimeoutMSRemaining)) return STATUS_RDY_BSY_TOUT; else return STATUS_CMD_OK;