From 79efd8c79e723adb3392367ae62356c5c3a835d0 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 15 Dec 2009 05:17:52 +0000 Subject: Fix a bug in the Still Image Host Class driver where the returned block status code was being truncated. Add programming support to the AVRISP project's PDI programming mode; paged memory writes are not currently functional. --- Projects/AVRISP/Lib/PDIProtocol.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'Projects/AVRISP/Lib/PDIProtocol.c') 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 { -- cgit v1.2.3