MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / mmcsd_detect

Function mmcsd_detect

components/drivers/sdio/dev_mmcsd_core.c:625–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623}
624
625void mmcsd_detect(void *param)
626{
627 struct rt_mmcsd_host *host;
628 rt_uint32_t ocr;
629 rt_int32_t err;
630
631 while (1)
632 {
633 if (rt_mb_recv(&mmcsd_detect_mb, (rt_ubase_t *)&host, RT_WAITING_FOREVER) == RT_EOK)
634 {
635 if (host->card == RT_NULL)
636 {
637 mmcsd_host_lock(host);
638 mmcsd_power_up(host);
639 mmcsd_go_idle(host);
640
641 mmcsd_send_if_cond(host, host->valid_ocr);
642
643 err = sdio_io_send_op_cond(host, 0, &ocr);
644 if (!err)
645 {
646 if (init_sdio(host, ocr))
647 mmcsd_power_off(host);
648 mmcsd_host_unlock(host);
649 continue;
650 }
651
652 /*
653 * detect SD card
654 */
655 err = mmcsd_send_app_op_cond(host, 0, &ocr);
656 if (!err)
657 {
658 if (init_sd(host, ocr))
659 mmcsd_power_off(host);
660 mmcsd_host_unlock(host);
661 rt_mb_send(&mmcsd_hotpluge_mb, (rt_ubase_t)host);
662 continue;
663 }
664
665 /*
666 * detect mmc card
667 */
668 err = mmc_send_op_cond(host, 0, &ocr);
669 if (!err)
670 {
671 if (init_mmc(host, ocr))
672 mmcsd_power_off(host);
673 mmcsd_host_unlock(host);
674 rt_mb_send(&mmcsd_hotpluge_mb, (rt_ubase_t)host);
675 continue;
676 }
677 mmcsd_host_unlock(host);
678 }
679 else
680 {
681 /* card removed */
682 mmcsd_host_lock(host);

Callers

nothing calls this directly

Calls 15

rt_mb_recvFunction · 0.85
mmcsd_host_lockFunction · 0.85
mmcsd_power_upFunction · 0.85
mmcsd_go_idleFunction · 0.85
mmcsd_send_if_condFunction · 0.85
sdio_io_send_op_condFunction · 0.85
init_sdioFunction · 0.85
mmcsd_power_offFunction · 0.85
mmcsd_host_unlockFunction · 0.85
mmcsd_send_app_op_condFunction · 0.85
init_sdFunction · 0.85
rt_mb_sendFunction · 0.85

Tested by

no test coverage detected