|
|
@ -236,8 +236,8 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|
|
|
ISPTarget_SendByte(StartAddress & 0xFF);
|
|
|
|
ISPTarget_SendByte(StartAddress & 0xFF);
|
|
|
|
ISPTarget_SendByte(0x00);
|
|
|
|
ISPTarget_SendByte(0x00);
|
|
|
|
|
|
|
|
|
|
|
|
/* Check if polling is possible, if not switch to timed delay mode */
|
|
|
|
/* Check if polling is possible and enabled, if not switch to timed delay mode */
|
|
|
|
if (!(PollAddress))
|
|
|
|
if (!(PollAddress) && (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_VALUE_MASK))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Write_Memory_Params.ProgrammingMode &= ~PROG_MODE_PAGED_VALUE_MASK;
|
|
|
|
Write_Memory_Params.ProgrammingMode &= ~PROG_MODE_PAGED_VALUE_MASK;
|
|
|
|
Write_Memory_Params.ProgrammingMode |= PROG_MODE_PAGED_TIMEDELAY_MASK;
|
|
|
|
Write_Memory_Params.ProgrammingMode |= PROG_MODE_PAGED_TIMEDELAY_MASK;
|
|
|
@ -276,6 +276,9 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|
|
|
if (V2Command == CMD_PROGRAM_FLASH_ISP)
|
|
|
|
if (V2Command == CMD_PROGRAM_FLASH_ISP)
|
|
|
|
Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
|
|
|
|
Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Save previous programming mode in case we modify it for the current word */
|
|
|
|
|
|
|
|
uint8_t PreviousProgrammingMode = Write_Memory_Params.ProgrammingMode;
|
|
|
|
|
|
|
|
|
|
|
|
if (ByteToWrite != PollValue)
|
|
|
|
if (ByteToWrite != PollValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
|
|
|
|
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
|
|
|
@ -283,10 +286,18 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|
|
|
|
|
|
|
|
|
|
|
PollAddress = (CurrentAddress & 0xFFFF);
|
|
|
|
PollAddress = (CurrentAddress & 0xFFFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!(Write_Memory_Params.ProgrammingMode & PROG_MODE_WORD_READYBUSY_MASK))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Write_Memory_Params.ProgrammingMode &= ~PROG_MODE_WORD_VALUE_MASK;
|
|
|
|
|
|
|
|
Write_Memory_Params.ProgrammingMode |= PROG_MODE_WORD_TIMEDELAY_MASK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue,
|
|
|
|
ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue,
|
|
|
|
Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]);
|
|
|
|
Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Restore previous programming mode mask in case the current word needed to change it */
|
|
|
|
|
|
|
|
Write_Memory_Params.ProgrammingMode = PreviousProgrammingMode;
|
|
|
|
|
|
|
|
|
|
|
|
/* Abort the programming loop early if the byte/word programming failed */
|
|
|
|
/* Abort the programming loop early if the byte/word programming failed */
|
|
|
|
if (ProgrammingStatus != STATUS_CMD_OK)
|
|
|
|
if (ProgrammingStatus != STATUS_CMD_OK)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|