Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ihbai
rt-thread
提交
5035662c
R
rt-thread
项目概览
ihbai
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5035662c
编写于
3月 16, 2018
作者:
lymzzyh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Components][USB Device]各个class对HS进行了适配
部分class还不支持HS,RNDIS存在暂时无法解决的已知bug
上级
b553543b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
59 deletion
+76
-59
components/drivers/usb/usbdevice/class/cdc_vcom.c
components/drivers/usb/usbdevice/class/cdc_vcom.c
+11
-8
components/drivers/usb/usbdevice/class/ecm.c
components/drivers/usb/usbdevice/class/ecm.c
+17
-13
components/drivers/usb/usbdevice/class/hid.c
components/drivers/usb/usbdevice/class/hid.c
+13
-9
components/drivers/usb/usbdevice/class/mstorage.c
components/drivers/usb/usbdevice/class/mstorage.c
+17
-13
components/drivers/usb/usbdevice/class/rndis.c
components/drivers/usb/usbdevice/class/rndis.c
+18
-16
未找到文件。
components/drivers/usb/usbdevice/class/cdc_vcom.c
浏览文件 @
5035662c
...
...
@@ -114,15 +114,17 @@ static struct udevice_descriptor dev_desc =
USB_DYNAMIC
,
//bNumConfigurations;
};
//FS and HS needed
static
struct
usb_qualifier_descriptor
dev_qualifier
=
{
sizeof
(
dev_qualifier
),
USB_DESC_TYPE_DEVICEQUALIFIER
,
0x0200
,
USB_CLASS_CDC
,
0x00
,
64
,
0x01
,
sizeof
(
dev_qualifier
),
//bLength
USB_DESC_TYPE_DEVICEQUALIFIER
,
//bDescriptorType
0x0200
,
//bcdUSB
USB_CLASS_CDC
,
//bDeviceClass
0x00
,
//bDeviceSubClass
0x00
,
//bDeviceProtocol
64
,
//bMaxPacketSize0
0x01
,
//bNumConfigurations
0
,
};
...
...
@@ -566,7 +568,8 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
/* create a cdc function */
func
=
rt_usbd_function_new
(
device
,
&
dev_desc
,
&
ops
);
rt_usbd_device_set_qualifier
(
device
,
&
dev_qualifier
);
//not support HS
//rt_usbd_device_set_qualifier(device, &dev_qualifier);
/* allocate memory for cdc vcom data */
data
=
(
struct
vcom
*
)
rt_malloc
(
sizeof
(
struct
vcom
));
...
...
components/drivers/usb/usbdevice/class/ecm.c
浏览文件 @
5035662c
...
...
@@ -41,7 +41,7 @@ struct rt_ecm_eth
rt_uint8_t
dev_addr
[
MAX_ADDR_LEN
];
ALIGN
(
4
)
rt_uint8_t
rx_pool
[
64
];
rt_uint8_t
rx_pool
[
512
];
ALIGN
(
4
)
rt_size_t
rx_size
;
ALIGN
(
4
)
...
...
@@ -147,14 +147,14 @@ const static struct ucdc_data_descriptor _data_desc =
USB_DESC_TYPE_ENDPOINT
,
USB_DIR_OUT
|
USB_DYNAMIC
,
USB_EP_ATTR_BULK
,
USB_
CDC_BUFSIZE
,
USB_
DYNAMIC
,
0x00
,
/* endpoint, bulk in */
USB_DESC_LENGTH_ENDPOINT
,
USB_DESC_TYPE_ENDPOINT
,
USB_DYNAMIC
|
USB_DIR_IN
,
USB_EP_ATTR_BULK
,
USB_
CDC_BUFSIZE
,
USB_
DYNAMIC
,
0x00
,
};
...
...
@@ -170,17 +170,20 @@ const static char* _ustring[] =
};
ALIGN
(
4
)
//FS and HS needed
static
struct
usb_qualifier_descriptor
dev_qualifier
=
{
sizeof
(
dev_qualifier
),
USB_DESC_TYPE_DEVICEQUALIFIER
,
0x0200
,
USB_CLASS_CDC
,
0x00
,
64
,
0x01
,
sizeof
(
dev_qualifier
),
//bLength
USB_DESC_TYPE_DEVICEQUALIFIER
,
//bDescriptorType
0x0200
,
//bcdUSB
USB_CLASS_CDC
,
//bDeviceClass
USB_CDC_SUBCLASS_ETH
,
//bDeviceSubClass
USB_CDC_PROTOCOL_NONE
,
//bDeviceProtocol
64
,
//bMaxPacketSize0
0x01
,
//bNumConfigurations
0
,
};
static
rt_err_t
_cdc_send_notifi
(
ufunction_t
func
,
ucdc_notification_code_t
notifi
,
rt_uint16_t
wValue
,
rt_uint16_t
wLength
)
{
static
struct
ucdc_management_element_notifications
_notifi
;
...
...
@@ -472,7 +475,7 @@ static struct ufunction_ops ops =
*
* @return RT_EOK on successful.
*/
static
rt_err_t
_cdc_descriptor_config
(
ucdc_comm_desc_t
comm
,
rt_uint8_t
cintf_nr
,
ucdc_data_desc_t
data
,
rt_uint8_t
dintf_nr
)
static
rt_err_t
_cdc_descriptor_config
(
ucdc_comm_desc_t
comm
,
rt_uint8_t
cintf_nr
,
ucdc_data_desc_t
data
,
rt_uint8_t
dintf_nr
,
rt_uint8_t
device_is_hs
)
{
comm
->
call_mgmt_desc
.
data_interface
=
dintf_nr
;
comm
->
union_desc
.
master_interface
=
cintf_nr
;
...
...
@@ -480,7 +483,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n
#ifdef RT_USB_DEVICE_COMPOSITE
comm
->
iad_desc
.
bFirstInterface
=
cintf_nr
;
#endif
data
->
ep_out_desc
.
wMaxPacketSize
=
device_is_hs
?
512
:
64
;
data
->
ep_in_desc
.
wMaxPacketSize
=
device_is_hs
?
512
:
64
;
return
RT_EOK
;
}
...
...
@@ -532,7 +536,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
(
rt_off_t
)
&
((
ucdc_eth_desc_t
)
0
)
->
intf_desc
);
rt_usbd_altsetting_config_descriptor
(
data_setting
,
&
_data_desc
,
0
);
/* configure the cdc interface descriptor */
_cdc_descriptor_config
(
comm_setting
->
desc
,
intf_comm
->
intf_num
,
data_setting
->
desc
,
intf_data
->
intf_num
);
_cdc_descriptor_config
(
comm_setting
->
desc
,
intf_comm
->
intf_num
,
data_setting
->
desc
,
intf_data
->
intf_num
,
device
->
dcd
->
device_is_hs
);
/* create a command endpoint */
comm_desc
=
(
ucdc_eth_desc_t
)
comm_setting
->
desc
;
...
...
components/drivers/usb/usbdevice/class/hid.c
浏览文件 @
5035662c
...
...
@@ -227,18 +227,21 @@ static struct udevice_descriptor _dev_desc =
USB_DYNAMIC
,
//bNumConfigurations;
};
static
struct
usb_qualifier_descriptor
_dev_qualifier
=
//FS and HS needed
static
struct
usb_qualifier_descriptor
dev_qualifier
=
{
sizeof
(
_dev_qualifier
),
USB_DESC_TYPE_DEVICEQUALIFIER
,
0x0200
,
USB_CLASS_HID
,
0x00
,
64
,
0x01
,
sizeof
(
dev_qualifier
),
//bLength
USB_DESC_TYPE_DEVICEQUALIFIER
,
//bDescriptorType
0x0200
,
//bcdUSB
USB_CLASS_MASS_STORAGE
,
//bDeviceClass
0x06
,
//bDeviceSubClass
0x50
,
//bDeviceProtocol
64
,
//bMaxPacketSize0
0x01
,
//bNumConfigurations
0
,
};
/* hid interface descriptor */
const
static
struct
uhid_comm_descriptor
_hid_comm_desc
=
{
...
...
@@ -631,7 +634,8 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
/* create a cdc function */
func
=
rt_usbd_function_new
(
device
,
&
_dev_desc
,
&
ops
);
rt_usbd_device_set_qualifier
(
device
,
&
_dev_qualifier
);
//not support hs
//rt_usbd_device_set_qualifier(device, &_dev_qualifier);
/* allocate memory for cdc vcom data */
data
=
(
struct
hid_s
*
)
rt_malloc
(
sizeof
(
struct
hid_s
));
...
...
components/drivers/usb/usbdevice/class/mstorage.c
浏览文件 @
5035662c
...
...
@@ -88,8 +88,8 @@ static struct udevice_descriptor dev_desc =
USB_DESC_TYPE_DEVICE
,
//type;
USB_BCD_VERSION
,
//bcdUSB;
USB_CLASS_MASS_STORAGE
,
//bDeviceClass;
0x0
0
,
//bDeviceSubClass;
0x
0
0
,
//bDeviceProtocol;
0x0
6
,
//bDeviceSubClass;
0x
5
0
,
//bDeviceProtocol;
0x40
,
//bMaxPacketSize0;
_VENDOR_ID
,
//idVendor;
_PRODUCT_ID
,
//idProduct;
...
...
@@ -100,15 +100,17 @@ static struct udevice_descriptor dev_desc =
USB_DYNAMIC
,
//bNumConfigurations;
};
//FS and HS needed
static
struct
usb_qualifier_descriptor
dev_qualifier
=
{
sizeof
(
dev_qualifier
),
USB_DESC_TYPE_DEVICEQUALIFIER
,
0x0200
,
USB_CLASS_MASS_STORAGE
,
0x00
,
64
,
0x01
,
sizeof
(
dev_qualifier
),
//bLength
USB_DESC_TYPE_DEVICEQUALIFIER
,
//bDescriptorType
0x0200
,
//bcdUSB
USB_CLASS_MASS_STORAGE
,
//bDeviceClass
0x06
,
//bDeviceSubClass
0x50
,
//bDeviceProtocol
64
,
//bMaxPacketSize0
0x01
,
//bNumConfigurations
0
,
};
...
...
@@ -141,14 +143,14 @@ const static struct umass_descriptor _mass_desc =
USB_DESC_TYPE_ENDPOINT
,
//type;
USB_DYNAMIC
|
USB_DIR_OUT
,
//bEndpointAddress;
USB_EP_ATTR_BULK
,
//bmAttributes;
0x40
,
//wMaxPacketSize;
USB_DYNAMIC
,
//wMaxPacketSize;
0x00
,
//bInterval;
USB_DESC_LENGTH_ENDPOINT
,
//bLength;
USB_DESC_TYPE_ENDPOINT
,
//type;
USB_DYNAMIC
|
USB_DIR_IN
,
//bEndpointAddress;
USB_EP_ATTR_BULK
,
//bmAttributes;
0x40
,
//wMaxPacketSize;
USB_DYNAMIC
,
//wMaxPacketSize;
0x00
,
//bInterval;
};
...
...
@@ -1043,11 +1045,13 @@ static struct ufunction_ops ops =
_function_disable
,
RT_NULL
,
};
static
rt_err_t
_mstorage_descriptor_config
(
umass_desc_t
desc
,
rt_uint8_t
cintf_nr
)
static
rt_err_t
_mstorage_descriptor_config
(
umass_desc_t
desc
,
rt_uint8_t
cintf_nr
,
rt_uint8_t
device_is_hs
)
{
#ifdef RT_USB_DEVICE_COMPOSITE
desc
->
iad_desc
.
bFirstInterface
=
cintf_nr
;
#endif
desc
->
ep_out_desc
.
wMaxPacketSize
=
device_is_hs
?
512
:
64
;
desc
->
ep_in_desc
.
wMaxPacketSize
=
device_is_hs
?
512
:
64
;
return
RT_EOK
;
}
/**
...
...
@@ -1090,7 +1094,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device)
rt_usbd_altsetting_config_descriptor
(
setting
,
&
_mass_desc
,
(
rt_off_t
)
&
((
umass_desc_t
)
0
)
->
intf_desc
);
/* configure the msc interface descriptor */
_mstorage_descriptor_config
(
setting
->
desc
,
intf
->
intf_num
);
_mstorage_descriptor_config
(
setting
->
desc
,
intf
->
intf_num
,
device
->
dcd
->
device_is_hs
);
/* create a bulk out and a bulk in endpoint */
mass_desc
=
(
umass_desc_t
)
setting
->
desc
;
...
...
components/drivers/usb/usbdevice/class/rndis.c
浏览文件 @
5035662c
...
...
@@ -58,9 +58,9 @@ struct rt_rndis_eth
#endif
/* RNDIS_DELAY_LINK_UP */
ALIGN
(
4
)
rt_uint8_t
rx_pool
[
64
];
rt_uint8_t
rx_pool
[
512
];
ALIGN
(
4
)
rt_uint8_t
tx_pool
[
64
];
rt_uint8_t
tx_pool
[
512
];
rt_uint32_t
cmd_pool
[
2
];
ALIGN
(
4
)
...
...
@@ -175,14 +175,14 @@ const static struct ucdc_data_descriptor _data_desc =
USB_DESC_TYPE_ENDPOINT
,
USB_DIR_OUT
|
USB_DYNAMIC
,
USB_EP_ATTR_BULK
,
USB_
CDC_BUFSIZE
,
USB_
DYNAMIC
,
0x00
,
/* endpoint, bulk in */
USB_DESC_LENGTH_ENDPOINT
,
USB_DESC_TYPE_ENDPOINT
,
USB_DYNAMIC
|
USB_DIR_IN
,
USB_EP_ATTR_BULK
,
USB_
CDC_BUFSIZE
,
USB_
DYNAMIC
,
0x00
,
};
...
...
@@ -206,16 +206,17 @@ struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
.
subCompatibleID
=
{
'5'
,
'1'
,
'6'
,
'2'
,
'0'
,
'0'
,
'1'
,
0x00
},
.
reserved2
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
}
};
ALIGN
(
4
)
//FS and HS needed
static
struct
usb_qualifier_descriptor
dev_qualifier
=
{
sizeof
(
dev_qualifier
),
USB_DESC_TYPE_DEVICEQUALIFIER
,
0x0200
,
USB_CLASS_CDC
,
0x00
,
64
,
0x01
,
sizeof
(
dev_qualifier
),
//bLength
USB_DESC_TYPE_DEVICEQUALIFIER
,
//bDescriptorType
0x0200
,
//bcdUSB
USB_CLASS_CDC
,
//bDeviceClass
USB_CDC_SUBCLASS_ACM
,
//bDeviceSubClass
USB_CDC_PROTOCOL_VENDOR
,
//bDeviceProtocol
64
,
//bMaxPacketSize0
0x01
,
//bNumConfigurations
0
,
};
...
...
@@ -401,7 +402,7 @@ static rt_err_t _rndis_query_response(ufunction_t func,rndis_query_msg_t msg)
case
OID_GEN_LINK_SPEED
:
resp
=
_create_resp
(
4
);
if
(
resp
==
RT_NULL
)
break
;
_set_resp
(
resp
,
(
10
UL
*
1000
*
1000
)
/
100
);
_set_resp
(
resp
,
func
->
device
->
dcd
->
device_is_hs
?
(
480UL
*
1000
*
1000
)
:
(
12
UL
*
1000
*
1000
)
/
100
);
break
;
case
OID_GEN_MEDIA_CONNECT_STATUS
:
...
...
@@ -1008,7 +1009,7 @@ static struct ufunction_ops ops =
*
* @return RT_EOK on successful.
*/
static
rt_err_t
_cdc_descriptor_config
(
ucdc_comm_desc_t
comm
,
rt_uint8_t
cintf_nr
,
ucdc_data_desc_t
data
,
rt_uint8_t
dintf_nr
)
static
rt_err_t
_cdc_descriptor_config
(
ucdc_comm_desc_t
comm
,
rt_uint8_t
cintf_nr
,
ucdc_data_desc_t
data
,
rt_uint8_t
dintf_nr
,
rt_uint8_t
device_is_hs
)
{
comm
->
call_mgmt_desc
.
data_interface
=
dintf_nr
;
comm
->
union_desc
.
master_interface
=
cintf_nr
;
...
...
@@ -1016,7 +1017,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n
#ifdef RT_USB_DEVICE_COMPOSITE
comm
->
iad_desc
.
bFirstInterface
=
cintf_nr
;
#endif
data
->
ep_out_desc
.
wMaxPacketSize
=
device_is_hs
?
512
:
64
;
data
->
ep_in_desc
.
wMaxPacketSize
=
device_is_hs
?
512
:
64
;
return
RT_EOK
;
}
...
...
@@ -1237,7 +1239,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
(
rt_off_t
)
&
((
ucdc_comm_desc_t
)
0
)
->
intf_desc
);
rt_usbd_altsetting_config_descriptor
(
data_setting
,
&
_data_desc
,
0
);
/* configure the cdc interface descriptor */
_cdc_descriptor_config
(
comm_setting
->
desc
,
intf_comm
->
intf_num
,
data_setting
->
desc
,
intf_data
->
intf_num
);
_cdc_descriptor_config
(
comm_setting
->
desc
,
intf_comm
->
intf_num
,
data_setting
->
desc
,
intf_data
->
intf_num
,
device
->
dcd
->
device_is_hs
);
/* create a command endpoint */
comm_desc
=
(
ucdc_comm_desc_t
)
comm_setting
->
desc
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录