Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PHPmihuan
rt-thread
提交
e822f87b
R
rt-thread
项目概览
PHPmihuan
/
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,发现更多精彩内容 >>
提交
e822f87b
编写于
5月 17, 2013
作者:
qiuyiuestc
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #90 from heyuanjie87/ForPullRequest
For pull request
上级
2ef9d919
8b4aadb4
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
79 addition
and
11 deletion
+79
-11
components/drivers/include/drivers/usb_common.h
components/drivers/include/drivers/usb_common.h
+27
-0
components/drivers/include/drivers/usb_device.h
components/drivers/include/drivers/usb_device.h
+7
-5
components/drivers/usb/usbdevice/core/core.c
components/drivers/usb/usbdevice/core/core.c
+45
-6
未找到文件。
components/drivers/include/drivers/usb_common.h
浏览文件 @
e822f87b
...
...
@@ -207,6 +207,18 @@ extern "C" {
(((rt_uint16_t)(*(((rt_uint8_t *)(x)) + 1))) << 8))
typedef
void
(
*
func_callback
)(
void
*
context
);
typedef
enum
{
USB_STATE_NOTATTACHED
=
0
,
USB_STATE_ATTACHED
,
USB_STATE_POWERED
,
USB_STATE_RECONNECTING
,
USB_STATE_UNAUTHENTICATED
,
USB_STATE_DEFAULT
,
USB_STATE_ADDRESS
,
USB_STATE_CONFIGURED
,
USB_STATE_SUSPENDED
}
udevice_state_t
;
#pragma pack(1)
...
...
@@ -310,6 +322,21 @@ struct uhub_descriptor
};
typedef
struct
uhub_descriptor
*
uhub_desc_t
;
struct
uhid_descriptor
{
rt_uint8_t
bLength
;
rt_uint8_t
type
;
rt_uint16_t
bcdHID
;
rt_uint8_t
bCountryCode
;
rt_uint8_t
bNumDescriptors
;
struct
hid_descriptor_list
{
rt_uint8_t
type
;
rt_uint16_t
wLength
;
}
Descriptor
[
1
];
};
typedef
struct
uhid_descriptor
*
uhid_desc_t
;
struct
ureqest
{
rt_uint8_t
request_type
;
...
...
components/drivers/include/drivers/usb_device.h
浏览文件 @
e822f87b
...
...
@@ -131,6 +131,7 @@ struct udevice
struct
udevice_descriptor
dev_desc
;
const
char
**
str
;
udevice_state_t
state
;
rt_list_t
cfg_list
;
uconfig_t
curr_cfg
;
rt_uint8_t
nr_intf
;
...
...
@@ -198,6 +199,7 @@ uep_t rt_usbd_find_endpoint(udevice_t device, uclass_t* pcls, rt_uint8_t ep_addr
uclass_t
rt_usbd_class_mstorage_create
(
udevice_t
device
);
uclass_t
rt_usbd_class_cdc_create
(
udevice_t
device
);
uclass_t
rt_usbd_class_rndis_create
(
udevice_t
device
);
uclass_t
rt_usbd_class_dap_create
(
udevice_t
device
);
#ifdef RT_USB_DEVICE_COMPOSITE
rt_err_t
rt_usbd_class_set_iad
(
uclass_t
cls
,
uiad_desc_t
iad_desc
);
...
...
components/drivers/usb/usbdevice/core/core.c
浏览文件 @
e822f87b
...
...
@@ -199,6 +199,12 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup)
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"_get_interface
\n
"
));
if
(
device
->
state
!=
USB_STATE_CONFIGURED
)
{
dcd_ep_stall
(
device
->
dcd
,
0
);
return
-
RT_ERROR
;
}
/* find the specified interface and its alternate setting */
intf
=
rt_usbd_find_interface
(
device
,
setup
->
index
&
0xFF
,
RT_NULL
);
value
=
intf
->
curr_setting
->
intf_desc
->
bAlternateSetting
;
...
...
@@ -230,6 +236,12 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup)
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"_set_interface
\n
"
));
if
(
device
->
state
!=
USB_STATE_CONFIGURED
)
{
dcd_ep_stall
(
device
->
dcd
,
0
);
return
-
RT_ERROR
;
}
/* find the specified interface */
intf
=
rt_usbd_find_interface
(
device
,
setup
->
index
&
0xFF
,
RT_NULL
);
...
...
@@ -267,9 +279,15 @@ static rt_err_t _get_config(struct udevice* device, ureq_t setup)
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"_get_config
\n
"
));
if
(
device
->
state
==
USB_STATE_CONFIGURED
)
{
/* get current configuration */
value
=
device
->
curr_cfg
->
cfg_desc
.
bConfigurationValue
;
}
else
{
value
=
0
;
}
/* write the current configuration to endpoint 0 */
dcd_ep_write
(
device
->
dcd
,
0
,
&
value
,
1
);
...
...
@@ -298,6 +316,20 @@ static rt_err_t _set_config(struct udevice* device, ureq_t setup)
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"_set_config
\n
"
));
if
(
setup
->
value
>
device
->
dev_desc
.
bNumConfigurations
)
{
dcd_ep_stall
(
device
->
dcd
,
0
);
return
-
RT_ERROR
;
}
if
(
setup
->
value
==
0
)
{
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"address state
\n
"
));
device
->
state
=
USB_STATE_ADDRESS
;
goto
_exit
;
}
/* set current configuration */
rt_usbd_set_config
(
device
,
setup
->
value
);
cfg
=
device
->
curr_cfg
;
...
...
@@ -324,6 +356,9 @@ static rt_err_t _set_config(struct udevice* device, ureq_t setup)
cls
->
ops
->
run
(
device
,
cls
);
}
device
->
state
=
USB_STATE_CONFIGURED
;
_exit:
/* issue status stage */
dcd_send_status
(
device
->
dcd
);
...
...
@@ -349,6 +384,8 @@ static rt_err_t _set_address(struct udevice* device, ureq_t setup)
/* set address in device control driver */
dcd_set_address
(
device
->
dcd
,
setup
->
value
);
device
->
state
=
USB_STATE_ADDRESS
;
/* issue status stage */
dcd_send_status
(
device
->
dcd
);
...
...
@@ -382,7 +419,9 @@ static rt_err_t _request_interface(struct udevice* device, ureq_t setup)
ret
=
intf
->
handler
(
device
,
cls
,
setup
);
}
else
{
ret
=
-
RT_ERROR
;
}
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录