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

Function rt_device_write

components/drivers/core/device.c:380–405  ·  view source on GitHub ↗

* @brief This function will write some data to a device. * * @param dev is the pointer of device driver structure. * * @param pos is the position when writing. * * @param buffer is the data buffer to be written to device. * * @param size is the size of buffer. * * @return the actually written size on successful, otherwise 0 will be returned. * * @note the unit of size/pos is a block fo

Source from the content-addressed store, hash-verified

378 * @note the unit of size/pos is a block for block device.
379 */
380rt_ssize_t rt_device_write(rt_device_t dev,
381 rt_off_t pos,
382 const void *buffer,
383 rt_size_t size)
384{
385 /* parameter check */
386 RT_ASSERT(dev != RT_NULL);
387 RT_ASSERT(rt_object_get_type(&dev->parent) == RT_Object_Class_Device);
388
389 if (dev->ref_count == 0)
390 {
391 rt_set_errno(-RT_ERROR);
392 return 0;
393 }
394
395 /* call device_write interface */
396 if (device_write != RT_NULL)
397 {
398 return device_write(dev, pos, buffer, size);
399 }
400
401 /* set error code */
402 rt_set_errno(-RT_ENOSYS);
403
404 return 0;
405}
406RTM_EXPORT(rt_device_write);
407
408/**

Callers 15

_ep_out_handlerFunction · 0.85
speaker_entryFunction · 0.85
sys_logFunction · 0.85
sys_device_writeFunction · 0.85
serial_fops_writeFunction · 0.85
serial_fops_writeFunction · 0.85
block_readFunction · 0.85
nonblock_writeFunction · 0.85
uart_send_entryFunction · 0.85
rx_timeout_test_itemFunction · 0.85
test_itemFunction · 0.85
uart_send_entryFunction · 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
test_itemFunction · 0.68
uart_tx_demoFunction · 0.68
test_rtc_interfaceFunction · 0.68
test_hwtimerFunction · 0.68
uart_threadFunction · 0.68
uart_taskFunction · 0.68
usbd_testFunction · 0.68
uart_threadFunction · 0.68
uart_taskFunction · 0.68