Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
0c6c0842
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看板
未验证
提交
0c6c0842
编写于
11月 15, 2017
作者:
B
Bernard Xiong
提交者:
GitHub
11月 15, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1004 from uestczyh222/master
[Components][Drivers][USB]fix usb device core
上级
66ddbbfe
a3808362
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
18 deletion
+50
-18
components/drivers/include/drivers/usb_common.h
components/drivers/include/drivers/usb_common.h
+11
-0
components/drivers/include/drivers/usb_device.h
components/drivers/include/drivers/usb_device.h
+2
-0
components/drivers/usb/usbdevice/core/core.c
components/drivers/usb/usbdevice/core/core.c
+37
-18
未找到文件。
components/drivers/include/drivers/usb_common.h
浏览文件 @
0c6c0842
...
...
@@ -21,6 +21,7 @@
* Date Author Notes
* 2012-10-01 Yi Qiu first version
* 2013-04-26 aozima add DEVICEQUALIFIER support.
* 2017-11-15 ZYH fix ep0 transform error
*/
#ifndef __USB_COMMON_H__
...
...
@@ -241,6 +242,16 @@ typedef enum
USB_STATE_SUSPENDED
}
udevice_state_t
;
typedef
enum
{
STAGE_IDLE
,
STAGE_SETUP
,
STAGE_STATUS_IN
,
STAGE_STATUS_OUT
,
STAGE_DIN
,
STAGE_DOUT
}
uep0_stage_t
;
#pragma pack(1)
struct
usb_descriptor
...
...
components/drivers/include/drivers/usb_device.h
浏览文件 @
0c6c0842
...
...
@@ -22,6 +22,7 @@
* 2012-10-01 Yi Qiu first version
* 2012-12-12 heyuanjie87 change endpoint and function handler
* 2013-04-26 aozima add DEVICEQUALIFIER support.
* 2017-11-15 ZYH fix ep0 transform error
*/
#ifndef __USB_DEVICE_H__
...
...
@@ -137,6 +138,7 @@ struct udcd
struct
rt_device
parent
;
const
struct
udcd_ops
*
ops
;
struct
uendpoint
ep0
;
uep0_stage_t
stage
;
struct
ep_id
*
ep_pool
;
};
typedef
struct
udcd
*
udcd_t
;
...
...
components/drivers/usb/usbdevice/core/core.c
浏览文件 @
0c6c0842
...
...
@@ -24,6 +24,7 @@
* 2012-12-30 heyuanjie87 change inferface handler
* 2013-04-26 aozima add DEVICEQUALIFIER support.
* 2013-07-25 Yi Qiu update for USB CV test
* 2017-11-15 ZYH fix ep0 transform error
*/
#include <rtthread.h>
...
...
@@ -1815,22 +1816,41 @@ rt_err_t rt_usbd_ep0_setup_handler(udcd_t dcd, struct urequest* setup)
rt_err_t
rt_usbd_ep0_in_handler
(
udcd_t
dcd
)
{
rt_int32_t
remain
,
mps
;
RT_ASSERT
(
dcd
!=
RT_NULL
);
if
(
dcd
->
ep0
.
request
.
remain_size
>=
dcd
->
ep0
.
id
->
maxpacket
)
{
dcd_ep_write
(
dcd
,
EP0_IN_ADDR
,
dcd
->
ep0
.
request
.
buffer
,
dcd
->
ep0
.
id
->
maxpacket
);
dcd
->
ep0
.
request
.
remain_size
-=
dcd
->
ep0
.
id
->
maxpacket
;
dcd
->
ep0
.
request
.
buffer
+=
dcd
->
ep0
.
id
->
maxpacket
;
}
else
if
(
dcd
->
ep0
.
request
.
remain_size
>
0
)
if
(
dcd
->
stage
!=
STAGE_DIN
)
return
RT_EOK
;
mps
=
dcd
->
ep0
.
id
->
maxpacket
;
dcd
->
ep0
.
request
.
remain_size
-=
mps
;
remain
=
dcd
->
ep0
.
request
.
remain_size
;
if
(
remain
>
0
)
{
dcd_ep_write
(
dcd
,
EP0_IN_ADDR
,
dcd
->
ep0
.
request
.
buffer
,
dcd
->
ep0
.
request
.
remain_size
);
dcd
->
ep0
.
request
.
remain_size
=
0
;
if
(
remain
>=
mps
)
{
remain
=
mps
;
}
dcd
->
ep0
.
request
.
buffer
+=
mps
;
dcd_ep_write
(
dcd
,
EP0_IN_ADDR
,
dcd
->
ep0
.
request
.
buffer
,
remain
);
}
else
{
dcd_ep_write
(
dcd
,
EP0_IN_ADDR
,
RT_NULL
,
0
);
/* last packet is MPS multiple, so send ZLP packet */
if
((
remain
==
0
)
&&
(
dcd
->
ep0
.
request
.
size
>
0
))
{
dcd
->
ep0
.
request
.
size
=
0
;
dcd_ep_write
(
dcd
,
EP0_IN_ADDR
,
RT_NULL
,
0
);
}
else
{
/* receive status */
dcd
->
stage
=
STAGE_STATUS_OUT
;
dcd_ep_read_prepare
(
dcd
,
EP0_OUT_ADDR
,
RT_NULL
,
0
);
}
}
return
RT_EOK
;
...
...
@@ -1935,6 +1955,7 @@ rt_err_t rt_usbd_sof_handler(udcd_t dcd)
rt_size_t
rt_usbd_ep0_write
(
udevice_t
device
,
void
*
buffer
,
rt_size_t
size
)
{
uep_t
ep0
;
rt_size_t
sent_size
=
0
;
RT_ASSERT
(
device
!=
RT_NULL
);
RT_ASSERT
(
device
->
dcd
!=
RT_NULL
);
...
...
@@ -1945,20 +1966,17 @@ rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size)
ep0
->
request
.
size
=
size
;
ep0
->
request
.
buffer
=
buffer
;
ep0
->
request
.
remain_size
=
size
;
if
(
ep0
->
request
.
remain_size
>=
ep0
->
id
->
maxpacket
)
if
(
size
>=
ep0
->
id
->
maxpacket
)
{
dcd_ep_write
(
device
->
dcd
,
EP0_IN_ADDR
,
ep0
->
request
.
buffer
,
ep0
->
id
->
maxpacket
);
ep0
->
request
.
remain_size
-=
ep0
->
id
->
maxpacket
;
ep0
->
request
.
buffer
+=
ep0
->
id
->
maxpacket
;
sent_size
=
ep0
->
id
->
maxpacket
;
}
else
{
dcd_ep_write
(
device
->
dcd
,
EP0_IN_ADDR
,
ep0
->
request
.
buffer
,
ep0
->
request
.
remain_size
);
ep0
->
request
.
remain_size
=
0
;
sent_size
=
size
;
}
device
->
dcd
->
stage
=
STAGE_DIN
;
return
size
;
return
dcd_ep_write
(
device
->
dcd
,
EP0_IN_ADDR
,
ep0
->
request
.
buffer
,
sent_size
)
;
}
rt_size_t
rt_usbd_ep0_read
(
udevice_t
device
,
void
*
buffer
,
rt_size_t
size
,
...
...
@@ -1975,6 +1993,7 @@ rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size,
ep0
->
request
.
buffer
=
buffer
;
ep0
->
request
.
remain_size
=
size
;
ep0
->
rx_indicate
=
rx_ind
;
device
->
dcd
->
stage
=
STAGE_DOUT
;
dcd_ep_read_prepare
(
device
->
dcd
,
EP0_OUT_ADDR
,
buffer
,
size
);
return
size
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录