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

Function _wait_token

components/drivers/spi/dev_spi_msd.c:270–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270static rt_err_t _wait_token(struct rt_spi_device *device, uint8_t token)
271{
272 struct rt_spi_message message;
273 rt_tick_t tick_start;
274 uint8_t send, recv;
275
276 tick_start = rt_tick_get();
277
278 /* wati token */
279 /* initial message */
280 send = DUMMY;
281 message.send_buf = &send;
282 message.recv_buf = &recv;
283 message.length = 1;
284 message.cs_take = message.cs_release = 0;
285
286 while (1)
287 {
288 /* transfer message */
289 device->bus->ops->xfer(device, &message);
290
291 if (recv == token)
292 {
293 return RT_EOK;
294 }
295
296 if (rt_tick_timeout(tick_start, rt_tick_from_millisecond(CARD_WAIT_TOKEN_TIMES)))
297 {
298 MSD_DEBUG("[err] wait data start token timeout!\r\n");
299 return -RT_ETIMEOUT;
300 }
301 } /* wati token */
302}
303
304static rt_err_t _wait_ready(struct rt_spi_device *device)
305{

Callers 1

_read_blockFunction · 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