aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-02-21 06:26:33 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-02-21 06:26:33 +0000
commite322f14620a1064efc4b3a98cf701efc48da81cc (patch)
treeb1d236f9627fcf0386279077dad2136d321d47fb /Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
parent12a01ed72d0d6dbf243160302314870e7b29cc07 (diff)
downloadlufa-e322f14620a1064efc4b3a98cf701efc48da81cc.tar.gz
lufa-e322f14620a1064efc4b3a98cf701efc48da81cc.tar.bz2
lufa-e322f14620a1064efc4b3a98cf701efc48da81cc.zip
More fixes to the AVRISP command timeout system so that it should no longer lock up while processing command no matter what the conditions.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
index 6ef59db37..f63f13a97 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
@@ -72,13 +72,15 @@ static void XMEGANVM_SendNVMRegAddress(const uint8_t Register)
bool XMEGANVM_WaitWhileNVMBusBusy(void)
{
/* Poll the STATUS register to check to see if NVM access has been enabled */
- uint8_t TimeoutMSRemaining = 100;
while (TimeoutMSRemaining)
{
/* Send the LDCS command to read the PDI STATUS register to see the NVM bus is active */
XPROGTarget_SendByte(PDI_CMD_LDCS | PDI_STATUS_REG);
if (XPROGTarget_ReceiveByte() & PDI_STATUS_NVM)
- return true;
+ {
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;
+ return true;
+ }
/* Manage software timeout */
if (TIFR0 & (1 << OCF0A))
@@ -99,7 +101,6 @@ bool XMEGANVM_WaitWhileNVMBusBusy(void)
bool XMEGANVM_WaitWhileNVMControllerBusy(void)
{
/* Poll the NVM STATUS register while the NVM controller is busy */
- uint8_t TimeoutMSRemaining = 100;
while (TimeoutMSRemaining)
{
/* Send a LDS command to read the NVM STATUS register to check the BUSY flag */
@@ -108,7 +109,10 @@ bool XMEGANVM_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))