/* Waits for a FLASH operation to complete or a TIMEOUT to occur.  */
FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout)
/* Waits for a FLASH operation to complete or a TIMEOUT to occur.  */
FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout)
{
    FLASH_Status status = FLASH_COMPLETE;
    status = FLASH_GetStatus();
    while ((status == FLASH_BUSY) && (Timeout != 0x00))
    {
        status = FLASH_GetStatus();
        Timeout--;
    }
    if (Timeout == 0x00)
    {
        status = FLASH_TIMEOUT;
    }
    return status;
}