Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaobo07
rt-thread
提交
7a75e449
R
rt-thread
项目概览
Xiaobo07
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7a75e449
编写于
6月 10, 2019
作者:
lymzzyh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Components][USB][ECM] fix hotplug
上级
cc9ce52b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
12 deletion
+35
-12
components/drivers/usb/usbdevice/class/ecm.c
components/drivers/usb/usbdevice/class/ecm.c
+35
-12
未找到文件。
components/drivers/usb/usbdevice/class/ecm.c
浏览文件 @
7a75e449
...
...
@@ -6,17 +6,16 @@
* Change Logs:
* Date Author Notes
* 2017-11-19 ZYH first version
* 2019-06-10 ZYH fix hotplug
*/
#include <rtdevice.h>
#ifdef RT_USB_DEVICE_ECM
#include "cdc.h"
#ifdef ECM_DEBUG
#define ECM_PRINTF rt_kprintf("[ECM] "); rt_kprintf
#else
#define ECM_PRINTF(...)
#endif
/* ECM_DEBUG */
#define DBG_LEVEL DBG_WARNING
#define DBG_SECTION_NAME "ECM"
#include <rtdbg.h>
/* RT-Thread LWIP ethernet interface */
#include <netif/ethernetif.h>
...
...
@@ -216,15 +215,21 @@ static rt_err_t _cdc_send_notifi(ufunction_t func,ucdc_notification_code_t notif
return
RT_EOK
;
}
static
rt_err_t
_ecm_set_eth_packet_filter
(
ufunction_t
func
,
ureq_t
setup
)
{
rt_ecm_eth_t
_ecm_eth
=
(
rt_ecm_eth_t
)
func
->
user_data
;
dcd_ep0_send_status
(
func
->
device
->
dcd
);
/* send link up. */
eth_device_linkchange
(
&
_ecm_eth
->
parent
,
RT_TRUE
);
_cdc_send_notifi
(
func
,
UCDC_NOTIFI_NETWORK_CONNECTION
,
1
,
0
);
_cdc_send_notifi
(
func
,
UCDC_NOTIFI_NETWORK_CONNECTION
,
1
,
0
);
#ifdef LWIP_USING_DHCPD
extern
void
dhcpd_start
(
const
char
*
netif_name
);
dhcpd_start
(
"u0"
);
#endif
return
RT_EOK
;
}
/**
...
...
@@ -243,10 +248,11 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
switch
(
setup
->
bRequest
)
{
case
CDC_SET_ETH_PACKET_FILTER
:
LOG_D
(
"CDC_SET_ETH_PACKET_FILTER"
);
_ecm_set_eth_packet_filter
(
func
,
setup
);
break
;
default:
rt_kprintf
(
"setup->bRequest:0x%02X"
,
setup
->
bRequest
);
LOG_E
(
"Unknow setup->bRequest: 0x%02X"
,
setup
->
bRequest
);
break
;
}
return
RT_EOK
;
...
...
@@ -402,14 +408,13 @@ rt_err_t rt_ecm_eth_tx(rt_device_t dev, struct pbuf* p)
if
(
!
ecm_eth_dev
->
parent
.
link_status
)
{
ECM_PRINTF
(
"linkdown, drop pkg
\r\n
"
);
LOG_D
(
"linkdown, drop pkg
"
);
return
RT_EOK
;
}
// RT_ASSERT(p->tot_len < USB_ETH_MTU);
if
(
p
->
tot_len
>
USB_ETH_MTU
)
{
ECM_PRINTF
(
"RNDIS MTU is:%d, but the send packet size is %d
\r\n
"
,
LOG_W
(
"ECM MTU is:%d, but the send packet size is %d
"
,
USB_ETH_MTU
,
p
->
tot_len
);
p
->
tot_len
=
USB_ETH_MTU
;
}
...
...
@@ -461,10 +466,17 @@ static rt_err_t _function_enable(ufunction_t func)
{
cdc_eps_t
eps
;
rt_ecm_eth_t
ecm_device
=
(
rt_ecm_eth_t
)
func
->
user_data
;
LOG_D
(
"plugged in"
);
eps
=
(
cdc_eps_t
)
&
ecm_device
->
eps
;
eps
->
ep_out
->
buffer
=
ecm_device
->
rx_pool
;
/* reset eth rx tx */
rt_sem_release
(
&
ecm_device
->
tx_buffer_free
);
ecm_device
->
rx_size
=
0
;
ecm_device
->
rx_offset
=
0
;
eth_device_ready
(
&
ecm_device
->
parent
);
eps
->
ep_out
->
request
.
buffer
=
(
void
*
)
eps
->
ep_out
->
buffer
;
eps
->
ep_out
->
request
.
size
=
EP_MAXPACKET
(
eps
->
ep_out
);
...
...
@@ -482,7 +494,16 @@ static rt_err_t _function_enable(ufunction_t func)
*/
static
rt_err_t
_function_disable
(
ufunction_t
func
)
{
LOG_D
(
"plugged out"
);
eth_device_linkchange
(
&
((
rt_ecm_eth_t
)
func
->
user_data
)
->
parent
,
RT_FALSE
);
/* reset eth rx tx */
rt_sem_release
(
&
((
rt_ecm_eth_t
)
func
->
user_data
)
->
tx_buffer_free
);
((
rt_ecm_eth_t
)
func
->
user_data
)
->
rx_size
=
0
;
((
rt_ecm_eth_t
)
func
->
user_data
)
->
rx_offset
=
0
;
eth_device_ready
(
&
((
rt_ecm_eth_t
)
func
->
user_data
)
->
parent
);
return
RT_EOK
;
}
...
...
@@ -643,3 +664,5 @@ int rt_usbd_ecm_class_register(void)
return
0
;
}
INIT_PREV_EXPORT
(
rt_usbd_ecm_class_register
);
#endif
/* RT_USB_DEVICE_ECM */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录