* - Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev)
* - Fixed incorrect LEDs_ChangeLEDs() function in the Benito board LED driver
* - Fixed incorrect USB_DeviceState value when unconfiguring the device without an address set
+ * - Fixed broken FLASH/EEPROM programming in the AVRISP-MKII clone project when writing in non-paged mode and the polling byte cannot be used
*
* \section Sec_ChangeLog100807 Version 100807
* <b>New:</b>
uint16_t PollAddress = 0;
uint8_t PollValue = (V2Command == CMD_PROGRAM_FLASH_ISP) ? Write_Memory_Params.PollValue1 :
Write_Memory_Params.PollValue2;
- uint8_t* NextWriteByte = Write_Memory_Params.ProgData;
+ uint8_t* NextWriteByte = Write_Memory_Params.ProgData;
/* Check the programming mode desired by the host, either Paged or Word memory writes */
if (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_WRITES_MASK)
ISPTarget_SendByte(StartAddress & 0xFF);
ISPTarget_SendByte(0x00);
- /* Check if polling is possible, if not switch to timed delay mode */
- if (!(PollAddress))
+ /* Check if polling is possible and enabled, if not switch to timed delay mode */
+ 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_TIMEDELAY_MASK;
* or low byte at the current word address */
if (V2Command == CMD_PROGRAM_FLASH_ISP)
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)
{
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,
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 */
if (ProgrammingStatus != STATUS_CMD_OK)
break;