+ for (uint16_t CurrentByte = 0; CurrentByte < Write_Memory_Params.BytesToWrite; CurrentByte++)\r
+ {\r
+ if ((V2Command == CMD_READ_FLASH_ISP) && (CurrentByte & 0x01))\r
+ Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_ODD_BYTE_MASK;\r
+ \r
+ SPI_SendByte(Write_Memory_Params.ProgrammingCommands[0]);\r
+ SPI_SendByte(CurrentAddress >> 8);\r
+ SPI_SendByte(CurrentAddress & 0xFF);\r
+ SPI_SendByte(Endpoint_Read_Byte());\r
+ \r
+ // TODO - Correct Polling\r
+\r
+ if (((V2Command == CMD_PROGRAM_FLASH_ISP) && (CurrentByte & 0x01)) || (V2Command == CMD_PROGRAM_EEPROM_ISP))\r
+ CurrentAddress++;\r
+ }\r
+ \r
+ /* If the current page must be committed, send the PROGRAM PAGE command to the target */\r
+ if (Write_Memory_Params.ProgrammingMode & PROG_MODE_COMMIT_PAGE_MASK)\r
+ {\r
+ SPI_SendByte(Write_Memory_Params.ProgrammingCommands[1]);\r
+ SPI_SendByte(CurrentAddress >> 8);\r
+ SPI_SendByte(CurrentAddress & 0xFF);\r
+ SPI_SendByte(0x00);\r
+ }\r
+ }\r
+ else\r
+ { \r
+ // TODO - Read in programming data, write to device \r