| 302 | } |
| 303 | |
| 304 | static 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 | |
| 337 | static rt_err_t _read_block(struct rt_spi_device *device, void *buffer, uint32_t block_size) |
| 338 | { |
no test coverage detected