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

Function sdio_host_create

bsp/bluetrum/libraries/hal_drivers/drv_sdio.c:537–600  ·  view source on GitHub ↗

* @brief This function create mmcsd host. * @param sdio_des ab32_sdio_des * @retval rt_mmcsd_host */

Source from the content-addressed store, hash-verified

535 * @retval rt_mmcsd_host
536 */
537struct rt_mmcsd_host *sdio_host_create(struct ab32_sdio_des *sdio_des)
538{
539 struct rt_mmcsd_host *host;
540 struct rthw_sdio *sdio = RT_NULL;
541
542 if ((sdio_des == RT_NULL) || (sdio_des->txconfig == RT_NULL) || (sdio_des->rxconfig == RT_NULL))
543 {
544 LOG_E("L:%d F:%s %s %s %s",
545 (sdio_des == RT_NULL ? "sdio_des is NULL" : ""),
546 (sdio_des ? (sdio_des->txconfig ? "txconfig is NULL" : "") : ""),
547 (sdio_des ? (sdio_des->rxconfig ? "rxconfig is NULL" : "") : "")
548 );
549 return RT_NULL;
550 }
551
552 sdio = rt_malloc(sizeof(struct rthw_sdio));
553 if (sdio == RT_NULL)
554 {
555 LOG_E("L:%d F:%s malloc rthw_sdio fail");
556 return RT_NULL;
557 }
558 rt_memset(sdio, 0, sizeof(struct rthw_sdio));
559
560 host = mmcsd_alloc_host();
561 if (host == RT_NULL)
562 {
563 LOG_E("L:%d F:%s mmcsd alloc host fail");
564 rt_free(sdio);
565 return RT_NULL;
566 }
567
568 rt_memcpy(&sdio->sdio_des, sdio_des, sizeof(struct ab32_sdio_des));
569 sdio->sdio_des.hw_sdio = (sdio_des->hw_sdio == RT_NULL ? SDMMC0_BASE : sdio_des->hw_sdio);
570 sdio->sdio_des.clk_get = (sdio_des->clk_get == RT_NULL ? ab32_sdio_clk_get : sdio_des->clk_get);
571
572 rt_event_init(&sdio->event, "sdio", RT_IPC_FLAG_FIFO);
573 rt_mutex_init(&sdio->mutex, "sdio", RT_IPC_FLAG_PRIO);
574
575 /* set host defautl attributes */
576 host->ops = &ab32_sdio_ops;
577 host->freq_min = 240 * 1000;
578 host->freq_max = SDIO_MAX_FREQ;
579 host->valid_ocr = 0X00FFFF80;/* The voltage range supported is 1.65v-3.6v */
580#ifndef SDIO_USING_1_BIT
581 host->flags = MMCSD_BUSWIDTH_4 | MMCSD_MUTBLKWRITE | MMCSD_SUP_SDIO_IRQ;
582#else
583 host->flags = MMCSD_MUTBLKWRITE | MMCSD_SUP_SDIO_IRQ;
584#endif
585 host->max_seg_size = SDIO_BUFF_SIZE;
586 host->max_dma_segs = 1;
587 host->max_blk_size = 512;
588 host->max_blk_count = 512;
589
590 /* link up host and sdio */
591 sdio->host = host;
592 host->private_data = sdio;
593
594 rthw_sdio_irq_update(host, 1);

Callers 1

rt_hw_sdio_initFunction · 0.70

Calls 9

rt_mallocFunction · 0.85
rt_memsetFunction · 0.85
mmcsd_alloc_hostFunction · 0.85
rt_freeFunction · 0.85
rt_memcpyFunction · 0.85
rt_event_initFunction · 0.85
rt_mutex_initFunction · 0.85
mmcsd_changeFunction · 0.85
rthw_sdio_irq_updateFunction · 0.70

Tested by

no test coverage detected