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

Function sdio_io_send_op_cond

components/drivers/sdio/dev_sdio.c:63–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63rt_int32_t sdio_io_send_op_cond(struct rt_mmcsd_host *host,
64 rt_uint32_t ocr,
65 rt_uint32_t *cmd5_resp)
66{
67 struct rt_mmcsd_cmd cmd;
68 rt_int32_t i, err = 0;
69
70 RT_ASSERT(host != RT_NULL);
71
72 rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd));
73
74 cmd.cmd_code = SD_IO_SEND_OP_COND;
75 cmd.arg = ocr;
76 cmd.flags = RESP_SPI_R4 | RESP_R4 | CMD_BCR;
77
78 for (i = 100; i; i--)
79 {
80 err = mmcsd_send_cmd(host, &cmd, 0);
81 if (err)
82 break;
83
84 /* if we're just probing, do a single pass */
85 if (ocr == 0)
86 break;
87
88 /* otherwise wait until reset completes */
89 if (controller_is_spi(host))
90 {
91 /*
92 * Both R1_SPI_IDLE and MMC_CARD_BUSY indicate
93 * an initialized card under SPI, but some cards
94 * (Marvell's) only behave when looking at this
95 * one.
96 */
97 if (cmd.resp[1] & CARD_BUSY)
98 break;
99 }
100 else
101 {
102 if (cmd.resp[0] & CARD_BUSY)
103 break;
104 }
105
106 err = -RT_ETIMEOUT;
107
108 rt_thread_mdelay(10);
109 }
110
111 if (cmd5_resp)
112 *cmd5_resp = cmd.resp[controller_is_spi(host) ? 1 : 0];
113
114 return err;
115}
116
117rt_int32_t sdio_io_rw_direct(struct rt_mmcsd_card *card,
118 rt_int32_t rw,

Callers 2

sdio_init_cardFunction · 0.85
mmcsd_detectFunction · 0.85

Calls 3

rt_memsetFunction · 0.85
mmcsd_send_cmdFunction · 0.85
rt_thread_mdelayFunction · 0.85

Tested by

no test coverage detected