Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逝缘~
rt-thread
提交
4cdb0154
R
rt-thread
项目概览
逝缘~
/
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,发现更多精彩内容 >>
提交
4cdb0154
编写于
6月 12, 2013
作者:
qiuyiuestc
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #100 from grissiom/usb-plug
usb: add USB_MSG_PLUG_OUT event
上级
4807145a
b02993c9
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
61 addition
and
4 deletion
+61
-4
components/drivers/include/drivers/usb_device.h
components/drivers/include/drivers/usb_device.h
+5
-0
components/drivers/usb/usbdevice/core/core.c
components/drivers/usb/usbdevice/core/core.c
+56
-4
未找到文件。
components/drivers/include/drivers/usb_device.h
浏览文件 @
4cdb0154
...
...
@@ -146,6 +146,11 @@ enum udev_msg_type
USB_MSG_DATA_NOTIFY
,
USB_MSG_SOF
,
USB_MSG_RESET
,
/* we don't need to add a "PLUG_IN" event because after the cable is
* plugged in(before any SETUP) the classed have nothing to do. If the host
* is ready, it will send RESET and we will have USB_MSG_RESET. So, a RESET
* should reset and run the class while plug_in is not. */
USB_MSG_PLUG_OUT
,
};
typedef
enum
udev_msg_type
udev_msg_type
;
...
...
components/drivers/usb/usbdevice/core/core.c
浏览文件 @
4cdb0154
...
...
@@ -667,13 +667,13 @@ rt_err_t _sof_notify(udevice_t device)
}
/**
* This function will
reset
all class.
* This function will
stop
all class.
*
* @param device the usb device object.
*
* @return RT_EOK.
*/
rt_err_t
_
reset
_notify
(
udevice_t
device
)
rt_err_t
_
stop
_notify
(
udevice_t
device
)
{
struct
rt_list_node
*
i
;
uclass_t
cls
;
...
...
@@ -681,13 +681,38 @@ rt_err_t _reset_notify(udevice_t device)
RT_ASSERT
(
device
!=
RT_NULL
);
/* to notity every class that sof event comes */
for
(
i
=
device
->
curr_cfg
->
cls_list
.
next
;
i
!=&
device
->
curr_cfg
->
cls_list
;
i
=
i
->
next
)
for
(
i
=
device
->
curr_cfg
->
cls_list
.
next
;
i
!=
&
device
->
curr_cfg
->
cls_list
;
i
=
i
->
next
)
{
cls
=
(
uclass_t
)
rt_list_entry
(
i
,
struct
uclass
,
list
);
if
(
cls
->
ops
->
stop
!=
RT_NULL
)
cls
->
ops
->
stop
(
device
,
cls
);
}
return
RT_EOK
;
}
/**
* This function will run all class.
*
* @param device the usb device object.
*
* @return RT_EOK.
*/
rt_err_t
_run_notify
(
udevice_t
device
)
{
struct
rt_list_node
*
i
;
uclass_t
cls
;
RT_ASSERT
(
device
!=
RT_NULL
);
/* to notity every class that sof event comes */
for
(
i
=
device
->
curr_cfg
->
cls_list
.
next
;
i
!=
&
device
->
curr_cfg
->
cls_list
;
i
=
i
->
next
)
{
cls
=
(
uclass_t
)
rt_list_entry
(
i
,
struct
uclass
,
list
);
if
(
cls
->
ops
->
run
!=
RT_NULL
)
cls
->
ops
->
run
(
device
,
cls
);
}
...
...
@@ -695,6 +720,26 @@ rt_err_t _reset_notify(udevice_t device)
return
RT_EOK
;
}
/**
* This function will reset all class.
*
* @param device the usb device object.
*
* @return RT_EOK.
*/
rt_err_t
_reset_notify
(
udevice_t
device
)
{
struct
rt_list_node
*
i
;
uclass_t
cls
;
RT_ASSERT
(
device
!=
RT_NULL
);
_stop_notify
();
_run_notify
();
return
RT_EOK
;
}
/**
* This function will create an usb device object.
*
...
...
@@ -1402,6 +1447,10 @@ static void rt_usbd_thread_entry(void* parameter)
_sof_notify
(
device
);
break
;
case
USB_MSG_DATA_NOTIFY
:
/* some buggy drivers will have USB_MSG_DATA_NOTIFY before the core
* got configured. */
if
(
device
->
state
!=
USB_STATE_CONFIGURED
)
break
;
ep
=
rt_usbd_find_endpoint
(
device
,
&
cls
,
msg
.
content
.
ep_msg
.
ep_addr
);
if
(
ep
!=
RT_NULL
)
ep
->
handler
(
device
,
cls
,
msg
.
content
.
ep_msg
.
size
);
...
...
@@ -1415,6 +1464,9 @@ static void rt_usbd_thread_entry(void* parameter)
if
(
device
->
state
==
USB_STATE_ADDRESS
)
_reset_notify
(
device
);
break
;
case
USB_MSG_PLUG_OUT
:
_stop_notify
(
device
);
break
;
default:
rt_kprintf
(
"unknown msg type
\n
"
);
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录