bool XMEGANVM_WaitWhileNVMBusBusy(void)
{
/* Poll the STATUS register to check to see if NVM access has been enabled */
- while (TimeoutMSRemaining)
+ for (;;)
{
/* Send the LDCS command to read the PDI STATUS register to see the NVM bus is active */
XPROGTarget_SendByte(PDI_CMD_LDCS | PDI_STATUS_REG);
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
- if (!(TimeoutMSRemaining))
+ if (!(TimeoutTicksRemaining))
return false;
/* Check the status register read response to see if the NVM bus is enabled */
if (StatusRegister & PDI_STATUS_NVM)
- {
- TimeoutMSRemaining = COMMAND_TIMEOUT_MS;
- return true;
- }
+ return true;
}
-
- return false;
}
/** Waits while the target's NVM controller is busy performing an operation, exiting if the
bool XMEGANVM_WaitWhileNVMControllerBusy(void)
{
/* Poll the NVM STATUS register while the NVM controller is busy */
- while (TimeoutMSRemaining)
+ for (;;)
{
/* Send a LDS command to read the NVM STATUS register to check the BUSY flag */
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
- if (!(TimeoutMSRemaining))
+ if (!(TimeoutTicksRemaining))
return false;
/* Check to see if the BUSY flag is still set */
if (!(StatusRegister & (1 << 7)))
- {
- TimeoutMSRemaining = COMMAND_TIMEOUT_MS;
- return true;
- }
+ return true;
}
-
- return false;
}
/** Retrieves the CRC value of the given memory space.
for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)
((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
- return (TimeoutMSRemaining != 0);
+ return (TimeoutTicksRemaining != 0);
}
/** Reads memory from the target's memory spaces.
/* Send a LD command with indirect access and post-increment to read out the bytes */
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
- while (ReadSize-- && TimeoutMSRemaining)
+ while (ReadSize-- && TimeoutTicksRemaining)
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
- return (TimeoutMSRemaining != 0);
+ return (TimeoutTicksRemaining != 0);
}
/** Writes byte addressed memory to the target's memory spaces.