unsigned long start_time;
unsigned long end_time;
BOOL_T bCurrSDINPlugStatus = TRUE;
BOOL_T bCurrSDOUTPlugStatus = TRUE;
#define SDMMC_in_timeout 500
#define SDMMC_out_timeout 100
static vod ms_sdmmc_hotplug(unsigned long data)
{
struct ms_sdmmc_slot *p_sdmmc_slot = (struct ms_sdmmc_slot *)data;
SlotEmType eSlot = (SlotEmType)p_sdmmc_slot->slotNo;
IPEmType eIP = get_IPSlot[eSlot];
if (_GetCardDetect(eSlot)) // insert SD card
{
bCurrSDOUTPlugStatus = TRUE;
end_time = 0;
if(start_time = SDMMC_in_timeout)
{
start_time ++ ;
if (bCurrSDINPlugStatus)
{
mmc_detect_change(p_sdmmc_slot->mmc,msecs_to_jiffies(500));
HAL_CARD_SetGPIOIntAttr();
}
}else
{
start_time ++;
}
}else //remove sd card
{
start_time = 0;
bCurrSDINPlugStatus = TRUE;
if (end_time = SDMMC_out_timeout)
{
end_time ++;
if (bCurrSDOUTPlugStatus)
{
bCurrSDOUTPlugStatus = FALSE;
if (p_sdmmc_slot->mmc->card)
mmc_card_set_removed(p_sdmmc_slot->mmc->sdcard);
HAL_CARD_SetGPIOIntAttr();
}
}else if (end_time < SDMMC_out_timeout)
{
end_time ++;
}
}
mdelay(1);
if (!gb_ShareCDZIRQSlot[eSlot])
enable_irq(p_sdmmc_slot->cdzIRQNo);
}