diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-05-13 11:14:10 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-05-13 11:14:10 +0000 |
commit | 571159df1b9b86fc76d12a02fc1e172bd202305a (patch) | |
tree | fb873b6323058da0e62a4bb59236622cee87eed5 /Projects | |
parent | cd0093a14bd12d61ceab6860341c1a1fcd0ebb04 (diff) | |
download | lufa-571159df1b9b86fc76d12a02fc1e172bd202305a.tar.gz lufa-571159df1b9b86fc76d12a02fc1e172bd202305a.tar.bz2 lufa-571159df1b9b86fc76d12a02fc1e172bd202305a.zip |
Additional fix to the AVRISP-MKII clone project for 256KB AVRs.
Diffstat (limited to 'Projects')
-rw-r--r-- | Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c index 430772ddc..e49f590d4 100644 --- a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c +++ b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c @@ -227,18 +227,9 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) PollAddress = (CurrentAddress & 0xFFFF); } - /* 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 */ - if (V2Command == CMD_PROGRAM_EEPROM_ISP) - { - CurrentAddress++; - } - else if (IsOddByte) - { - if (!(++CurrentAddress & 0xFFFF)) - ISPTarget_LoadExtendedAddress(); - } + /* EEPROM increments the address on each byte, flash needs to increment on each word */ + if (IsOddByte || (V2Command == CMD_PROGRAM_EEPROM_ISP)) + CurrentAddress++; } /* If the current page must be committed, send the PROGRAM PAGE command to the target */ @@ -258,6 +249,10 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue, Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]); + + /* Check to see if the FLASH address has crossed the extended address boundary */ + if ((V2Command == CMD_PROGRAM_FLASH_ISP) && !(CurrentAddress & 0xFFFF)) + ISPTarget_LoadExtendedAddress(); } } else @@ -285,6 +280,13 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) PollAddress = (CurrentAddress & 0xFFFF); } + + ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue, + Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]); + + /* Abort the programming loop early if the byte/word programming failed */ + if (ProgrammingStatus != STATUS_CMD_OK) + break; /* 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 @@ -298,12 +300,6 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) if (!(++CurrentAddress & 0xFFFF)) ISPTarget_LoadExtendedAddress(); } - - ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue, - Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]); - - if (ProgrammingStatus != STATUS_CMD_OK) - break; } } |