From e322f14620a1064efc4b3a98cf701efc48da81cc Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 21 Feb 2010 06:26:33 +0000 Subject: More fixes to the AVRISP command timeout system so that it should no longer lock up while processing command no matter what the conditions. --- Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c') diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c index 428469df74..a894793c7b 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c @@ -77,13 +77,15 @@ static void TINYNVM_SendWriteNVMRegister(const uint8_t Address) bool TINYNVM_WaitWhileNVMBusBusy(void) { /* Poll the STATUS register to check to see if NVM access has been enabled */ - uint8_t TimeoutMSRemaining = 100; while (TimeoutMSRemaining) { /* Send the SLDCS command to read the TPI STATUS register to see the NVM bus is active */ XPROGTarget_SendByte(TPI_CMD_SLDCS | TPI_STATUS_REG); if (XPROGTarget_ReceiveByte() & TPI_STATUS_NVM) - return true; + { + TimeoutMSRemaining = COMMAND_TIMEOUT_MS; + return true; + } /* Manage software timeout */ if (TIFR0 & (1 << OCF0A)) @@ -104,7 +106,6 @@ bool TINYNVM_WaitWhileNVMBusBusy(void) bool TINYNVM_WaitWhileNVMControllerBusy(void) { /* Poll the STATUS register to check to see if NVM access has been enabled */ - uint8_t TimeoutMSRemaining = 100; while (TimeoutMSRemaining) { /* Send the SIN command to read the TPI STATUS register to see the NVM bus is busy */ @@ -112,7 +113,10 @@ bool TINYNVM_WaitWhileNVMControllerBusy(void) /* Check to see if the BUSY flag is still set */ if (!(XPROGTarget_ReceiveByte() & (1 << 7))) - return true; + { + TimeoutMSRemaining = COMMAND_TIMEOUT_MS; + return true; + } /* Manage software timeout */ if (TIFR0 & (1 << OCF0A)) -- cgit v1.2.3