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

Function _wait_ready

components/drivers/spi/dev_spi_msd.c:304–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304static rt_err_t _wait_ready(struct rt_spi_device *device)
305{
306 struct rt_spi_message message;
307 rt_tick_t tick_start;
308 uint8_t send, recv;
309
310 tick_start = rt_tick_get();
311
312 send = DUMMY;
313 /* initial message */
314 message.send_buf = &send;
315 message.recv_buf = &recv;
316 message.length = 1;
317 message.cs_take = message.cs_release = 0;
318
319 while (1)
320 {
321 /* transfer message */
322 device->bus->ops->xfer(device, &message);
323
324 if (recv == DUMMY)
325 {
326 return RT_EOK;
327 }
328
329 if (rt_tick_timeout(tick_start, rt_tick_from_millisecond(1000)))
330 {
331 MSD_DEBUG("[err] wait ready timeout!\r\n");
332 return -RT_ETIMEOUT;
333 }
334 }
335}
336
337static rt_err_t _read_block(struct rt_spi_device *device, void *buffer, uint32_t block_size)
338{

Callers 4

_send_cmdFunction · 0.85
_write_blockFunction · 0.85
rt_msd_writeFunction · 0.85
rt_msd_sdhc_writeFunction · 0.85

Calls 3

rt_tick_getFunction · 0.85
rt_tick_timeoutFunction · 0.85
rt_tick_from_millisecondFunction · 0.85

Tested by

no test coverage detected