Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dgr6878
rt-thread
提交
cfc0304b
R
rt-thread
项目概览
dgr6878
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cfc0304b
编写于
11月 23, 2017
作者:
lymzzyh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Compinents][USB]增加USB协议栈对微软OS描述符的支持,修复HID class的IAD接口,增加免驱新class WinUSB
上级
5b8aa350
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
415 addition
and
7 deletion
+415
-7
components/drivers/KConfig
components/drivers/KConfig
+6
-0
components/drivers/include/drivers/usb_common.h
components/drivers/include/drivers/usb_common.h
+32
-0
components/drivers/include/drivers/usb_device.h
components/drivers/include/drivers/usb_device.h
+3
-0
components/drivers/usb/usbdevice/SConscript
components/drivers/usb/usbdevice/SConscript
+3
-0
components/drivers/usb/usbdevice/class/hid.c
components/drivers/usb/usbdevice/class/hid.c
+1
-1
components/drivers/usb/usbdevice/class/winusb.c
components/drivers/usb/usbdevice/class/winusb.c
+234
-0
components/drivers/usb/usbdevice/class/winusb.h
components/drivers/usb/usbdevice/class/winusb.h
+37
-0
components/drivers/usb/usbdevice/core/core.c
components/drivers/usb/usbdevice/core/core.c
+75
-4
components/drivers/usb/usbdevice/core/usbdevice.c
components/drivers/usb/usbdevice/core/usbdevice.c
+24
-2
未找到文件。
components/drivers/KConfig
浏览文件 @
cfc0304b
...
...
@@ -136,6 +136,9 @@ menu "Using USB"
bool "Enable to use device as ecm device"
select RT_USB_DEVICE_ECM
depends on RT_USING_LWIP
config _RT_USB_DEVICE_WINUSB
bool "Enable to use device as winusb device"
select RT_USB_DEVICE_WINUSB
endchoice
if RT_USB_DEVICE_COMPOSITE
config RT_USB_DEVICE_CDC
...
...
@@ -151,6 +154,9 @@ menu "Using USB"
bool "Enable to use device as ecm device"
default n
depends on RT_USING_LWIP
config RT_USB_DEVICE_WINUSB
bool "Enable to use device as winusb device"
default n
endif
if RT_USB_DEVICE_HID
...
...
components/drivers/include/drivers/usb_common.h
浏览文件 @
cfc0304b
...
...
@@ -125,6 +125,10 @@ extern "C" {
#define USB_STRING_SERIAL_INDEX 0x03
#define USB_STRING_CONFIG_INDEX 0x04
#define USB_STRING_INTERFACE_INDEX 0x05
#define USB_STRING_OS_INDEX 0x06
#define USB_STRING_MAX USB_STRING_OS_INDEX
#define USB_STRING_OS "MSFT100A"
#define USB_PID_OUT 0x01
#define USB_PID_ACK 0x02
...
...
@@ -390,6 +394,34 @@ struct usb_qualifier_descriptor
rt_uint8_t
bRESERVED
;
}
__attribute__
((
packed
));
struct
usb_os_header_comp_id_descriptor
{
rt_uint32_t
dwLength
;
rt_uint16_t
bcdVersion
;
rt_uint16_t
wIndex
;
rt_uint8_t
bCount
;
rt_uint8_t
reserved
[
7
];
};
typedef
struct
usb_os_header_comp_id_descriptor
*
usb_os_header_desc_t
;
struct
usb_os_function_comp_id_descriptor
{
rt_list_t
list
;
rt_uint8_t
bFirstInterfaceNumber
;
rt_uint8_t
reserved1
;
rt_uint8_t
compatibleID
[
8
];
rt_uint8_t
subCompatibleID
[
8
];
rt_uint8_t
reserved2
[
6
];
};
typedef
struct
usb_os_function_comp_id_descriptor
*
usb_os_func_comp_id_desc_t
;
struct
usb_os_comp_id_descriptor
{
struct
usb_os_header_comp_id_descriptor
head_desc
;
rt_list_t
func_desc
;
};
typedef
struct
usb_os_comp_id_descriptor
*
usb_os_comp_id_desc_t
;
#ifndef HID_SUB_DESCRIPTOR_MAX
#define HID_SUB_DESCRIPTOR_MAX 1
#endif
...
...
components/drivers/include/drivers/usb_device.h
浏览文件 @
cfc0304b
...
...
@@ -200,6 +200,7 @@ struct udevice
struct
udevice_descriptor
dev_desc
;
struct
usb_qualifier_descriptor
*
dev_qualifier
;
usb_os_comp_id_desc_t
os_comp_id_desc
;
const
char
**
str
;
udevice_state_t
state
;
...
...
@@ -261,11 +262,13 @@ rt_err_t rt_usbd_device_set_controller(udevice_t device, udcd_t dcd);
rt_err_t
rt_usbd_device_set_descriptor
(
udevice_t
device
,
udev_desc_t
dev_desc
);
rt_err_t
rt_usbd_device_set_string
(
udevice_t
device
,
const
char
**
ustring
);
rt_err_t
rt_usbd_device_set_qualifier
(
udevice_t
device
,
struct
usb_qualifier_descriptor
*
qualifier
);
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_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
);
rt_err_t
rt_usbd_os_comp_id_desc_add_os_func_comp_id_desc
(
usb_os_comp_id_desc_t
os_comp_id_desc
,
usb_os_func_comp_id_desc_t
os_func_comp_id_desc
);
rt_err_t
rt_usbd_altsetting_config_descriptor
(
ualtsetting_t
setting
,
const
void
*
desc
,
rt_off_t
intf_pos
);
rt_err_t
rt_usbd_set_config
(
udevice_t
device
,
rt_uint8_t
value
);
rt_err_t
rt_usbd_set_altsetting
(
uintf_t
intf
,
rt_uint8_t
value
);
...
...
components/drivers/usb/usbdevice/SConscript
浏览文件 @
cfc0304b
...
...
@@ -19,6 +19,9 @@ if GetDepend('RT_USB_DEVICE_MSTORAGE'):
if
GetDepend
(
'RT_USB_DEVICE_ECM'
):
src
+=
Glob
(
'class/ecm.c'
)
if
GetDepend
(
'RT_USB_DEVICE_WINUSB'
):
src
+=
Glob
(
'class/winusb.c'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'rt_usbd'
,
src
,
depend
=
[
'RT_USING_USB_DEVICE'
],
CPPPATH
=
CPPPATH
)
...
...
components/drivers/usb/usbdevice/class/hid.c
浏览文件 @
cfc0304b
...
...
@@ -247,7 +247,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
USB_DESC_LENGTH_IAD
,
USB_DESC_TYPE_IAD
,
USB_DYNAMIC
,
0x0
2
,
0x0
1
,
0x03
,
/* bInterfaceClass: HID */
#if defined(RT_USB_DEVICE_HID_KEYBOARD)||defined(RT_USB_DEVICE_HID_MOUSE)
USB_HID_SUBCLASS_BOOT
,
/* bInterfaceSubClass : 1=BOOT, 0=no boot */
...
...
components/drivers/usb/usbdevice/class/winusb.c
0 → 100644
浏览文件 @
cfc0304b
/*
* File : winusb.c
* COPYRIGHT (C) 2008 - 2016, RT-Thread Development Team
*
* Change Logs:
* Date Author Notes
* 2017-11-16 ZYH first version
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtservice.h>
#include <rtdevice.h>
#include <drivers/usb_device.h>
#include "winusb.h"
struct
winusb_device
{
uep_t
ep_out
;
uep_t
ep_in
;
};
typedef
struct
winusb_device
*
winusb_device_t
;
static
struct
udevice_descriptor
dev_desc
=
{
USB_DESC_LENGTH_DEVICE
,
//bLength;
USB_DESC_TYPE_DEVICE
,
//type;
USB_BCD_VERSION
,
//bcdUSB;
0x00
,
//bDeviceClass;
0x00
,
//bDeviceSubClass;
0x00
,
//bDeviceProtocol;
0x40
,
//bMaxPacketSize0;
_VENDOR_ID
,
//idVendor;
_PRODUCT_ID
,
//idProduct;
USB_BCD_DEVICE
,
//bcdDevice;
USB_STRING_MANU_INDEX
,
//iManufacturer;
USB_STRING_PRODUCT_INDEX
,
//iProduct;
USB_STRING_SERIAL_INDEX
,
//iSerialNumber;
USB_DYNAMIC
,
//bNumConfigurations;
};
//FS and HS needed
static
struct
usb_qualifier_descriptor
dev_qualifier
=
{
sizeof
(
dev_qualifier
),
USB_DESC_TYPE_DEVICEQUALIFIER
,
0x0200
,
0x00
,
0x00
,
64
,
0x01
,
0
,
};
struct
winusb_descriptor
_winusb_desc
=
{
#ifdef RT_USB_DEVICE_COMPOSITE
/* Interface Association Descriptor */
USB_DESC_LENGTH_IAD
,
USB_DESC_TYPE_IAD
,
USB_DYNAMIC
,
0x01
,
0xFF
,
0x00
,
0x00
,
0x00
,
#endif
/*interface descriptor*/
USB_DESC_LENGTH_INTERFACE
,
//bLength;
USB_DESC_TYPE_INTERFACE
,
//type;
USB_DYNAMIC
,
//bInterfaceNumber;
0x00
,
//bAlternateSetting;
0x02
,
//bNumEndpoints
0xFF
,
//bInterfaceClass;
0x00
,
//bInterfaceSubClass;
0x00
,
//bInterfaceProtocol;
0x00
,
//iInterface;
/*endpoint descriptor*/
USB_DESC_LENGTH_ENDPOINT
,
USB_DESC_TYPE_ENDPOINT
,
USB_DYNAMIC
|
USB_DIR_OUT
,
USB_EP_ATTR_BULK
,
0x40
,
0x00
,
/*endpoint descriptor*/
USB_DESC_LENGTH_ENDPOINT
,
USB_DESC_TYPE_ENDPOINT
,
USB_DYNAMIC
|
USB_DIR_IN
,
USB_EP_ATTR_BULK
,
0x40
,
0x00
,
};
const
static
char
*
_ustring
[]
=
{
"Language"
,
"RT-Thread Team."
,
"RTT Win USB"
,
"32021919830108"
,
"Configuration"
,
"Interface"
,
USB_STRING_OS
//must be
};
struct
usb_os_function_comp_id_descriptor
winusb_func_comp_id_desc
=
{
.
bFirstInterfaceNumber
=
USB_DYNAMIC
,
.
reserved1
=
0x01
,
.
compatibleID
=
{
'W'
,
'I'
,
'N'
,
'U'
,
'S'
,
'B'
,
0x00
,
0x00
},
.
subCompatibleID
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
.
reserved2
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
}
};
static
rt_err_t
_ep_out_handler
(
ufunction_t
func
,
rt_size_t
size
)
{
struct
winusb_device
*
data
=
(
struct
winusb_device
*
)
func
->
user_data
;
rt_kprintf
(
"recev:%s"
,
data
->
ep_out
->
buffer
);
data
->
ep_in
->
request
.
buffer
=
data
->
ep_out
->
buffer
;
data
->
ep_in
->
request
.
size
=
EP_MAXPACKET
(
data
->
ep_out
);
data
->
ep_in
->
request
.
req_type
=
UIO_REQUEST_WRITE
;
rt_usbd_io_request
(
func
->
device
,
data
->
ep_in
,
&
data
->
ep_in
->
request
);
return
RT_EOK
;
}
static
rt_err_t
_ep_in_handler
(
ufunction_t
func
,
rt_size_t
size
)
{
return
RT_EOK
;
}
static
rt_err_t
_interface_handler
(
ufunction_t
func
,
ureq_t
setup
)
{
return
RT_EOK
;
}
static
rt_err_t
_function_enable
(
ufunction_t
func
)
{
RT_ASSERT
(
func
!=
RT_NULL
);
struct
winusb_device
*
data
=
(
struct
winusb_device
*
)
func
->
user_data
;
data
->
ep_out
->
buffer
=
rt_malloc
(
0x40
);
data
->
ep_out
->
request
.
buffer
=
data
->
ep_out
->
buffer
;
data
->
ep_out
->
request
.
size
=
EP_MAXPACKET
(
data
->
ep_out
);
data
->
ep_out
->
request
.
req_type
=
UIO_REQUEST_READ_BEST
;
rt_usbd_io_request
(
func
->
device
,
data
->
ep_out
,
&
data
->
ep_out
->
request
);
return
RT_EOK
;
}
static
rt_err_t
_function_disable
(
ufunction_t
func
)
{
RT_ASSERT
(
func
!=
RT_NULL
);
struct
winusb_device
*
data
=
(
struct
winusb_device
*
)
func
->
user_data
;
if
(
data
->
ep_out
->
buffer
!=
RT_NULL
)
{
rt_free
(
data
->
ep_out
->
buffer
);
data
->
ep_out
->
buffer
=
RT_NULL
;
}
return
RT_EOK
;
}
static
struct
ufunction_ops
ops
=
{
_function_enable
,
_function_disable
,
RT_NULL
,
};
static
rt_err_t
_winusb_descriptor_config
(
winusb_desc_t
winusb
,
rt_uint8_t
cintf_nr
)
{
#ifdef RT_USB_DEVICE_COMPOSITE
winusb
->
iad_desc
.
bFirstInterface
=
cintf_nr
;
#endif
winusb_func_comp_id_desc
.
bFirstInterfaceNumber
=
cintf_nr
;
return
RT_EOK
;
}
static
rt_err_t
rt_usb_winusb_init
(
ufunction_t
func
)
{
return
RT_EOK
;
}
ufunction_t
rt_usbd_function_winusb_create
(
udevice_t
device
)
{
ufunction_t
func
;
winusb_device_t
winusb_device
;
uintf_t
winusb_intf
;
ualtsetting_t
winusb_setting
;
winusb_desc_t
winusb_desc
;
/* parameter check */
RT_ASSERT
(
device
!=
RT_NULL
);
/* set usb device string description */
rt_usbd_device_set_string
(
device
,
_ustring
);
/* create a cdc function */
func
=
rt_usbd_function_new
(
device
,
&
dev_desc
,
&
ops
);
rt_usbd_device_set_qualifier
(
device
,
&
dev_qualifier
);
/* allocate memory for cdc vcom data */
winusb_device
=
(
winusb_device_t
)
rt_malloc
(
sizeof
(
struct
winusb_device
));
rt_memset
((
void
*
)
winusb_device
,
0
,
sizeof
(
struct
winusb_device
));
func
->
user_data
=
(
void
*
)
winusb_device
;
/* create an interface object */
winusb_intf
=
rt_usbd_interface_new
(
device
,
_interface_handler
);
/* create an alternate setting object */
winusb_setting
=
rt_usbd_altsetting_new
(
sizeof
(
struct
winusb_descriptor
));
/* config desc in alternate setting */
rt_usbd_altsetting_config_descriptor
(
winusb_setting
,
&
_winusb_desc
,
(
rt_off_t
)
&
((
winusb_desc_t
)
0
)
->
intf_desc
);
/* configure the hid interface descriptor */
_winusb_descriptor_config
(
winusb_setting
->
desc
,
winusb_intf
->
intf_num
);
/* create endpoint */
winusb_desc
=
(
winusb_desc_t
)
winusb_setting
->
desc
;
winusb_device
->
ep_out
=
rt_usbd_endpoint_new
(
&
winusb_desc
->
ep_out_desc
,
_ep_out_handler
);
winusb_device
->
ep_in
=
rt_usbd_endpoint_new
(
&
winusb_desc
->
ep_in_desc
,
_ep_in_handler
);
/* add the int out and int in endpoint to the alternate setting */
rt_usbd_altsetting_add_endpoint
(
winusb_setting
,
winusb_device
->
ep_out
);
rt_usbd_altsetting_add_endpoint
(
winusb_setting
,
winusb_device
->
ep_in
);
/* add the alternate setting to the interface, then set default setting */
rt_usbd_interface_add_altsetting
(
winusb_intf
,
winusb_setting
);
rt_usbd_set_altsetting
(
winusb_intf
,
0
);
/* add the interface to the mass storage function */
rt_usbd_function_add_interface
(
func
,
winusb_intf
);
rt_usbd_os_comp_id_desc_add_os_func_comp_id_desc
(
device
->
os_comp_id_desc
,
&
winusb_func_comp_id_desc
);
/* initilize hid */
rt_usb_winusb_init
(
func
);
return
func
;
}
components/drivers/usb/usbdevice/class/winusb.h
0 → 100644
浏览文件 @
cfc0304b
/*
* File : winusb.h
* COPYRIGHT (C) 2008 - 2016, RT-Thread Development Team
*
* Change Logs:
* Date Author Notes
* 2017-11-16 ZYH first version
*/
#ifndef __WINUSB_H__
#define __WINUSB_H__
#include <rtthread.h>
struct
winusb_descriptor
{
#ifdef RT_USB_DEVICE_COMPOSITE
struct
uiad_descriptor
iad_desc
;
#endif
struct
uinterface_descriptor
intf_desc
;
struct
uendpoint_descriptor
ep_out_desc
;
struct
uendpoint_descriptor
ep_in_desc
;
};
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
浏览文件 @
cfc0304b
...
...
@@ -118,13 +118,18 @@ static rt_err_t _get_string_descriptor(struct udevice* device, ureq_t setup)
str_desc
.
type
=
USB_DESC_TYPE_STRING
;
index
=
setup
->
wValue
&
0xFF
;
if
(
index
>
USB_STRING_INTERFACE_INDEX
)
if
(
index
==
0xEE
)
{
index
=
USB_STRING_OS_INDEX
;
}
if
(
index
>
USB_STRING_MAX
)
{
rt_kprintf
(
"unknown string index
\n
"
);
rt_usbd_ep0_set_stall
(
device
);
return
-
RT_ERROR
;
}
if
(
index
==
0
)
else
if
(
index
==
USB_STRING_LANGID_INDEX
)
{
str_desc
.
bLength
=
4
;
str_desc
.
String
[
0
]
=
0x09
;
...
...
@@ -659,7 +664,52 @@ static rt_err_t _function_request(udevice_t device, ureq_t setup)
return
RT_EOK
;
}
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
;
switch
(
setup
->
bRequest
)
{
case
'A'
:
switch
(
setup
->
wIndex
)
{
case
0x04
:
if
(
rt_list_len
(
&
device
->
os_comp_id_desc
->
func_desc
)
==
0
)
{
rt_usbd_ep0_set_stall
(
device
);
return
RT_EOK
;
}
if
(
usb_comp_id_desc
==
RT_NULL
)
{
rt_uint8_t
*
pusb_comp_id_desc
;
rt_list_t
*
p
;
usb_comp_id_desc_size
=
sizeof
(
struct
usb_os_header_comp_id_descriptor
)
+
(
sizeof
(
struct
usb_os_function_comp_id_descriptor
)
-
sizeof
(
rt_list_t
))
*
rt_list_len
(
&
device
->
os_comp_id_desc
->
func_desc
);
usb_comp_id_desc
=
(
rt_uint8_t
*
)
rt_malloc
(
usb_comp_id_desc_size
);
RT_ASSERT
(
usb_comp_id_desc
!=
RT_NULL
);
device
->
os_comp_id_desc
->
head_desc
.
dwLength
=
usb_comp_id_desc_size
;
pusb_comp_id_desc
=
usb_comp_id_desc
;
rt_memcpy
((
void
*
)
pusb_comp_id_desc
,(
void
*
)
&
device
->
os_comp_id_desc
->
head_desc
,
sizeof
(
struct
usb_os_header_comp_id_descriptor
));
pusb_comp_id_desc
+=
sizeof
(
struct
usb_os_header_comp_id_descriptor
);
for
(
p
=
device
->
os_comp_id_desc
->
func_desc
.
next
;
p
!=
&
device
->
os_comp_id_desc
->
func_desc
;
p
=
p
->
next
)
{
func_comp_id_desc
=
rt_list_entry
(
p
,
struct
usb_os_function_comp_id_descriptor
,
list
);
rt_memcpy
(
pusb_comp_id_desc
,(
void
*
)
&
func_comp_id_desc
->
bFirstInterfaceNumber
,
sizeof
(
struct
usb_os_function_comp_id_descriptor
)
-
sizeof
(
rt_list_t
));
pusb_comp_id_desc
+=
sizeof
(
struct
usb_os_function_comp_id_descriptor
)
-
sizeof
(
rt_list_t
);
}
}
rt_usbd_ep0_write
(
device
,
(
void
*
)
usb_comp_id_desc
,
setup
->
wLength
);
break
;
}
break
;
}
return
RT_EOK
;
}
static
rt_err_t
_dump_setup_packet
(
ureq_t
setup
)
{
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"[
\n
"
));
...
...
@@ -699,7 +749,7 @@ static rt_err_t _setup_request(udevice_t device, ureq_t setup)
_function_request
(
device
,
setup
);
break
;
case
USB_REQ_TYPE_VENDOR
:
rt_kprintf
(
"vendor type request
\n
"
);
_vendor_request
(
device
,
setup
);
break
;
default:
rt_kprintf
(
"unknown setup request type
\n
"
);
...
...
@@ -964,6 +1014,18 @@ rt_err_t rt_usbd_device_set_string(udevice_t device, const char** ustring)
return
RT_EOK
;
}
rt_err_t
rt_usbd_device_set_os_comp_id_desc
(
udevice_t
device
,
usb_os_comp_id_desc_t
os_comp_id_desc
)
{
/* parameter check */
RT_ASSERT
(
device
!=
RT_NULL
);
RT_ASSERT
(
os_comp_id_desc
!=
RT_NULL
);
/* set string descriptor array to the device object */
device
->
os_comp_id_desc
=
os_comp_id_desc
;
rt_list_init
(
&
device
->
os_comp_id_desc
->
func_desc
);
return
RT_EOK
;
}
rt_err_t
rt_usbd_device_set_qualifier
(
udevice_t
device
,
struct
usb_qualifier_descriptor
*
qualifier
)
{
/* parameter check */
...
...
@@ -1548,6 +1610,15 @@ rt_err_t rt_usbd_altsetting_add_endpoint(ualtsetting_t setting, uep_t ep)
return
RT_EOK
;
}
rt_err_t
rt_usbd_os_comp_id_desc_add_os_func_comp_id_desc
(
usb_os_comp_id_desc_t
os_comp_id_desc
,
usb_os_func_comp_id_desc_t
os_func_comp_id_desc
)
{
RT_ASSERT
(
os_comp_id_desc
!=
RT_NULL
);
RT_ASSERT
(
os_func_comp_id_desc
!=
RT_NULL
);
rt_list_insert_before
(
&
os_comp_id_desc
->
func_desc
,
&
os_func_comp_id_desc
->
list
);
os_comp_id_desc
->
head_desc
.
bCount
++
;
return
RT_EOK
;
}
/**
* This function will set an alternate setting for an interface.
*
...
...
components/drivers/usb/usbdevice/core/usbdevice.c
浏览文件 @
cfc0304b
...
...
@@ -39,10 +39,9 @@ const static char* ustring[] =
"320219198301"
,
"Configuration"
,
"Interface"
,
USB_STRING_OS
};
#endif
#ifdef RT_USB_DEVICE_COMPOSITE
static
struct
udevice_descriptor
compsit_desc
=
{
USB_DESC_LENGTH_DEVICE
,
//bLength;
...
...
@@ -62,6 +61,16 @@ static struct udevice_descriptor compsit_desc =
};
#endif
struct
usb_os_comp_id_descriptor
usb_comp_id_desc
=
{
//head section
USB_DYNAMIC
,
0x0100
,
0x04
,
USB_DYNAMIC
,
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
};
rt_err_t
rt_usb_device_init
(
void
)
{
rt_device_t
udc
;
...
...
@@ -88,6 +97,8 @@ 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
);
#ifdef RT_USB_DEVICE_MSTORAGE
{
extern
ufunction_t
rt_usbd_function_mstorage_create
(
udevice_t
device
);
...
...
@@ -142,6 +153,17 @@ rt_err_t rt_usb_device_init(void)
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录