Minor fixups to the documentation and preprocessor tokens.
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / XPROG / TINYNVM.c
index e3e43dd..c7e64a5 100644 (file)
@@ -143,9 +143,9 @@ bool TINYNVM_ReadMemory(const uint16_t ReadAddress, uint8_t* ReadBuffer, uint16_
 \r
 /** Writes word addressed memory to the target's memory spaces.\r
  *\r
- *  \param[in]  WriteAddress  Start address to write to within the target's address space\r
- *  \param[in]  WriteBuffer   Buffer to source data from\r
- *  \param[in]  WriteLength   Total number of bytes to write to the device (must be an integer multiple of 2)\r
+ *  \param[in] WriteAddress  Start address to write to within the target's address space\r
+ *  \param[in] WriteBuffer   Buffer to source data from\r
+ *  \param[in] WriteLength   Total number of bytes to write to the device (must be an integer multiple of 2)\r
  *\r
  *  \return Boolean true if the command sequence complete successfully\r
  */\r
@@ -189,17 +189,25 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint
 \r
 /** Erases the target's memory space.\r
  *\r
+ *  \param[in] EraseCommand  NVM erase command to send to the device\r
+ *  \param[in] Address       Address inside the memory space to erase\r
+ *\r
  *  \return Boolean true if the command sequence complete successfully\r
  */\r
-bool TINYNVM_EraseMemory(void)\r
+bool TINYNVM_EraseMemory(const uint8_t EraseCommand, const uint16_t Address)\r
 {\r
        /* Wait until the NVM controller is no longer busy */\r
        if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
          return false;\r
 \r
-       /* Set the NVM control register to the CHIP ERASE command to erase the target */\r
+       /* Set the NVM control register to the target memory erase command */\r
        TINYNVM_SendWriteNVMRegister(XPROG_Param_NVMCMDRegAddr);\r
-       XPROGTarget_SendByte(TINY_NVM_CMD_CHIPERASE);   \r
+       XPROGTarget_SendByte(EraseCommand);\r
+\r
+       /* Write to a location within the target address space to start the erase process */\r
+       TINYNVM_SendPointerAddress(Address);\r
+       XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT);\r
+       XPROGTarget_SendByte(0x00);\r
 \r
        /* Wait until the NVM bus is ready again */\r
        if (!(TINYNVM_WaitWhileNVMBusBusy()))\r