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

Function _read_block

components/drivers/spi/dev_spi_msd.c:337–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337static rt_err_t _read_block(struct rt_spi_device *device, void *buffer, uint32_t block_size)
338{
339 struct rt_spi_message message;
340 rt_err_t result;
341
342 /* wati token */
343 result = _wait_token(device, MSD_TOKEN_READ_START);
344 if (result != RT_EOK)
345 {
346 return result;
347 }
348
349 /* read data */
350 {
351 /* initial message */
352 message.send_buf = RT_NULL;
353 message.recv_buf = buffer;
354 message.length = block_size;
355 message.cs_take = message.cs_release = 0;
356
357 /* transfer message */
358 device->bus->ops->xfer(device, &message);
359 } /* read data */
360
361 /* get crc */
362 {
363 uint8_t recv_buffer[2];
364
365 /* initial message */
366 message.send_buf = RT_NULL;
367 message.recv_buf = recv_buffer;
368 message.length = 2;
369 message.cs_take = message.cs_release = 0;
370
371 /* transfer message */
372 device->bus->ops->xfer(device, &message);
373 } /* get crc */
374
375 return RT_EOK;
376}
377
378static rt_err_t _write_block(struct rt_spi_device *device, const void *buffer, uint32_t block_size, uint8_t token)
379{

Callers 3

rt_msd_initFunction · 0.85
rt_msd_readFunction · 0.85
rt_msd_sdhc_readFunction · 0.85

Calls 1

_wait_tokenFunction · 0.85

Tested by

no test coverage detected