forked from mfulz_github/qmk_firmware
Fix TPI mode chip erase code not properly erasing the target memory space.
This commit is contained in:
parent
8d49480891
commit
5687ac7316
Projects/AVRISP-MKII/Lib/XPROG
|
@ -188,18 +188,25 @@ 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()))
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
bool TINYNVM_WaitWhileNVMBusBusy(void);
|
||||
bool TINYNVM_ReadMemory(const uint16_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadLength);
|
||||
bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint16_t WriteLength);
|
||||
bool TINYNVM_EraseMemory(void);
|
||||
bool TINYNVM_EraseMemory(const uint8_t EraseCommand, const uint16_t Address);
|
||||
|
||||
#if defined(INCLUDE_FROM_TINYNVM_C)
|
||||
static void TINYNVM_SendReadNVMRegister(const uint8_t Address);
|
||||
|
|
|
@ -322,7 +322,7 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
|
|||
{
|
||||
/* Other erase modes just need us to address a byte within the target memory space */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendAddress(Address);
|
||||
XMEGANVM_SendAddress(Address);
|
||||
XPROGTarget_SendByte(0x00);
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ static void XPROGProtocol_Erase(void)
|
|||
else
|
||||
{
|
||||
/* Erase the target memory, indicate timeout if ocurred */
|
||||
if (!(TINYNVM_EraseMemory()))
|
||||
if (!(TINYNVM_EraseMemory(TINY_NVM_CMD_CHIPERASE, Erase_XPROG_Params.Address)))
|
||||
ReturnStatus = XPRG_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue