Data Structures |
struct | rt_device |
struct | rt_device_blk_geometry |
struct | rt_device_graphic_info |
struct | rt_device_rect_info |
struct | rt_device_graphic_ops |
Defines |
#define | RT_DEVICE_FLAG_DEACTIVATE 0x000 |
#define | RT_DEVICE_FLAG_RDONLY 0x001 |
#define | RT_DEVICE_FLAG_WRONLY 0x002 |
#define | RT_DEVICE_FLAG_RDWR 0x003 |
#define | RT_DEVICE_FLAG_REMOVABLE 0x004 |
#define | RT_DEVICE_FLAG_STANDALONE 0x008 |
#define | RT_DEVICE_FLAG_ACTIVATED 0x010 |
#define | RT_DEVICE_FLAG_SUSPENDED 0x020 |
#define | RT_DEVICE_FLAG_STREAM 0x040 |
#define | RT_DEVICE_FLAG_INT_RX 0x100 |
#define | RT_DEVICE_FLAG_DMA_RX 0x200 |
#define | RT_DEVICE_FLAG_INT_TX 0x400 |
#define | RT_DEVICE_FLAG_DMA_TX 0x800 |
#define | RT_DEVICE_OFLAG_CLOSE 0x000 |
#define | RT_DEVICE_OFLAG_RDONLY 0x001 |
#define | RT_DEVICE_OFLAG_WRONLY 0x002 |
#define | RT_DEVICE_OFLAG_RDWR 0x003 |
#define | RT_DEVICE_OFLAG_OPEN 0x008 |
#define | RT_DEVICE_CTRL_RESUME 0x01 |
#define | RT_DEVICE_CTRL_SUSPEND 0x02 |
#define | RT_DEVICE_CTRL_CHAR_STREAM 0x10 |
#define | RT_DEVICE_CTRL_BLK_GETGEOME 0x10 |
#define | RT_DEVICE_CTRL_NETIF_GETMAC 0x10 |
#define | RT_DEVICE_CTRL_MTD_FORMAT 0x10 |
#define | RT_DEVICE_CTRL_RTC_GET_TIME 0x10 |
#define | RT_DEVICE_CTRL_RTC_SET_TIME 0x11 |
#define | RTGRAPHIC_CTRL_RECT_UPDATE 0 |
#define | RTGRAPHIC_PIXEL_POSITION(x, y) ((x << 16) | y) |
Enumerations |
enum | rt_device_class_type {
RT_Device_Class_Char = 0,
RT_Device_Class_Block,
RT_Device_Class_NetIf,
RT_Device_Class_MTD,
RT_Device_Class_CAN,
RT_Device_Class_RTC,
RT_Device_Class_Sound,
RT_Device_Class_Graphic,
RT_Device_Class_I2C,
RT_Device_Class_USBDevice,
RT_Device_Class_USBHost,
RT_Device_Class_SPIBUS,
RT_Device_Class_SPIDevice,
RT_Device_Class_SDIO,
RT_Device_Class_Unknown
} |
Functions |
rt_device_t | rt_device_find (const char *name) |
rt_err_t | rt_device_register (rt_device_t dev, const char *name, rt_uint16_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_set_rx_indicate (rt_device_t dev, rt_err_t(*rx_ind)(rt_device_t dev, rt_size_t size)) |
rt_err_t | rt_device_set_tx_complete (rt_device_t dev, rt_err_t(*tx_done)(rt_device_t dev, void *buffer)) |
rt_err_t | rt_device_init (rt_device_t dev) |
rt_err_t | rt_device_open (rt_device_t dev, rt_uint16_t oflag) |
rt_err_t | rt_device_close (rt_device_t dev) |
rt_size_t | rt_device_read (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size) |
rt_size_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:
- open, open a device
- close, close a device
- read, read some data from a device
- write, write some data to a device
- control, send some control command to a device
Define Documentation
device flags defitions device is not not initialized
general device commands resume device
special device commands stream mode on char device
graphic device control command
build a pixel position according to (x, y) coordinates.
Enumeration Type Documentation
device (I/O) class type
- Enumerator:
RT_Device_Class_Char |
character device
|
RT_Device_Class_Block |
block device
|
RT_Device_Class_NetIf |
net interface
|
RT_Device_Class_MTD |
memory device
|
RT_Device_Class_CAN |
CAN device
|
RT_Device_Class_RTC |
RTC device
|
RT_Device_Class_Sound |
Sound device
|
RT_Device_Class_Graphic |
Graphic device
|
RT_Device_Class_I2C |
I2C device
|
RT_Device_Class_USBDevice |
USB slave device
|
RT_Device_Class_USBHost |
USB host bus
|
RT_Device_Class_SPIBUS |
SPI bus device
|
RT_Device_Class_SPIDevice |
SPI device
|
RT_Device_Class_SDIO |
SDIO bus device
|
RT_Device_Class_Unknown |
unknown device
|
Function Documentation
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.
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.
This function removes a previously registered device driver
- Parameters:
-
dev | the pointer of device driver structure |
- Returns:
- the error code, RT_EOK on successfully.
This function initializes all registered device driver
- Returns:
- the error code, RT_EOK on successfully.
This function will set the indication callback function when device receives data.
- Parameters:
-
dev | the pointer of device driver structure |
rx_ind | the indication callback function |
- Returns:
- RT_EOK
This function will set the indication callback function when device has written data to physical hardware.
- Parameters:
-
dev | the pointer of device driver structure |
tx_done | the indication callback function |
- Returns:
- RT_EOK
This function will initialize the specified device
- Parameters:
-
dev | the pointer of device driver structure |
- Returns:
- the result
This function will open a device
- Parameters:
-
dev | the pointer of device driver structure |
oflag | the flags for device open |
- Returns:
- the result
This function will close a device
- Parameters:
-
dev | the pointer of device driver structure |
- Returns:
- the result
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.
- Note:
- since 0.4.0, the unit of size/pos is a block for block device.
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.
- Note:
- since 0.4.0, the unit of size/pos is a block for block device.
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