Make sure that long reads are aborted early if the connection times out while waiting on more bytes in the AVRISP MKII clone project.

This commit is contained in:
Dean Camera 2010-04-30 08:33:21 +00:00
parent ceb16ee24f
commit 9a1560dc05
3 changed files with 8 additions and 5 deletions

View file

@ -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.