Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wwsmg1
rt-thread
提交
40a474fe
R
rt-thread
项目概览
wwsmg1
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
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,发现更多精彩内容 >>
提交
40a474fe
编写于
1月 08, 2019
作者:
S
SummerGift
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][stm32] optimize eth driver
上级
688d8994
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
4 deletion
+59
-4
bsp/stm32/libraries/HAL_Drivers/drv_eth.c
bsp/stm32/libraries/HAL_Drivers/drv_eth.c
+52
-4
bsp/stm32/libraries/HAL_Drivers/drv_eth.h
bsp/stm32/libraries/HAL_Drivers/drv_eth.h
+7
-0
未找到文件。
bsp/stm32/libraries/HAL_Drivers/drv_eth.c
浏览文件 @
40a474fe
...
...
@@ -260,6 +260,9 @@ rt_err_t rt_stm32_eth_tx(rt_device_t dev, struct pbuf *p)
/* TODO Optimize data send speed*/
LOG_D
(
"transmit frame lenth :%d"
,
framelength
);
/* wait for unlocked */
while
(
EthHandle
.
Lock
==
HAL_LOCKED
);
state
=
HAL_ETH_TransmitFrame
(
&
EthHandle
,
framelength
);
if
(
state
!=
HAL_OK
)
{
...
...
@@ -410,6 +413,40 @@ void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth)
LOG_E
(
"eth err"
);
}
#ifdef PHY_USING_INTERRUPT_MODE
static
void
eth_phy_isr
(
void
*
args
)
{
rt_uint32_t
status
=
0
;
static
rt_uint8_t
link_status
=
1
;
HAL_ETH_ReadPHYRegister
(
&
EthHandle
,
PHY_INTERRUPT_FLAG_REG
,
(
uint32_t
*
)
&
status
);
LOG_D
(
"phy interrupt status reg is 0x%X"
,
status
);
HAL_ETH_ReadPHYRegister
(
&
EthHandle
,
PHY_BASIC_STATUS_REG
,
(
uint32_t
*
)
&
status
);
LOG_D
(
"phy basic status reg is 0x%X"
,
status
);
if
(
status
&
PHY_LINKED_STATUS_MASK
)
{
if
(
link_status
==
0
)
{
link_status
=
1
;
LOG_D
(
"link up"
);
/* send link up. */
eth_device_linkchange
(
&
stm32_eth_device
.
parent
,
RT_TRUE
);
}
}
else
{
if
(
link_status
==
1
)
{
link_status
=
0
;
LOG_I
(
"link down"
);
/* send link down. */
eth_device_linkchange
(
&
stm32_eth_device
.
parent
,
RT_FALSE
);
}
}
}
#endif
/* PHY_USING_INTERRUPT_MODE */
static
uint8_t
phy_speed
=
0
;
#define PHY_LINK_MASK (1<<0)
static
void
phy_monitor_thread_entry
(
void
*
parameter
)
...
...
@@ -435,12 +472,12 @@ static void phy_monitor_thread_entry(void *parameter)
if
(
phy_addr
==
0xFF
)
{
LOG_E
(
"phy not probe!
\r\n
"
);
LOG_E
(
"phy not probe!"
);
return
;
}
else
{
LOG_D
(
"found a phy, address:0x%02X
\r\n
"
,
phy_addr
);
LOG_D
(
"found a phy, address:0x%02X"
,
phy_addr
);
}
/* RESET PHY */
...
...
@@ -452,7 +489,7 @@ static void phy_monitor_thread_entry(void *parameter)
while
(
1
)
{
HAL_ETH_ReadPHYRegister
(
&
EthHandle
,
PHY_BASIC_STATUS_REG
,
(
uint32_t
*
)
&
status
);
LOG_D
(
"PHY BASIC STATUS REG:0x%04X
\r\n
"
,
status
);
LOG_D
(
"PHY BASIC STATUS REG:0x%04X"
,
status
);
phy_speed_new
=
0
;
...
...
@@ -512,10 +549,21 @@ static void phy_monitor_thread_entry(void *parameter)
/* send link up. */
eth_device_linkchange
(
&
stm32_eth_device
.
parent
,
RT_TRUE
);
#ifdef PHY_USING_INTERRUPT_MODE
/* configuration intterrupt pin */
rt_pin_mode
(
PHY_INT_PIN
,
PIN_MODE_INPUT_PULLUP
);
rt_pin_attach_irq
(
PHY_INT_PIN
,
PIN_IRQ_MODE_FALLING
,
eth_phy_isr
,
(
void
*
)
"callbackargs"
);
rt_pin_irq_enable
(
PHY_INT_PIN
,
PIN_IRQ_ENABLE
);
/* enable phy interrupt */
HAL_ETH_WritePHYRegister
(
&
EthHandle
,
PHY_INTERRUPT_MSAK_REG
,
PHY_INT_MASK
);
break
;
#endif
}
/* link up. */
else
{
LOG_I
(
"link down
\r\n
"
);
LOG_I
(
"link down"
);
/* send link down. */
eth_device_linkchange
(
&
stm32_eth_device
.
parent
,
RT_FALSE
);
}
...
...
bsp/stm32/libraries/HAL_Drivers/drv_eth.h
浏览文件 @
40a474fe
...
...
@@ -55,6 +55,13 @@
#define PHY_10M_MASK ((1<<12) || (1<<13))
#define PHY_100M_MASK ((1<<14) || (1<<15))
#define PHY_FULL_DUPLEX_MASK ((1<<15) || (1<<13))
/* The PHY interrupt source flag register. */
#define PHY_INTERRUPT_FLAG_REG 0x15U
/* The PHY interrupt mask register. */
#define PHY_INTERRUPT_MSAK_REG 0x15U
#define PHY_LINK_CHANGE_FLAG (1<<2)
#define PHY_LINK_CHANGE_MASK (1<<9)
#define PHY_INT_MASK 0
#endif
/* PHY_USING_DM9161CEP */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录