From 37480086512b2aa98c13db294e1adfb67d280dd0 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Tue, 5 Apr 2016 11:01:49 +0800 Subject: [PATCH] [DeviceDrivers] Add card remove operations in MMC/SD. --- components/drivers/sdio/mmcsd_core.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index 095ecaff8a..0cbf8f1892 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -651,6 +651,23 @@ void mmcsd_detect(void *param) } mmcsd_host_unlock(host); } + else + { + /* card removed */ + mmcsd_host_lock(host); + if (host->card->sdio_function_num != 0) + { + rt_kprintf("unsupport sdio card plug out!\n"); + } + else + { + rt_mmcsd_blk_remove(host->card); + rt_free(host->card); + + host->card = RT_NULL; + } + mmcsd_host_unlock(host); + } } } } @@ -691,8 +708,8 @@ void rt_mmcsd_core_init(void) { rt_err_t ret; - /* init detect sd cart thread */ - /* init mailbox and create detect sd card thread */ + /* initialize detect SD cart thread */ + /* initialize mailbox and create detect SD card thread */ ret = rt_mb_init(&mmcsd_detect_mb, "mmcsdmb", &mmcsd_detect_mb_pool[0], sizeof(mmcsd_detect_mb_pool), RT_IPC_FLAG_FIFO); @@ -707,3 +724,4 @@ void rt_mmcsd_core_init(void) rt_sdio_init(); } +