Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
fbaa8693
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看板
未验证
提交
fbaa8693
编写于
10月 23, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
10月 23, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1922 from liruncong/usb
解决usb相关问题
上级
bf537189
d3764db8
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
71 addition
and
43 deletion
+71
-43
components/drivers/include/drivers/usb_common.h
components/drivers/include/drivers/usb_common.h
+13
-0
components/drivers/include/drivers/usb_device.h
components/drivers/include/drivers/usb_device.h
+9
-0
components/drivers/usb/usbhost/class/adk.c
components/drivers/usb/usbhost/class/adk.c
+3
-3
components/drivers/usb/usbhost/class/hid.c
components/drivers/usb/usbhost/class/hid.c
+7
-7
components/drivers/usb/usbhost/class/mass.c
components/drivers/usb/usbhost/class/mass.c
+6
-6
components/drivers/usb/usbhost/class/udisk.c
components/drivers/usb/usbhost/class/udisk.c
+5
-5
components/drivers/usb/usbhost/core/core.c
components/drivers/usb/usbhost/core/core.c
+16
-14
components/drivers/usb/usbhost/core/hub.c
components/drivers/usb/usbhost/core/hub.c
+12
-8
未找到文件。
components/drivers/include/drivers/usb_common.h
浏览文件 @
fbaa8693
...
...
@@ -216,6 +216,19 @@ extern "C" {
#define HID_REPORT_ID_GENERAL 5
#define HID_REPORT_ID_MOUSE 6
/*
* Time of usb timeout
*/
#ifndef USB_TIMEOUT_BASIC
#define USB_TIMEOUT_BASIC (RT_TICK_PER_SECOND)
/* 1s */
#endif
#ifndef USB_TIMEOUT_LONG
#define USB_TIMEOUT_LONG (RT_TICK_PER_SECOND * 5)
/* 5s */
#endif
#ifndf USB_DEBOUNCE_TIME
#define USB_DEBOUNCE_TIME (RT_TICK_PER_SECOND / 5)
/* 0.2s */
#endif
#define uswap_32(x) \
((((x) & 0xff000000) >> 24) | \
(((x) & 0x00ff0000) >> 8) | \
...
...
components/drivers/include/drivers/usb_device.h
浏览文件 @
fbaa8693
...
...
@@ -17,6 +17,10 @@
#include <rtthread.h>
#include "drivers/usb_common.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/* Vendor ID */
#ifdef USB_VENDOR_ID
#define _VENDOR_ID USB_VENDOR_ID
...
...
@@ -453,4 +457,9 @@ rt_inline void usbd_os_proerty_descriptor_send(ufunction_t func, ureq_t setup, u
}
rt_usbd_ep0_write
(
func
->
device
,
data
,
setup
->
wLength
);
}
#ifdef __cplusplus
}
#endif
#endif
components/drivers/usb/usbhost/class/adk.c
浏览文件 @
fbaa8693
...
...
@@ -55,7 +55,7 @@ static rt_err_t rt_usbh_adk_get_protocol(struct uintf* intf, rt_uint16_t *protoc
{
struct
urequest
setup
;
uinst_t
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
@@ -89,7 +89,7 @@ static rt_err_t rt_usbh_adk_send_string(struct uintf* intf, rt_uint16_t index,
{
struct
urequest
setup
;
uinst_t
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
@@ -122,7 +122,7 @@ static rt_err_t rt_usbh_adk_start(struct uintf* intf)
{
struct
urequest
setup
;
uinst_t
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
components/drivers/usb/usbhost/class/hid.c
浏览文件 @
fbaa8693
...
...
@@ -30,7 +30,7 @@ rt_err_t rt_usbh_hid_set_idle(struct uintf* intf, int duration, int report_id)
{
struct
urequest
setup
;
struct
uinstance
*
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
@@ -64,7 +64,7 @@ rt_err_t rt_usbh_hid_get_report(struct uintf* intf, rt_uint8_t type,
{
struct
urequest
setup
;
struct
uinstance
*
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
@@ -97,7 +97,7 @@ rt_err_t rt_usbh_hid_set_report(struct uintf* intf, rt_uint8_t *buffer, rt_size_
{
struct
urequest
setup
;
struct
uinstance
*
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
@@ -129,7 +129,7 @@ rt_err_t rt_usbh_hid_set_protocal(struct uintf* intf, int protocol)
{
struct
urequest
setup
;
struct
uinstance
*
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
@@ -164,7 +164,7 @@ rt_err_t rt_usbh_hid_get_report_descriptor(struct uintf* intf,
{
struct
urequest
setup
;
struct
uinstance
*
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
@@ -214,7 +214,7 @@ static void rt_usbh_hid_callback(void* context)
{
upipe_t
pipe
;
struct
uhid
*
hid
;
int
timeout
=
300
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* parameter check */
RT_ASSERT
(
context
!=
RT_NULL
);
...
...
@@ -269,7 +269,7 @@ static rt_err_t rt_usbh_hid_enable(void* arg)
uprotocal_t
protocal
;
struct
uhid
*
hid
;
struct
uintf
*
intf
=
(
struct
uintf
*
)
arg
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
upipe_t
pipe
;
/* parameter check */
...
...
components/drivers/usb/usbhost/class/mass.c
浏览文件 @
fbaa8693
...
...
@@ -190,7 +190,7 @@ rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun)
{
struct
uinstance
*
device
;
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
if
(
intf
==
RT_NULL
)
{
...
...
@@ -240,7 +240,7 @@ rt_err_t rt_usbh_storage_reset(struct uhintf* intf)
{
struct
urequest
setup
;
struct
uinstance
*
device
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
if
(
intf
==
RT_NULL
)
...
...
@@ -377,7 +377,7 @@ rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
rt_err_t
rt_usbh_storage_request_sense
(
struct
uhintf
*
intf
,
rt_uint8_t
*
buffer
)
{
struct
ustorage_cbw
cmd
;
int
timeout
=
200
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* parameter check */
if
(
intf
==
RT_NULL
)
...
...
@@ -413,7 +413,7 @@ rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer)
rt_err_t
rt_usbh_storage_test_unit_ready
(
struct
uhintf
*
intf
)
{
struct
ustorage_cbw
cmd
;
int
timeout
=
200
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* parameter check */
if
(
intf
==
RT_NULL
)
...
...
@@ -449,7 +449,7 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf)
rt_err_t
rt_usbh_storage_inquiry
(
struct
uhintf
*
intf
,
rt_uint8_t
*
buffer
)
{
struct
ustorage_cbw
cmd
;
int
timeout
=
200
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* parameter check */
if
(
intf
==
RT_NULL
)
...
...
@@ -486,7 +486,7 @@ rt_err_t rt_usbh_storage_inquiry(struct uhintf* intf, rt_uint8_t* buffer)
rt_err_t
rt_usbh_storage_get_capacity
(
struct
uhintf
*
intf
,
rt_uint8_t
*
buffer
)
{
struct
ustorage_cbw
cmd
;
int
timeout
=
200
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* parameter check */
if
(
intf
==
RT_NULL
)
...
...
components/drivers/usb/usbhost/class/udisk.c
浏览文件 @
fbaa8693
...
...
@@ -70,13 +70,13 @@ static rt_size_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void* buffer,
rt_err_t
ret
;
struct
uhintf
*
intf
;
struct
ustor_data
*
data
;
int
timeout
=
500
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* check parameter */
RT_ASSERT
(
dev
!=
RT_NULL
);
RT_ASSERT
(
buffer
!=
RT_NULL
);
if
(
size
>
4096
)
timeout
=
800
;
if
(
size
>
4096
)
timeout
*=
2
;
data
=
(
struct
ustor_data
*
)
dev
->
user_data
;
intf
=
data
->
intf
;
...
...
@@ -108,13 +108,13 @@ static rt_size_t rt_udisk_write (rt_device_t dev, rt_off_t pos, const void* buff
rt_err_t
ret
;
struct
uhintf
*
intf
;
struct
ustor_data
*
data
;
int
timeout
=
500
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* check parameter */
RT_ASSERT
(
dev
!=
RT_NULL
);
RT_ASSERT
(
buffer
!=
RT_NULL
);
if
(
size
*
SECTOR_SIZE
>
4096
)
timeout
=
800
;
if
(
size
*
SECTOR_SIZE
>
4096
)
timeout
*=
2
;
data
=
(
struct
ustor_data
*
)
dev
->
user_data
;
intf
=
data
->
intf
;
...
...
@@ -293,7 +293,7 @@ rt_err_t rt_udisk_run(struct uhintf* intf)
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"read partition table
\n
"
));
/* get the partition table */
ret
=
rt_usbh_storage_read10
(
intf
,
sector
,
0
,
1
,
500
);
ret
=
rt_usbh_storage_read10
(
intf
,
sector
,
0
,
1
,
USB_TIMEOUT_LONG
);
if
(
ret
!=
RT_EOK
)
{
rt_kprintf
(
"read parition table error
\n
"
);
...
...
components/drivers/usb/usbhost/core/core.c
浏览文件 @
fbaa8693
...
...
@@ -260,18 +260,20 @@ rt_err_t rt_usbh_detach_instance(uinst_t device)
}
/* free configration descriptor */
for
(
i
=
0
;
i
<
device
->
cfg_desc
->
bNumInterfaces
;
i
++
)
{
if
(
device
->
intf
[
i
]
==
RT_NULL
)
continue
;
if
(
device
->
intf
[
i
]
->
drv
==
RT_NULL
)
continue
;
if
(
device
->
cfg_desc
)
{
for
(
i
=
0
;
i
<
device
->
cfg_desc
->
bNumInterfaces
;
i
++
)
{
if
(
device
->
intf
[
i
]
==
RT_NULL
)
continue
;
if
(
device
->
intf
[
i
]
->
drv
==
RT_NULL
)
continue
;
RT_ASSERT
(
device
->
intf
[
i
]
->
device
==
device
);
RT_ASSERT
(
device
->
intf
[
i
]
->
device
==
device
);
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"free interface instance %d
\n
"
,
i
));
rt_usbh_class_driver_disable
(
device
->
intf
[
i
]
->
drv
,
(
void
*
)
device
->
intf
[
i
]);
rt_free
(
device
->
intf
[
i
]);
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"free interface instance %d
\n
"
,
i
));
rt_usbh_class_driver_disable
(
device
->
intf
[
i
]
->
drv
,
(
void
*
)
device
->
intf
[
i
]);
rt_free
(
device
->
intf
[
i
]);
}
rt_free
(
device
->
cfg_desc
);
}
if
(
device
->
cfg_desc
)
rt_free
(
device
->
cfg_desc
);
rt_usb_hcd_free_pipe
(
device
->
hcd
,
device
->
pipe_ep0_out
);
rt_usb_hcd_free_pipe
(
device
->
hcd
,
device
->
pipe_ep0_in
);
...
...
@@ -301,7 +303,7 @@ rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer,
int
nbytes
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
RT_ASSERT
(
device
!=
RT_NULL
);
...
...
@@ -335,7 +337,7 @@ rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer,
rt_err_t
rt_usbh_set_address
(
uinst_t
device
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
RT_ASSERT
(
device
!=
RT_NULL
);
...
...
@@ -371,7 +373,7 @@ rt_err_t rt_usbh_set_address(uinst_t device)
rt_err_t
rt_usbh_set_configure
(
uinst_t
device
,
int
config
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* check parameter */
RT_ASSERT
(
device
!=
RT_NULL
);
...
...
@@ -405,7 +407,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config)
rt_err_t
rt_usbh_set_interface
(
uinst_t
device
,
int
intf
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* check parameter */
RT_ASSERT
(
device
!=
RT_NULL
);
...
...
@@ -436,7 +438,7 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf)
rt_err_t
rt_usbh_clear_feature
(
uinst_t
device
,
int
endpoint
,
int
feature
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* check parameter */
RT_ASSERT
(
device
!=
RT_NULL
);
...
...
components/drivers/usb/usbhost/core/hub.c
浏览文件 @
fbaa8693
...
...
@@ -118,7 +118,7 @@ void rt_usbh_root_hub_disconnect_handler(struct uhcd *hcd, rt_uint8_t port)
rt_err_t
rt_usbh_hub_get_descriptor
(
struct
uinstance
*
device
,
rt_uint8_t
*
buffer
,
rt_size_t
nbytes
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
device
!=
RT_NULL
);
...
...
@@ -151,7 +151,7 @@ rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer
rt_err_t
rt_usbh_hub_get_status
(
struct
uinstance
*
device
,
rt_uint32_t
*
buffer
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
device
!=
RT_NULL
);
...
...
@@ -184,7 +184,7 @@ rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint32_t* buffer)
rt_err_t
rt_usbh_hub_get_port_status
(
uhub_t
hub
,
rt_uint16_t
port
,
rt_uint32_t
*
buffer
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
hub
!=
RT_NULL
);
...
...
@@ -226,7 +226,7 @@ rt_err_t rt_usbh_hub_get_port_status(uhub_t hub, rt_uint16_t port, rt_uint32_t*
rt_err_t
rt_usbh_hub_clear_port_feature
(
uhub_t
hub
,
rt_uint16_t
port
,
rt_uint16_t
feature
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
hub
!=
RT_NULL
);
...
...
@@ -267,7 +267,7 @@ rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port,
rt_uint16_t
feature
)
{
struct
urequest
setup
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
/* parameter check */
RT_ASSERT
(
hub
!=
RT_NULL
);
...
...
@@ -345,6 +345,9 @@ rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port)
int
i
=
0
,
times
=
20
;
rt_uint32_t
pstatus
;
rt_bool_t
connect
=
RT_TRUE
;
int
delayticks
=
USB_DEBOUNCE_TIME
/
times
;
if
(
delayticks
<
1
)
delayticks
=
1
;
/* parameter check */
RT_ASSERT
(
hub
!=
RT_NULL
);
...
...
@@ -360,7 +363,7 @@ rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port)
break
;
}
rt_thread_delay
(
1
);
rt_thread_delay
(
delayticks
);
}
if
(
connect
)
return
RT_EOK
;
...
...
@@ -428,6 +431,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
device
->
speed
=
(
pstatus
&
PORT_LSDA
)
?
1
:
0
;
device
->
parent_hub
=
hub
;
device
->
hcd
=
hub
->
hcd
;
device
->
port
=
i
+
1
;
hub
->
child
[
i
]
=
device
;
/* reset usb roothub port */
...
...
@@ -452,7 +456,7 @@ static void rt_usbh_hub_irq(void* context)
{
upipe_t
pipe
;
uhub_t
hub
;
int
timeout
=
100
;
int
timeout
=
USB_TIMEOUT_BASIC
;
RT_ASSERT
(
context
!=
RT_NULL
);
...
...
@@ -493,7 +497,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
struct
uinstance
*
device
;
struct
uhintf
*
intf
=
(
struct
uhintf
*
)
arg
;
upipe_t
pipe_in
=
RT_NULL
;
int
timeout
=
300
;
int
timeout
=
USB_TIMEOUT_LONG
;
/* paremeter check */
RT_ASSERT
(
intf
!=
RT_NULL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录