Make sure that the NVM bus/controller busy waits in the AVRISP MKII clone project abort properly if a timeout occurs while waiting for a response.

This commit is contained in:
Dean Camera 2010-04-30 08:27:21 +00:00
parent 9cad677ebb
commit ceb16ee24f
3 changed files with 54 additions and 15 deletions

View file

@ -453,22 +453,33 @@ static void XPROGTarget_SetRxMode(void)
{
BITBANG_PDIDATA_DDR &= ~BITBANG_PDIDATA_MASK;
BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;
/* Wait until DATA line has been pulled up to idle by the target */
while (!(BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK) && TimeoutMSRemaining)
{
/* Manage software timeout */
if (TIFR0 & (1 << OCF0A))
{
TIFR0 |= (1 << OCF0A);
TimeoutMSRemaining--;
}
}
}
else
{
BITBANG_TPIDATA_DDR &= ~BITBANG_TPIDATA_MASK;
BITBANG_TPIDATA_PORT &= ~BITBANG_TPIDATA_MASK;
}
/* Wait until DATA line has been pulled up to idle by the target */
while (!(BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK) && TimeoutMSRemaining)
{
/* Manage software timeout */
if (TIFR0 & (1 << OCF0A))
BITBANG_TPIDATA_PORT &= ~BITBANG_TPIDATA_MASK;
/* Wait until DATA line has been pulled up to idle by the target */
while (!(BITBANG_TPIDATA_PIN & BITBANG_TPIDATA_MASK) && TimeoutMSRemaining)
{
TIFR0 |= (1 << OCF0A);
TimeoutMSRemaining--;
}
/* Manage software timeout */
if (TIFR0 & (1 << OCF0A))
{
TIFR0 |= (1 << OCF0A);
TimeoutMSRemaining--;
}
}
}
#endif