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

Function mmcsd_mmc_init_card

components/drivers/sdio/dev_mmc.c:613–736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host,
614 rt_uint32_t ocr)
615{
616 rt_int32_t err;
617 rt_uint32_t resp[4];
618 rt_uint32_t rocr = 0;
619 rt_uint8_t *ext_csd = RT_NULL;
620 struct rt_mmcsd_card *card = RT_NULL;
621
622 mmcsd_go_idle(host);
623
624 /* The extra bit indicates that we support high capacity */
625 err = mmc_send_op_cond(host, ocr | (1 << 30), &rocr);
626 if (err)
627 goto err;
628
629 if (controller_is_spi(host))
630 {
631 err = mmcsd_spi_use_crc(host, 1);
632 if (err)
633 goto err1;
634 }
635
636 if (controller_is_spi(host))
637 err = mmcsd_get_cid(host, resp);
638 else
639 err = mmcsd_all_get_cid(host, resp);
640 if (err)
641 goto err;
642
643 card = rt_malloc(sizeof(struct rt_mmcsd_card));
644 if (!card)
645 {
646 LOG_E("malloc card failed!");
647 err = -RT_ENOMEM;
648 goto err;
649 }
650 rt_memset(card, 0, sizeof(struct rt_mmcsd_card));
651
652 card->card_type = CARD_TYPE_MMC;
653 card->host = host;
654 card->rca = 1;
655 rt_memcpy(card->resp_cid, resp, sizeof(card->resp_cid));
656
657 /*
658 * For native busses: get card RCA and quit open drain mode.
659 */
660 if (!controller_is_spi(host))
661 {
662 err = mmc_set_card_addr(host, card->rca);
663 if (err)
664 goto err1;
665
666 mmcsd_set_bus_mode(host, MMCSD_BUSMODE_PUSHPULL);
667 }
668
669 err = mmcsd_get_csd(card, card->resp_csd);
670 if (err)

Callers 1

init_mmcFunction · 0.85

Calls 15

mmcsd_go_idleFunction · 0.85
mmcsd_spi_use_crcFunction · 0.85
mmcsd_get_cidFunction · 0.85
mmcsd_all_get_cidFunction · 0.85
rt_mallocFunction · 0.85
rt_memsetFunction · 0.85
rt_memcpyFunction · 0.85
mmc_set_card_addrFunction · 0.85
mmcsd_set_bus_modeFunction · 0.85
mmcsd_get_csdFunction · 0.85
mmcsd_select_cardFunction · 0.85
mmc_get_ext_csdFunction · 0.85

Tested by

no test coverage detected