/* Waits for a Flash operation to complete or a TIMEOUT to occur.  */
FMC_STATUS_T FMC_WaitForLastOperation(uint32_t timeOut)
/* Waits for a Flash operation to complete or a TIMEOUT to occur.  */
FMC_STATUS_T FMC_WaitForLastOperation(uint32_t timeOut)
{
    FMC_STATUS_T status = FMC_STATUS_COMPLETE;
    status = FMC_ReadStatus();
    while ((status == FMC_STATUS_BUSY) && (timeOut != 0))
    {
        status = FMC_ReadStatus();
        timeOut--;
    }
    if (timeOut == 0x00)
    {
        status = FMC_STATUS_TIMEOUT;
    }
    return status;
}