aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-02-02 04:33:58 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-02-02 04:33:58 +0000
commit5687ac7316335009160ccd7f56fce5e7746c5889 (patch)
tree565ee94a92c3a061f9b5b806392c1b9aced2292b /Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
parent8d494808919315ec4aaeb3f568e61cb93031d956 (diff)
downloadlufa-5687ac7316335009160ccd7f56fce5e7746c5889.tar.gz
lufa-5687ac7316335009160ccd7f56fce5e7746c5889.tar.bz2
lufa-5687ac7316335009160ccd7f56fce5e7746c5889.zip
Fix TPI mode chip erase code not properly erasing the target memory space.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
index e3e43dd50..ca5def27e 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
@@ -189,17 +189,24 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint
/** Erases the target's memory space.
*
+ * \param[in] Address Address inside the memory space to erase
+ *
* \return Boolean true if the command sequence complete successfully
*/
-bool TINYNVM_EraseMemory(void)
+bool TINYNVM_EraseMemory(const uint8_t EraseCommand, const uint16_t Address)
{
/* Wait until the NVM controller is no longer busy */
if (!(TINYNVM_WaitWhileNVMControllerBusy()))
return false;
- /* Set the NVM control register to the CHIP ERASE command to erase the target */
+ /* Set the NVM control register to the target memory erase command */
TINYNVM_SendWriteNVMRegister(XPROG_Param_NVMCMDRegAddr);
- XPROGTarget_SendByte(TINY_NVM_CMD_CHIPERASE);
+ XPROGTarget_SendByte(EraseCommand);
+
+ /* Write to a location within the target address space to start the erase process */
+ TINYNVM_SendPointerAddress(Address);
+ XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT);
+ XPROGTarget_SendByte(0x00);
/* Wait until the NVM bus is ready again */
if (!(TINYNVM_WaitWhileNVMBusBusy()))