Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
2bd7a0e8
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
2bd7a0e8
编写于
4月 24, 2018
作者:
lymzzyh
提交者:
GitHub
4月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1382 from uestczyh222/master
[Coponents][USB device]add class register interface
上级
70f7ea2a
1ed77003
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
107 addition
and
69 deletion
+107
-69
components/drivers/include/drivers/usb_device.h
components/drivers/include/drivers/usb_device.h
+15
-4
components/drivers/usb/usbdevice/class/cdc_vcom.c
components/drivers/usb/usbdevice/class/cdc_vcom.c
+11
-1
components/drivers/usb/usbdevice/class/ecm.c
components/drivers/usb/usbdevice/class/ecm.c
+12
-0
components/drivers/usb/usbdevice/class/hid.c
components/drivers/usb/usbdevice/class/hid.c
+10
-0
components/drivers/usb/usbdevice/class/mstorage.c
components/drivers/usb/usbdevice/class/mstorage.c
+11
-0
components/drivers/usb/usbdevice/class/rndis.c
components/drivers/usb/usbdevice/class/rndis.c
+12
-0
components/drivers/usb/usbdevice/class/winusb.c
components/drivers/usb/usbdevice/class/winusb.c
+11
-0
components/drivers/usb/usbdevice/core/usbdevice.c
components/drivers/usb/usbdevice/core/usbdevice.c
+25
-64
未找到文件。
components/drivers/include/drivers/usb_device.h
浏览文件 @
2bd7a0e8
...
...
@@ -213,6 +213,13 @@ struct udevice
};
typedef
struct
udevice
*
udevice_t
;
struct
udclass
{
rt_list_t
list
;
ufunction_t
(
*
rt_usbd_function_create
)(
udevice_t
device
);
};
typedef
struct
udclass
*
udclass_t
;
enum
udev_msg_type
{
USB_MSG_SETUP_NOTIFY
,
...
...
@@ -248,6 +255,7 @@ struct udev_msg
};
typedef
struct
udev_msg
*
udev_msg_t
;
int
rt_usbd_class_list_init
(
void
);
udevice_t
rt_usbd_device_new
(
void
);
uconfig_t
rt_usbd_config_new
(
void
);
ufunction_t
rt_usbd_function_new
(
udevice_t
device
,
udev_desc_t
dev_desc
,
...
...
@@ -266,6 +274,7 @@ rt_err_t rt_usbd_device_set_qualifier(udevice_t device, struct usb_qualifier_des
rt_err_t
rt_usbd_device_set_os_comp_id_desc
(
udevice_t
device
,
usb_os_comp_id_desc_t
os_comp_id_desc
);
rt_err_t
rt_usbd_device_add_config
(
udevice_t
device
,
uconfig_t
cfg
);
rt_err_t
rt_usbd_config_add_function
(
uconfig_t
cfg
,
ufunction_t
func
);
rt_err_t
rt_usbd_class_register
(
udclass_t
udclass
);
rt_err_t
rt_usbd_function_add_interface
(
ufunction_t
func
,
uintf_t
intf
);
rt_err_t
rt_usbd_interface_add_altsetting
(
uintf_t
intf
,
ualtsetting_t
setting
);
rt_err_t
rt_usbd_altsetting_add_endpoint
(
ualtsetting_t
setting
,
uep_t
ep
);
...
...
@@ -283,10 +292,12 @@ rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size);
rt_size_t
rt_usbd_ep0_read
(
udevice_t
device
,
void
*
buffer
,
rt_size_t
size
,
rt_err_t
(
*
rx_ind
)(
udevice_t
device
,
rt_size_t
size
));
ufunction_t
rt_usbd_function_mstorage_create
(
udevice_t
device
);
ufunction_t
rt_usbd_function_cdc_create
(
udevice_t
device
);
ufunction_t
rt_usbd_function_rndis_create
(
udevice_t
device
);
ufunction_t
rt_usbd_function_dap_create
(
udevice_t
device
);
int
rt_usbd_vcom_class_register
(
void
);
int
rt_usbd_ecm_class_register
(
void
);
int
rt_usbd_hid_class_register
(
void
);
int
rt_usbd_msc_class_register
(
void
);
int
rt_usbd_rndis_class_register
(
void
);
int
rt_usbd_winusb_class_register
(
void
);
#ifdef RT_USB_DEVICE_COMPOSITE
rt_err_t
rt_usbd_function_set_iad
(
ufunction_t
func
,
uiad_desc_t
iad_desc
);
...
...
components/drivers/usb/usbdevice/class/cdc_vcom.c
浏览文件 @
2bd7a0e8
...
...
@@ -934,6 +934,16 @@ static void rt_usb_vcom_init(struct ufunction *func)
result
=
rt_thread_startup
(
&
vcom_thread
);
RT_ASSERT
(
result
==
RT_EOK
);
}
struct
udclass
vcom_class
=
{
.
rt_usbd_function_create
=
rt_usbd_function_cdc_create
};
#endif
int
rt_usbd_vcom_class_register
(
void
)
{
rt_usbd_class_register
(
&
vcom_class
);
return
0
;
}
INIT_PREV_EXPORT
(
rt_usbd_vcom_class_register
);
#endif
components/drivers/usb/usbdevice/class/ecm.c
浏览文件 @
2bd7a0e8
...
...
@@ -604,3 +604,15 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
return
cdc
;
}
struct
udclass
ecm_class
=
{
.
rt_usbd_function_create
=
rt_usbd_function_ecm_create
};
int
rt_usbd_ecm_class_register
(
void
)
{
rt_usbd_class_register
(
&
ecm_class
);
return
0
;
}
INIT_PREV_EXPORT
(
rt_usbd_ecm_class_register
);
components/drivers/usb/usbdevice/class/hid.c
浏览文件 @
2bd7a0e8
...
...
@@ -674,5 +674,15 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
rt_usb_hid_init
(
func
);
return
func
;
}
struct
udclass
hid_class
=
{
.
rt_usbd_function_create
=
rt_usbd_function_hid_create
};
int
rt_usbd_hid_class_register
(
void
)
{
rt_usbd_class_register
(
&
hid_class
);
return
0
;
}
INIT_PREV_EXPORT
(
rt_usbd_hid_class_register
);
#endif
/* RT_USB_DEVICE_HID */
components/drivers/usb/usbdevice/class/mstorage.c
浏览文件 @
2bd7a0e8
...
...
@@ -1114,5 +1114,16 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
return
func
;
}
struct
udclass
msc_class
=
{
.
rt_usbd_function_create
=
rt_usbd_function_mstorage_create
};
int
rt_usbd_msc_class_register
(
void
)
{
rt_usbd_class_register
(
&
msc_class
);
return
0
;
}
INIT_PREV_EXPORT
(
rt_usbd_msc_class_register
);
#endif
components/drivers/usb/usbdevice/class/rndis.c
浏览文件 @
2bd7a0e8
...
...
@@ -1325,3 +1325,15 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
return
cdc
;
}
struct
udclass
rndis_class
=
{
.
rt_usbd_function_create
=
rt_usbd_function_rndis_create
};
int
rt_usbd_rndis_class_register
(
void
)
{
rt_usbd_class_register
(
&
rndis_class
);
return
0
;
}
INIT_PREV_EXPORT
(
rt_usbd_rndis_class_register
);
\ No newline at end of file
components/drivers/usb/usbdevice/class/winusb.c
浏览文件 @
2bd7a0e8
...
...
@@ -320,3 +320,14 @@ ufunction_t rt_usbd_function_winusb_create(udevice_t device)
return
func
;
}
struct
udclass
winusb_class
=
{
.
rt_usbd_function_create
=
rt_usbd_function_winusb_create
};
int
rt_usbd_winusb_class_register
(
void
)
{
rt_usbd_class_register
(
&
winusb_class
);
return
0
;
}
INIT_PREV_EXPORT
(
rt_usbd_winusb_class_register
);
components/drivers/usb/usbdevice/core/usbdevice.c
浏览文件 @
2bd7a0e8
...
...
@@ -84,6 +84,19 @@ struct usb_os_comp_id_descriptor usb_comp_id_desc =
USB_DYNAMIC
,
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
};
static
rt_list_t
class_list
;
int
rt_usbd_class_list_init
(
void
)
{
rt_list_init
(
&
class_list
);
return
0
;
}
INIT_BOARD_EXPORT
(
rt_usbd_class_list_init
);
rt_err_t
rt_usbd_class_register
(
udclass_t
udclass
)
{
rt_list_insert_before
(
&
class_list
,
&
udclass
->
list
);
return
RT_EOK
;
}
rt_err_t
rt_usb_device_init
(
void
)
{
...
...
@@ -91,6 +104,8 @@ rt_err_t rt_usb_device_init(void)
udevice_t
udevice
;
uconfig_t
cfg
;
ufunction_t
func
;
rt_list_t
*
i
;
udclass_t
udclass
;
/* create and startup usb device thread */
rt_usbd_core_init
();
...
...
@@ -111,79 +126,25 @@ rt_err_t rt_usb_device_init(void)
/* create a configuration object */
cfg
=
rt_usbd_config_new
();
rt_usbd_device_set_os_comp_id_desc
(
udevice
,
&
usb_comp_id_desc
);
rt_usbd_device_set_os_comp_id_desc
(
udevice
,
&
usb_comp_id_desc
);
#ifdef RT_USB_DEVICE_MSTORAGE
for
(
i
=
class_list
.
next
;
i
!=
&
class_list
;
i
=
i
->
next
)
{
extern
ufunction_t
rt_usbd_function_mstorage_create
(
udevice_t
device
);
/* create a mass storage function object */
func
=
rt_usbd_function_mstorage_create
(
udevice
);
/* get a class creater */
udclass
=
rt_list_entry
(
i
,
struct
udclass
,
list
);
/* create a function object */
func
=
udclass
->
rt_usbd_function_create
(
udevice
);
/* add the function to the configuration */
rt_usbd_config_add_function
(
cfg
,
func
);
}
#endif
#ifdef RT_USB_DEVICE_CDC
{
extern
ufunction_t
rt_usbd_function_cdc_create
(
udevice_t
device
);
/* create a cdc function object */
func
=
rt_usbd_function_cdc_create
(
udevice
);
/* add the function to the configuration */
rt_usbd_config_add_function
(
cfg
,
func
);
}
#endif
#ifdef RT_USB_DEVICE_HID
{
extern
ufunction_t
rt_usbd_function_hid_create
(
udevice_t
device
);
/* create a cdc function object */
func
=
rt_usbd_function_hid_create
(
udevice
);
/* add the function to the configuration */
rt_usbd_config_add_function
(
cfg
,
func
);
}
#endif
#ifdef RT_USB_DEVICE_RNDIS
{
extern
ufunction_t
rt_usbd_function_rndis_create
(
udevice_t
device
);
/* create a rndis function object */
func
=
rt_usbd_function_rndis_create
(
udevice
);
/* add the function to the configuration */
rt_usbd_config_add_function
(
cfg
,
func
);
}
#endif
#ifdef RT_USB_DEVICE_ECM
{
extern
ufunction_t
rt_usbd_function_ecm_create
(
udevice_t
device
);
/* create a rndis function object */
func
=
rt_usbd_function_ecm_create
(
udevice
);
/* add the function to the configuration */
rt_usbd_config_add_function
(
cfg
,
func
);
}
#endif
#ifdef RT_USB_DEVICE_WINUSB
{
extern
ufunction_t
rt_usbd_function_winusb_create
(
udevice_t
device
);
/* create a rndis function object */
func
=
rt_usbd_function_winusb_create
(
udevice
);
/* add the function to the configuration */
rt_usbd_config_add_function
(
cfg
,
func
);
}
#endif
/* set device descriptor to the device */
#ifdef RT_USB_DEVICE_COMPOSITE
rt_usbd_device_set_descriptor
(
udevice
,
&
compsit_desc
);
rt_usbd_device_set_string
(
udevice
,
ustring
);
rt_usbd_device_set_qualifier
(
udevice
,
&
dev_qualifier
);
if
(
udevice
->
dcd
->
device_is_hs
)
{
rt_usbd_device_set_qualifier
(
udevice
,
&
dev_qualifier
);
}
#else
rt_usbd_device_set_descriptor
(
udevice
,
func
->
dev_desc
);
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录