X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/0b6d5467bc70ba36ff71a186da9cf4d0742612a6..3e044872790072838c2d1d0370b98b6ebf4fea93:/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c index ccd31f3d2..797fa3655 100644 --- a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c +++ b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c @@ -69,10 +69,11 @@ void ISPProtocol_EnterISPMode(void) ISPTarget_EnableTargetISP(); ISPTarget_ChangeTargetResetLine(true); + ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS); /* Continuously attempt to synchronize with the target until either the number of attempts specified * by the host has exceeded, or the the device sends back the expected response values */ - while (Enter_ISP_Params.SynchLoops-- && (ResponseStatus != STATUS_CMD_OK) && !(TimeoutExpired)) + while (Enter_ISP_Params.SynchLoops-- && !(TimeoutExpired)) { uint8_t ResponseBytes[4]; @@ -86,12 +87,14 @@ void ISPProtocol_EnterISPMode(void) if (!(Enter_ISP_Params.PollIndex) || (ResponseBytes[Enter_ISP_Params.PollIndex - 1] == Enter_ISP_Params.PollValue)) { ResponseStatus = STATUS_CMD_OK; + break; } else { ISPTarget_ChangeTargetResetLine(false); ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS); ISPTarget_ChangeTargetResetLine(true); + ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS); } } @@ -230,18 +233,18 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) if (ProgrammingStatus != STATUS_CMD_OK) break; - /* Must reset the polling address afterwards, so it is not erronously used for the next byte */ + /* Must reset the polling address afterwards, so it is not erroneously used for the next byte */ PollAddress = 0; } /* EEPROM just increments the address each byte, flash needs to increment on each word and * also check to ensure that a LOAD EXTENDED ADDRESS command is issued each time the extended - * address boundary has been crossed */ + * address boundary has been crossed during FLASH memory programming */ if ((CurrentByte & 0x01) || (V2Command == CMD_PROGRAM_EEPROM_ISP)) { CurrentAddress++; - if ((V2Command != CMD_PROGRAM_EEPROM_ISP) && !(CurrentAddress & 0xFFFF)) + if ((V2Command == CMD_PROGRAM_FLASH_ISP) && !(CurrentAddress & 0xFFFF)) MustLoadExtendedAddress = true; } }