|
|
@ -77,13 +77,15 @@ static void TINYNVM_SendWriteNVMRegister(const uint8_t Address)
|
|
|
|
bool TINYNVM_WaitWhileNVMBusBusy(void)
|
|
|
|
bool TINYNVM_WaitWhileNVMBusBusy(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Poll the STATUS register to check to see if NVM access has been enabled */
|
|
|
|
/* Poll the STATUS register to check to see if NVM access has been enabled */
|
|
|
|
uint8_t TimeoutMSRemaining = 100;
|
|
|
|
|
|
|
|
while (TimeoutMSRemaining)
|
|
|
|
while (TimeoutMSRemaining)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Send the SLDCS command to read the TPI STATUS register to see the NVM bus is active */
|
|
|
|
/* Send the SLDCS command to read the TPI STATUS register to see the NVM bus is active */
|
|
|
|
XPROGTarget_SendByte(TPI_CMD_SLDCS | TPI_STATUS_REG);
|
|
|
|
XPROGTarget_SendByte(TPI_CMD_SLDCS | TPI_STATUS_REG);
|
|
|
|
if (XPROGTarget_ReceiveByte() & TPI_STATUS_NVM)
|
|
|
|
if (XPROGTarget_ReceiveByte() & TPI_STATUS_NVM)
|
|
|
|
return true;
|
|
|
|
{
|
|
|
|
|
|
|
|
TimeoutMSRemaining = COMMAND_TIMEOUT_MS;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Manage software timeout */
|
|
|
|
/* Manage software timeout */
|
|
|
|
if (TIFR0 & (1 << OCF0A))
|
|
|
|
if (TIFR0 & (1 << OCF0A))
|
|
|
@ -104,7 +106,6 @@ bool TINYNVM_WaitWhileNVMBusBusy(void)
|
|
|
|
bool TINYNVM_WaitWhileNVMControllerBusy(void)
|
|
|
|
bool TINYNVM_WaitWhileNVMControllerBusy(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Poll the STATUS register to check to see if NVM access has been enabled */
|
|
|
|
/* Poll the STATUS register to check to see if NVM access has been enabled */
|
|
|
|
uint8_t TimeoutMSRemaining = 100;
|
|
|
|
|
|
|
|
while (TimeoutMSRemaining)
|
|
|
|
while (TimeoutMSRemaining)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Send the SIN command to read the TPI STATUS register to see the NVM bus is busy */
|
|
|
|
/* Send the SIN command to read the TPI STATUS register to see the NVM bus is busy */
|
|
|
@ -112,7 +113,10 @@ bool TINYNVM_WaitWhileNVMControllerBusy(void)
|
|
|
|
|
|
|
|
|
|
|
|
/* Check to see if the BUSY flag is still set */
|
|
|
|
/* Check to see if the BUSY flag is still set */
|
|
|
|
if (!(XPROGTarget_ReceiveByte() & (1 << 7)))
|
|
|
|
if (!(XPROGTarget_ReceiveByte() & (1 << 7)))
|
|
|
|
return true;
|
|
|
|
{
|
|
|
|
|
|
|
|
TimeoutMSRemaining = COMMAND_TIMEOUT_MS;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Manage software timeout */
|
|
|
|
/* Manage software timeout */
|
|
|
|
if (TIFR0 & (1 << OCF0A))
|
|
|
|
if (TIFR0 & (1 << OCF0A))
|
|
|
|