X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/8ea051de637f09f0fd2895f5a18ee9f337b9b1f1..79efd8c79e723adb3392367ae62356c5c3a835d0:/Projects/AVRISP/Lib/PDIProtocol.c?ds=sidebyside diff --git a/Projects/AVRISP/Lib/PDIProtocol.c b/Projects/AVRISP/Lib/PDIProtocol.c index 36aa3b4c5..aa03fc494 100644 --- a/Projects/AVRISP/Lib/PDIProtocol.c +++ b/Projects/AVRISP/Lib/PDIProtocol.c @@ -201,7 +201,7 @@ static void PDIProtocol_WriteMemory(void) uint8_t PageMode; uint32_t Address; uint16_t Length; - uint8_t ProgData[512]; + uint8_t ProgData[256]; } WriteMemory_XPROG_Params; Endpoint_Read_Stream_LE(&WriteMemory_XPROG_Params, (sizeof(WriteMemory_XPROG_Params) - @@ -215,24 +215,37 @@ static void PDIProtocol_WriteMemory(void) uint8_t WriteCommand = NVM_CMD_NOOP; - uint8_t WritePageCommand = NVM_CMD_NOOP; + uint8_t WriteBuffCommand = NVM_CMD_NOOP; + uint8_t EraseBuffCommand = NVM_CMD_NOOP; bool PagedMemory = false; if (WriteMemory_XPROG_Params.MemoryType == XPRG_MEM_TYPE_APPL) { - PagedMemory = true; + WriteCommand = NVM_CMD_ERASEWRITEFLASH; + WriteBuffCommand = NVM_CMD_LOADFLASHPAGEBUFF; + EraseBuffCommand = NVM_CMD_ERASEFLASHPAGEBUFF; + PagedMemory = true; } else if (WriteMemory_XPROG_Params.MemoryType == XPRG_MEM_TYPE_BOOT) { - PagedMemory = true; + WriteCommand = NVM_CMD_ERASEWRITEFLASH; + WriteBuffCommand = NVM_CMD_LOADFLASHPAGEBUFF; + EraseBuffCommand = NVM_CMD_ERASEFLASHPAGEBUFF; + PagedMemory = true; } else if (WriteMemory_XPROG_Params.MemoryType == XPRG_MEM_TYPE_EEPROM) { - PagedMemory = true; + WriteCommand = NVM_CMD_ERASEWRITEEEPROMPAGE; + WriteBuffCommand = NVM_CMD_LOADEEPROMPAGEBUFF; + EraseBuffCommand = NVM_CMD_ERASEEEPROMPAGEBUFF; + PagedMemory = true; } else if (WriteMemory_XPROG_Params.MemoryType == XPRG_MEM_TYPE_USERSIG) { - PagedMemory = true; + WriteCommand = NVM_CMD_WRITEUSERSIG; + WriteBuffCommand = NVM_CMD_LOADFLASHPAGEBUFF; + EraseBuffCommand = NVM_CMD_ERASEFLASHPAGEBUFF; + PagedMemory = true; } else if (WriteMemory_XPROG_Params.MemoryType == XPRG_MEM_TYPE_FUSE) { @@ -245,7 +258,12 @@ static void PDIProtocol_WriteMemory(void) if (PagedMemory) { - + if (!(NVMTarget_WritePageMemory(WriteBuffCommand, EraseBuffCommand, WriteCommand, + WriteMemory_XPROG_Params.PageMode, WriteMemory_XPROG_Params.Address, + WriteMemory_XPROG_Params.ProgData, WriteMemory_XPROG_Params.Length))) + { + ReturnStatus = XPRG_ERR_TIMEOUT; + } } else {