Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
d40d5355
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看板
提交
d40d5355
编写于
11月 28, 2017
作者:
lymzzyh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Components][Drivers][USB]WinUSB And Core update
协议栈增加允许class在windows环境下枚举时向系统注册附加属性。并在winusb class中提供范例(注册GUID信息)
上级
3044461b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
119 addition
and
16 deletion
+119
-16
components/drivers/include/drivers/usb_common.h
components/drivers/include/drivers/usb_common.h
+47
-0
components/drivers/include/drivers/usb_device.h
components/drivers/include/drivers/usb_device.h
+45
-1
components/drivers/usb/usbdevice/class/winusb.c
components/drivers/usb/usbdevice/class/winusb.c
+18
-1
components/drivers/usb/usbdevice/class/winusb.h
components/drivers/usb/usbdevice/class/winusb.h
+0
-14
components/drivers/usb/usbdevice/core/core.c
components/drivers/usb/usbdevice/core/core.c
+9
-0
未找到文件。
components/drivers/include/drivers/usb_common.h
浏览文件 @
d40d5355
...
...
@@ -422,6 +422,53 @@ struct usb_os_comp_id_descriptor
};
typedef
struct
usb_os_comp_id_descriptor
*
usb_os_comp_id_desc_t
;
struct
usb_os_property_header
{
rt_uint32_t
dwLength
;
rt_uint16_t
bcdVersion
;
rt_uint16_t
wIndex
;
rt_uint16_t
wCount
;
};
typedef
struct
usb_os_property_header
*
usb_os_property_header_t
;
struct
usb_os_proerty
{
rt_uint32_t
dwSize
;
rt_uint32_t
dwPropertyDataType
;
rt_uint16_t
wPropertyNameLength
;
const
char
*
bPropertyName
;
rt_uint32_t
dwPropertyDataLength
;
const
char
*
bPropertyData
;
};
typedef
struct
usb_os_proerty
*
usb_os_proerty_t
;
// Value Description
// 1 A NULL-terminated Unicode String (REG_SZ)
// 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ)
// 3 Free-form binary (REG_BINARY)
// 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN)
// 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN)
// 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK)
// 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ)
#define USB_OS_PROERTY_TYPE_REG_SZ 0x01UL
#define USB_OS_PROERTY_TYPE_REG_EXPAND_SZ 0x02UL
#define USB_OS_PROERTY_TYPE_REG_BINARY 0x03UL
#define USB_OS_PROERTY_TYPE_REG_DWORD_LITTLE_ENDIAN 0x04UL
#define USB_OS_PROERTY_TYPE_REG_DWORD_BIG_ENDIAN 0x05UL
#define USB_OS_PROERTY_TYPE_REG_LINK 0x06UL
#define USB_OS_PROERTY_TYPE_REG_MULTI_SZ 0x07UL
#define USB_OS_PROERTY_DESC(PropertyDataType,PropertyName,PropertyData) \
{\
.dwSize = sizeof(struct usb_os_proerty)-sizeof(const char *)*2\
+sizeof(PropertyName)*2+sizeof(PropertyData)*2,\
.dwPropertyDataType = PropertyDataType,\
.wPropertyNameLength = sizeof(PropertyName)*2,\
.bPropertyName = PropertyName,\
.dwPropertyDataLength = sizeof(PropertyData)*2,\
.bPropertyData = PropertyData\
}
#ifndef HID_SUB_DESCRIPTOR_MAX
#define HID_SUB_DESCRIPTOR_MAX 1
#endif
...
...
components/drivers/include/drivers/usb_device.h
浏览文件 @
d40d5355
...
...
@@ -410,5 +410,49 @@ rt_inline rt_err_t dcd_ep_clear_stall(udcd_t dcd, rt_uint8_t address)
return
dcd
->
ops
->
ep_clear_stall
(
address
);
}
rt_inline
void
usbd_os_proerty_descriptor_send
(
ufunction_t
func
,
ureq_t
setup
,
usb_os_proerty_t
usb_os_proerty
,
rt_uint8_t
number_of_proerty
)
{
struct
usb_os_property_header
header
;
static
rt_uint8_t
*
data
;
rt_uint8_t
*
pdata
;
rt_uint8_t
index
,
i
;
if
(
data
==
RT_NULL
)
{
header
.
dwLength
=
sizeof
(
struct
usb_os_property_header
);
header
.
bcdVersion
=
0x0100
;
header
.
wIndex
=
0x05
;
header
.
wCount
=
number_of_proerty
;
for
(
index
=
0
;
index
<
number_of_proerty
;
index
++
)
{
header
.
dwLength
+=
usb_os_proerty
[
index
].
dwSize
;
}
data
=
(
rt_uint8_t
*
)
rt_malloc
(
header
.
dwLength
);
RT_ASSERT
(
data
!=
RT_NULL
);
pdata
=
data
;
rt_memcpy
((
void
*
)
pdata
,(
void
*
)
&
header
,
sizeof
(
struct
usb_os_property_header
));
pdata
+=
sizeof
(
struct
usb_os_property_header
);
for
(
index
=
0
;
index
<
number_of_proerty
;
index
++
)
{
rt_memcpy
((
void
*
)
pdata
,(
void
*
)
&
usb_os_proerty
[
index
],
10
);
pdata
+=
10
;
for
(
i
=
0
;
i
<
usb_os_proerty
[
index
].
wPropertyNameLength
;
i
++
)
{
*
pdata
=
usb_os_proerty
[
index
].
bPropertyName
[
i
];
pdata
++
;
*
pdata
=
0
;
pdata
++
;
}
*
((
rt_uint32_t
*
)
pdata
)
=
usb_os_proerty
[
index
].
dwPropertyDataLength
;
pdata
+=
4
;
for
(
i
=
0
;
i
<
usb_os_proerty
[
index
].
dwPropertyDataLength
;
i
++
)
{
*
pdata
=
usb_os_proerty
[
index
].
bPropertyData
[
i
];
pdata
++
;
*
pdata
=
0
;
pdata
++
;
}
}
}
rt_usbd_ep0_write
(
func
->
device
,
data
,
setup
->
wLength
);
}
#endif
components/drivers/usb/usbdevice/class/winusb.c
浏览文件 @
d40d5355
...
...
@@ -25,7 +25,7 @@ static struct udevice_descriptor dev_desc =
USB_DESC_LENGTH_DEVICE
,
//bLength;
USB_DESC_TYPE_DEVICE
,
//type;
USB_BCD_VERSION
,
//bcdUSB;
0x00
,
//bDeviceClass;
0x00
,
//bDeviceClass;
0x00
,
//bDeviceSubClass;
0x00
,
//bDeviceProtocol;
0x40
,
//bMaxPacketSize0;
...
...
@@ -100,6 +100,11 @@ const static char* _ustring[] =
"Interface"
,
USB_STRING_OS
//must be
};
struct
usb_os_proerty
winusb_proerty
[]
=
{
USB_OS_PROERTY_DESC
(
USB_OS_PROERTY_TYPE_REG_SZ
,
"DeviceInterfaceGUID"
,
"{6860DC3C-C05F-4807-8807-1CA861CC1D66}"
),
};
struct
usb_os_function_comp_id_descriptor
winusb_func_comp_id_desc
=
{
.
bFirstInterfaceNumber
=
USB_DYNAMIC
,
...
...
@@ -127,6 +132,18 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
}
static
rt_err_t
_interface_handler
(
ufunction_t
func
,
ureq_t
setup
)
{
switch
(
setup
->
bRequest
)
{
case
'A'
:
switch
(
setup
->
wIndex
)
{
case
0x05
:
usbd_os_proerty_descriptor_send
(
func
,
setup
,
winusb_proerty
,
sizeof
(
winusb_proerty
)
/
sizeof
(
winusb_proerty
[
0
]));
break
;
}
break
;
}
return
RT_EOK
;
}
static
rt_err_t
_function_enable
(
ufunction_t
func
)
...
...
components/drivers/usb/usbdevice/class/winusb.h
浏览文件 @
d40d5355
...
...
@@ -20,18 +20,4 @@ struct winusb_descriptor
};
typedef
struct
winusb_descriptor
*
winusb_desc_t
;
struct
winusb_os_header_properties_descriptor
{
rt_uint32_t
dwLength
;
rt_uint16_t
bcdVersion
;
rt_uint16_t
wIndex
;
rt_uint16_t
bCount
;
};
typedef
struct
winusb_os_header_properties_descriptor
*
winusb_os_header_prop_desc_t
;
#endif
components/drivers/usb/usbdevice/core/core.c
浏览文件 @
d40d5355
...
...
@@ -669,6 +669,8 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup)
static
rt_uint8_t
*
usb_comp_id_desc
=
RT_NULL
;
static
rt_uint32_t
usb_comp_id_desc_size
=
0
;
usb_os_func_comp_id_desc_t
func_comp_id_desc
;
uintf_t
intf
;
ufunction_t
func
;
switch
(
setup
->
bRequest
)
{
case
'A'
:
...
...
@@ -704,6 +706,13 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup)
}
rt_usbd_ep0_write
(
device
,
(
void
*
)
usb_comp_id_desc
,
setup
->
wLength
);
break
;
case
0x05
:
intf
=
rt_usbd_find_interface
(
device
,
setup
->
wValue
&
0xFF
,
&
func
);
if
(
intf
!=
RT_NULL
)
{
intf
->
handler
(
func
,
setup
);
}
break
;
}
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录