Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
luozhenger
rt-thread
提交
431aa6a9
R
rt-thread
项目概览
luozhenger
/
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,发现更多精彩内容 >>
提交
431aa6a9
编写于
4月 25, 2014
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #273 from yuht/patch-2
[bsp/lpc176x] Update emac.c
上级
1fdcede3
764c271c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
30 deletion
+46
-30
bsp/lpc176x/drivers/emac.c
bsp/lpc176x/drivers/emac.c
+46
-30
未找到文件。
bsp/lpc176x/drivers/emac.c
浏览文件 @
431aa6a9
...
...
@@ -195,7 +195,7 @@ static rt_err_t lpc17xx_emac_init(rt_device_t dev)
for
(
tout
=
1000
;
tout
;
tout
--
);
/* Wait for hardware reset to end. */
for
(
tout
=
0
;
tout
<
0x10
0000
;
tout
++
)
for
(
tout
=
0
;
tout
<
1
0000
;
tout
++
)
{
regv
=
read_PHY
(
PHY_REG_BMCR
);
if
(
!
(
regv
&
0x8000
))
...
...
@@ -204,46 +204,59 @@ static rt_err_t lpc17xx_emac_init(rt_device_t dev)
break
;
}
}
if
(
tout
>=
0x100000
)
return
-
RT_ERROR
;
/* reset failed */
if
(
tout
>=
10000
)
{
//return -RT_ERROR; /* reset failed */
rt_kprintf
(
"
\t
PHY Read PHY_REG_BMSR,Reset timeout,tout: %d.
\n
"
,
tout
);
}
/* Check if this is a DP83848C PHY. */
id1
=
read_PHY
(
PHY_REG_IDR1
);
id2
=
read_PHY
(
PHY_REG_IDR2
);
if
(((
id1
<<
16
)
|
(
id2
&
0xFFF0
))
!=
DP83848C_ID
)
return
-
RT_ERROR
;
/* Configure the PHY device */
/* Configure the PHY device */
switch
(
lpc17xx_emac_device
.
phy_mode
)
{
case
EMAC_PHY_AUTO
:
/* Use auto negotiation about the link speed. */
write_PHY
(
PHY_REG_BMCR
,
PHY_AUTO_NEG
);
/* Wait to complete Auto_Negotiation. */
for
(
tout
=
0
;
tout
<
0x100000
;
tout
++
)
// return -RT_ERROR;
rt_kprintf
(
"
\t
PHY Read PHY_REG_IDRx,PHY chip isn't DP83848C,Chip ID is %d.
\n
"
,((
id1
<<
16
)
|
(
id2
&
0xFFF0
)));
}
else
{
/* Configure the PHY device */
/* Configure the PHY device */
switch
(
lpc17xx_emac_device
.
phy_mode
)
{
regv
=
read_PHY
(
PHY_REG_BMSR
);
if
(
regv
&
0x0020
)
{
/* Auto negotiation Complete. */
case
EMAC_PHY_AUTO
:
/* Use auto negotiation about the link speed. */
write_PHY
(
PHY_REG_BMCR
,
PHY_AUTO_NEG
);
/* Wait to complete Auto_Negotiation. */
for
(
tout
=
0
;
tout
<
200000
;
tout
++
)
{
regv
=
read_PHY
(
PHY_REG_BMSR
);
if
(
regv
&
0x0020
)
{
/* Auto negotiation Complete. */
break
;
}
}
if
(
tout
>=
200000
)
{
rt_kprintf
(
"
\t
PHY Read PHY_REG_BMSR,Auto nego timeout,tout: %d.
\n
"
,
tout
);
}
break
;
case
EMAC_PHY_10MBIT
:
/* Connect at 10MBit */
write_PHY
(
PHY_REG_BMCR
,
PHY_FULLD_10M
);
break
;
case
EMAC_PHY_100MBIT
:
/* Connect at 100MBit */
write_PHY
(
PHY_REG_BMCR
,
PHY_FULLD_100M
);
break
;
}
}
break
;
case
EMAC_PHY_10MBIT
:
/* Connect at 10MBit */
write_PHY
(
PHY_REG_BMCR
,
PHY_FULLD_10M
);
break
;
case
EMAC_PHY_100MBIT
:
/* Connect at 100MBit */
write_PHY
(
PHY_REG_BMCR
,
PHY_FULLD_100M
);
break
;
}
if
(
tout
>=
0x100000
)
return
-
RT_ERROR
;
// auto_neg failed
//
if (tout >= 0x100000) return -RT_ERROR; // auto_neg failed
/* Check the link status. */
for
(
tout
=
0
;
tout
<
0x100
00
;
tout
++
)
for
(
tout
=
0
;
tout
<
1
00
;
tout
++
)
{
regv
=
read_PHY
(
PHY_REG_STS
);
if
(
regv
&
0x0001
)
...
...
@@ -252,8 +265,11 @@ static rt_err_t lpc17xx_emac_init(rt_device_t dev)
break
;
}
}
if
(
tout
>=
0x10000
)
return
-
RT_ERROR
;
if
(
tout
>=
100
)
{
//return -RT_ERROR;
rt_kprintf
(
"
\t
PHY Read PHY_REG_BMSR,Link on timeout,tout: %d.
\n
"
,
tout
);
}
/* Configure Full/Half Duplex mode. */
if
(
regv
&
0x0004
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录