aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP/Lib/PDIProtocol.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-14 05:15:42 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-14 05:15:42 +0000
commit48e50b6b578fa7a74b4f33f067aa684e3469850e (patch)
treeb6bb45e6a9eb32f3e764cd6285380a3dcd30c424 /Projects/AVRISP/Lib/PDIProtocol.c
parent8a55d80e7e1214b8625b413fa0123a8b6ce9c825 (diff)
downloadlufa-48e50b6b578fa7a74b4f33f067aa684e3469850e.tar.gz
lufa-48e50b6b578fa7a74b4f33f067aa684e3469850e.tar.bz2
lufa-48e50b6b578fa7a74b4f33f067aa684e3469850e.zip
Added memory erase handling to the PDI protocol in the AVRISP project.
Diffstat (limited to 'Projects/AVRISP/Lib/PDIProtocol.c')
-rw-r--r--Projects/AVRISP/Lib/PDIProtocol.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/Projects/AVRISP/Lib/PDIProtocol.c b/Projects/AVRISP/Lib/PDIProtocol.c
index e3255a0c6..39f33cf49 100644
--- a/Projects/AVRISP/Lib/PDIProtocol.c
+++ b/Projects/AVRISP/Lib/PDIProtocol.c
@@ -154,11 +154,31 @@ static void PDIProtocol_Erase(void)
} Erase_XPROG_Params;
Endpoint_Read_Stream_LE(&Erase_XPROG_Params, sizeof(Erase_XPROG_Params));
+ Erase_XPROG_Params.Address = SwapEndian_32(Erase_XPROG_Params.Address);
Endpoint_ClearOUT();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
- // TODO: Send erase command here via PDI protocol
+ uint8_t EraseCommand;
+
+ if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_CHIP)
+ EraseCommand = NVM_CMD_CHIPERASE;
+ else if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_APP)
+ EraseCommand = NVM_CMD_ERASEAPPSEC;
+ else if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_BOOT)
+ EraseCommand = NVM_CMD_ERASEBOOTSEC;
+ else if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_EEPROM)
+ EraseCommand = NVM_CMD_ERASEEEPROM;
+ else if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_APP_PAGE)
+ EraseCommand = NVM_CMD_ERASEAPPSECPAGE;
+ else if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_BOOT_PAGE)
+ EraseCommand = NVM_CMD_ERASEBOOTSECPAGE;
+ else if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_EEPROM_PAGE)
+ EraseCommand = NVM_CMD_ERASEEEPROMPAGE;
+ else if (Erase_XPROG_Params.MemoryType == XPRG_ERASE_USERSIG)
+ EraseCommand = NVM_CMD_ERASEUSERSIG;
+
+ NVMTarget_EraseMemory(EraseCommand, Erase_XPROG_Params.Address);
Endpoint_Write_Byte(CMD_XPROG);
Endpoint_Write_Byte(XPRG_CMD_ERASE);