aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP/Lib/NVMTarget.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-20 22:33:48 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-20 22:33:48 +0000
commit37c9ba7fa980472406625973f0ee32719b5a8997 (patch)
tree0db6f97496255b576cb150068f904b23b4554cb5 /Projects/AVRISP/Lib/NVMTarget.c
parent8b7565956380c558bb309732c1d7d2cb58b193ea (diff)
downloadlufa-37c9ba7fa980472406625973f0ee32719b5a8997.tar.gz
lufa-37c9ba7fa980472406625973f0ee32719b5a8997.tar.bz2
lufa-37c9ba7fa980472406625973f0ee32719b5a8997.zip
Fixed AVRISP project timeouts not checking for the correct timeout period (thanks to Carl Ott).
Diffstat (limited to 'Projects/AVRISP/Lib/NVMTarget.c')
-rw-r--r--Projects/AVRISP/Lib/NVMTarget.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Projects/AVRISP/Lib/NVMTarget.c b/Projects/AVRISP/Lib/NVMTarget.c
index 00312d513..adf213bb4 100644
--- a/Projects/AVRISP/Lib/NVMTarget.c
+++ b/Projects/AVRISP/Lib/NVMTarget.c
@@ -72,9 +72,12 @@ void NVMTarget_SendAddress(const uint32_t AbsoluteAddress)
bool NVMTarget_WaitWhileNVMControllerBusy(void)
{
TCNT0 = 0;
-
+ TIFR0 = (1 << OCF1A);
+
+ uint8_t TimeoutMS = PDI_NVM_TIMEOUT_MS;
+
/* Poll the NVM STATUS register while the NVM controller is busy */
- while (TCNT0 < NVM_BUSY_TIMEOUT_MS)
+ while (TimeoutMS)
{
/* Send a LDS command to read the NVM STATUS register to check the BUSY flag */
PDITarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
@@ -83,6 +86,12 @@ bool NVMTarget_WaitWhileNVMControllerBusy(void)
/* Check to see if the BUSY flag is still set */
if (!(PDITarget_ReceiveByte() & (1 << 7)))
return true;
+
+ if (TIFR0 & (1 << OCF1A))
+ {
+ TIFR0 = (1 << OCF1A);
+ TimeoutMS--;
+ }
}
return false;