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

Function rt_device_read

components/drivers/core/device.c:337–362  ·  view source on GitHub ↗

* @brief This function will read some data from a device. * * @param dev is the pointer of device driver structure. * * @param pos is the position when reading. * * @param buffer is a data buffer to save the read data. * * @param size is the size of buffer. * * @return the actually read size on successful, otherwise 0 will be returned. * * @note the unit of size/pos is a block for bloc

Source from the content-addressed store, hash-verified

335 * @note the unit of size/pos is a block for block device.
336 */
337rt_ssize_t rt_device_read(rt_device_t dev,
338 rt_off_t pos,
339 void *buffer,
340 rt_size_t size)
341{
342 /* parameter check */
343 RT_ASSERT(dev != RT_NULL);
344 RT_ASSERT(rt_object_get_type(&dev->parent) == RT_Object_Class_Device);
345
346 if (dev->ref_count == 0)
347 {
348 rt_set_errno(-RT_ERROR);
349 return 0;
350 }
351
352 /* call device_read interface */
353 if (device_read != RT_NULL)
354 {
355 return device_read(dev, pos, buffer, size);
356 }
357
358 /* set error code */
359 rt_set_errno(-RT_ENOSYS);
360
361 return 0;
362}
363RTM_EXPORT(rt_device_read);
364
365/**

Callers 15

finsh_getcharFunction · 0.85
_read_10Function · 0.85
_ep_in_handlerFunction · 0.85
mic_entryFunction · 0.85
sys_device_readFunction · 0.85
sys_getrandomFunction · 0.85
serial_fops_readFunction · 0.85
serial_fops_readFunction · 0.85
block_readFunction · 0.85
uart_rec_entryFunction · 0.85
rx_timeout_test_itemFunction · 0.85
test_itemFunction · 0.85

Calls 2

rt_object_get_typeFunction · 0.85
rt_set_errnoFunction · 0.85

Tested by 15

test_itemFunction · 0.68
test_itemFunction · 0.68
test_itemFunction · 0.68
uart_rx_demoFunction · 0.68
test_ts_readFunction · 0.68
test_rtc_interfaceFunction · 0.68
test_hwtimerFunction · 0.68
uart_threadFunction · 0.68
uart_threadFunction · 0.68
uart_threadFunction · 0.68
can_rx_threadFunction · 0.68
GenClkUpFunction · 0.68