X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/8d494808919315ec4aaeb3f568e61cb93031d956..53eca61d02f296262011b802e80f145329ace34b:/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c index e3e43dd50..c7e64a5eb 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c @@ -143,9 +143,9 @@ bool TINYNVM_ReadMemory(const uint16_t ReadAddress, uint8_t* ReadBuffer, uint16_ /** Writes word addressed memory to the target's memory spaces. * - * \param[in] WriteAddress Start address to write to within the target's address space - * \param[in] WriteBuffer Buffer to source data from - * \param[in] WriteLength Total number of bytes to write to the device (must be an integer multiple of 2) + * \param[in] WriteAddress Start address to write to within the target's address space + * \param[in] WriteBuffer Buffer to source data from + * \param[in] WriteLength Total number of bytes to write to the device (must be an integer multiple of 2) * * \return Boolean true if the command sequence complete successfully */ @@ -189,17 +189,25 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint /** Erases the target's memory space. * + * \param[in] EraseCommand NVM erase command to send to the device + * \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()))