Device System
[RT-Thread Kernel API]


Functions

rt_device_t rt_device_find (const char *name)
rt_err_t rt_device_register (rt_device_t dev, const char *name, rt_uint8_t flags)
rt_err_t rt_device_unregister (rt_device_t dev)
rt_err_t rt_device_init_all (void)
rt_err_t rt_device_open (rt_device_t dev)
rt_err_t rt_device_close (rt_device_t dev)
rt_err_t rt_device_read (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
rt_err_t rt_device_write (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
rt_err_t rt_device_control (rt_device_t dev, rt_uint8_t cmd, void *arg)

Detailed Description

The Device System is designed as simple and minimum layer to help communication between applications and drivers.

The Device System provide five interfaces to driver:


Function Documentation

rt_err_t rt_device_close ( rt_device_t  dev  ) 

This function will close a device

Parameters:
dev the pointer of device driver structure
Returns:
the result

rt_err_t rt_device_control ( rt_device_t  dev,
rt_uint8_t  cmd,
void *  arg 
)

This function will perform a variety of control functions on devices.

Parameters:
dev the pointer of device driver structure
cmd the command sent to device
arg the argument of command
Returns:
the result

rt_device_t rt_device_find ( const char *  name  ) 

This function finds a device driver by specified name.

Parameters:
name the device driver's name
Returns:
the registered device driver on successful, or RT_NULL on failure.

rt_err_t rt_device_init_all ( void   ) 

This function initializes all registered device driver

Returns:
the error code, RT_EOK on successfully.

rt_err_t rt_device_open ( rt_device_t  dev  ) 

This function will open a device

Parameters:
dev the pointer of device driver structure
Returns:
the result

rt_err_t rt_device_read ( rt_device_t  dev,
rt_off_t  pos,
void *  buffer,
rt_size_t  size 
)

This function will read some data from a device.

Parameters:
dev the pointer of device driver structure
pos the position of reading
buffer the data buffer to save read data
size the size of buffer
Returns:
the actually read size on successful, otherwise negative returned.

rt_err_t rt_device_register ( rt_device_t  dev,
const char *  name,
rt_uint8_t  flags 
)

This function registers a device driver with specified name.

Parameters:
dev the pointer of device driver structure
name the device driver's name
flags the flag of device
Returns:
the error code, RT_EOK on initialization successfully.

rt_err_t rt_device_unregister ( rt_device_t  dev  ) 

This function removes a previouly registered device driver

Parameters:
dev the pointer of device driver structure
Returns:
the error code, RT_EOK on successfully.

rt_err_t rt_device_write ( rt_device_t  dev,
rt_off_t  pos,
const void *  buffer,
rt_size_t  size 
)

This function will write some data to a device.

Parameters:
dev the pointer of device driver structure
pos the position of written
buffer the data buffer to be written to device
size the size of buffer
Returns:
the actually written size on successful, otherwise negative returned.


Generated on Thu Oct 9 07:19:09 2008 for RT-Thread Kernel by  doxygen 1.5.7