diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-04-30 08:33:21 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-04-30 08:33:21 +0000 |
commit | 9a1560dc050f79fd189838a87ce623e79ff48677 (patch) | |
tree | 76a3aa9738ab22f0380e9429c38a2785899dedf5 /Projects/AVRISP-MKII/Lib | |
parent | ceb16ee24f1e6add5e2ad0398369c24d2d868cd8 (diff) | |
download | lufa-9a1560dc050f79fd189838a87ce623e79ff48677.tar.gz lufa-9a1560dc050f79fd189838a87ce623e79ff48677.tar.bz2 lufa-9a1560dc050f79fd189838a87ce623e79ff48677.zip |
Make sure that long reads are aborted early if the connection times out while waiting on more bytes in the AVRISP MKII clone project.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib')
-rw-r--r-- | Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c | 4 | ||||
-rw-r--r-- | Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c | 6 | ||||
-rw-r--r-- | Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c index 7b9ff0914..acd6b651c 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c @@ -164,14 +164,14 @@ bool TINYNVM_ReadMemory(const uint16_t ReadAddress, uint8_t* ReadBuffer, uint16_ /* Send the address of the location to read from */
TINYNVM_SendPointerAddress(ReadAddress);
- while (ReadSize--)
+ while (ReadSize-- && TimeoutMSRemaining)
{
/* Read the byte of data from the target */
XPROGTarget_SendByte(TPI_CMD_SLD | TPI_POINTER_INDIRECT_PI);
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
}
- return true;
+ return (TimeoutMSRemaining != 0);
}
/** Writes word addressed memory to the target's memory spaces.
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c index 7ca0c5e8a..b6b039aa8 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c @@ -183,7 +183,7 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest) for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)
((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
- return true;
+ return (TimeoutMSRemaining != 0);
}
/** Reads memory from the target's memory spaces.
@@ -215,10 +215,10 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16 /* Send a LD command with indirect access and postincrement to read out the bytes */
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
- while (ReadSize--)
+ while (ReadSize-- && TimeoutMSRemaining)
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
- return true;
+ return (TimeoutMSRemaining != 0);
}
/** Writes byte addressed memory to the target's memory spaces.
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c index 6f0d87add..e75adbe10 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c @@ -338,6 +338,9 @@ uint8_t XPROGTarget_ReceiveByte(void) }
}
+ if (TimeoutMSRemaining)
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;
+
return UDR1;
#else
/* Wait until a byte has been received before reading */
|