/* Wait for the transfer complete. It covers the interrupt mode, DMA mode and PIO mode.  */
int card_wait_xfer_done(uint32_t instance)
/* Wait for the transfer complete. It covers the interrupt mode, DMA mode and PIO mode.  */
int card_wait_xfer_done(uint32_t instance)
{
    int usdhc_status = 0;
    int timeout = 0x40000000;
    if(SDHC_INTR_mode)
    {
        while (timeout--) {
            card_xfer_result(instance, &usdhc_status);
            if (usdhc_status == 1)
                return SUCCESS;
        }
     } else {
            return SUCCESS;
     }
     return FAIL;
}