Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
bd592766
R
rt-thread
项目概览
BaiXuePrincess
/
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看板
提交
bd592766
编写于
5月 12, 2015
作者:
肉肉_Alex
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update cmem7_eth.c
上级
2313424f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
103 addition
and
40 deletion
+103
-40
bsp/CME_M7/StdPeriph_Driver/src/cmem7_eth.c
bsp/CME_M7/StdPeriph_Driver/src/cmem7_eth.c
+103
-40
未找到文件。
bsp/CME_M7/StdPeriph_Driver/src/cmem7_eth.c
浏览文件 @
bd592766
...
...
@@ -5,8 +5,8 @@
* @brief CMEM7 ethernet source file
*
*
* @version V
1
.0
* @date 3. September 201
3
* @version V
2
.0
* @date 3. September 201
4
*
* @note
*
...
...
@@ -25,7 +25,7 @@
*/
#include "cmem7_eth.h"
#include "cmem7_misc.h"
typedef
struct
{
union
{
...
...
@@ -49,7 +49,7 @@ typedef struct {
uint32_t
TCH
:
1
;
/*!< Second Address Chained */
uint32_t
:
4
;
uint32_t
TTSE
:
1
;
/*!< enables IEEE1588 hardware timestamping in first segment */
uint32_t
:
2
;
uint32_t
:
2
;
uint32_t
FS
:
1
;
/*!< first segment flag */
uint32_t
LS
:
1
;
/*!< last segment flag */
uint32_t
IC
:
1
;
/*!< Interrupt on Completion */
...
...
@@ -190,8 +190,9 @@ static void mac_SetConfig(ETH_InitTypeDef *init) {
ETH
->
CONFIG_b
.
IPC
=
init
->
ETH_ChecksumOffload
;
ETH
->
CONFIG_b
.
DM
=
init
->
ETH_Duplex
;
ETH
->
CONFIG_b
.
LM
=
FALSE
;
ETH
->
MMC_RX_MASK
=
0xFFFFFFFF
;
ETH
->
MMC_TX_MASK
=
0xFFFFFFFF
;
ETH
->
MMCRIMR
=
0xFFFFFFFF
;
ETH
->
MMCTIMR
=
0xFFFFFFFF
;
ETH
->
MMCIRCOIM
=
0xFFFFFFFF
;
if
(
init
->
ETH_Speed
==
ETH_SPEED_10M
)
{
ETH
->
CONFIG_b
.
FES
=
ETH_EXACT_SPEED_10M_BPS
;
...
...
@@ -209,7 +210,7 @@ static void mac_SetConfig(ETH_InitTypeDef *init) {
ETH
->
CONFIG_b
.
JD
=
TRUE
;
ETH
->
CONFIG_b
.
WD
=
TRUE
;
ETH
->
CONFIG_b
.
TC
=
FALSE
;
ETH
->
CONFIG_b
.
CST
=
FALS
E
;
ETH
->
CONFIG_b
.
CST
=
TRU
E
;
ETH
->
CONFIG_b
.
TWOKPE
=
FALSE
;
ETH
->
CONFIG_b
.
SARC
=
ETH_SOURCE_ADDR_REPLACE
;
}
...
...
@@ -318,7 +319,7 @@ static void mac_SetFrameFilter(ETH_FrameFilter *filter) {
ETH
->
FF_b
.
VTFE
=
FALSE
;
ETH
->
FF_b
.
IPFE
=
FALSE
;
ETH
->
FF_b
.
DNTU
=
FALSE
;
ETH
->
FF_b
.
RA
=
TRUE
;
ETH
->
FF_b
.
RA
=
FALSE
;
//TRUE
// receive all
if
(
!
filter
)
{
...
...
@@ -339,14 +340,20 @@ static void mac_SetFrameFilter(ETH_FrameFilter *filter) {
// SA
if
(
filter
->
ETH_SourceFilterEnable
)
{
ETH
->
FF_b
.
RA
=
FALSE
;
uint32_t
value
;
ETH
->
FF_b
.
RA
=
FALSE
;
ETH
->
FF_b
.
SAF
=
TRUE
;
ETH
->
FF_b
.
SAIF
=
filter
->
ETH_SourceDrop
;
ETH
->
ADDR1_HIGH_b
.
AE
=
TRUE
;
ETH
->
ADDR1_HIGH_b
.
SA
=
TRUE
;
ETH
->
ADDR1_HIGH_b
.
ADDR
=
ETH
->
ADDR1_HIGH_b
.
SA
=
TRUE
;
ETH
->
ADDR1_HIGH_b
.
ADDR
=
(
filter
->
ETH_SourceMacAddr
[
5
]
<<
8
)
|
filter
->
ETH_SourceMacAddr
[
4
];
ETH
->
ADDR1_LOW
=
(
filter
->
ETH_SourceMacAddr
[
3
]
<<
24
)
|
// value = (filter->ETH_SourceMacAddr[5] << 8) | filter->ETH_SourceMacAddr[4];
// CMEM7_BFI(&(ETH->ADDR1_HIGH), value, 0, 16);
ETH
->
ADDR1_LOW
=
(
filter
->
ETH_SourceMacAddr
[
3
]
<<
24
)
|
(
filter
->
ETH_SourceMacAddr
[
2
]
<<
16
)
|
(
filter
->
ETH_SourceMacAddr
[
1
]
<<
8
)
|
filter
->
ETH_SourceMacAddr
[
0
];
...
...
@@ -355,9 +362,9 @@ static void mac_SetFrameFilter(ETH_FrameFilter *filter) {
static
void
mac_setFlowControl
(
void
)
{
ETH
->
FC_b
.
FCB
=
FALSE
;
ETH
->
FC_b
.
TFE
=
TRUE
;
ETH
->
FC_b
.
RFE
=
TRUE
;
ETH
->
FC_b
.
UP
=
TRUE
;
ETH
->
FC_b
.
TFE
=
FALSE
;
//TRUE
ETH
->
FC_b
.
RFE
=
FALSE
;
//TRUE
ETH
->
FC_b
.
UP
=
FALSE
;
//TRUE
}
uint32_t
ETH_PhyRead
(
uint32_t
phyAddr
,
uint32_t
phyReg
)
{
...
...
@@ -381,27 +388,44 @@ void ETH_PhyWrite(uint32_t phyAddr, uint32_t phyReg, uint32_t data) {
while
(
ETH
->
GMII_ADDR_b
.
BUSY
)
;
}
void
ETH_StructInit
(
ETH_InitTypeDef
*
init
)
{
init
->
ETH_Speed
=
ETH_SPEED_10M
;
init
->
ETH_Duplex
=
ETH_DUPLEX_FULL
;
init
->
ETH_JumboFrame
=
FALSE
;
init
->
ETH_LinkUp
=
FALSE
;
init
->
ETH_RxEn
=
TRUE
;
init
->
ETH_TxEn
=
TRUE
;
init
->
ETH_ChecksumOffload
=
FALSE
;
init
->
ETH_Filter
=
0
;
init
->
ETH_MacAddr
[
0
]
=
0
;
init
->
ETH_MacAddr
[
1
]
=
0
;
init
->
ETH_MacAddr
[
2
]
=
0
;
init
->
ETH_MacAddr
[
3
]
=
0
;
init
->
ETH_MacAddr
[
4
]
=
0
;
init
->
ETH_MacAddr
[
5
]
=
0
;
}
BOOL
ETH_Init
(
ETH_InitTypeDef
*
init
)
{
assert_param
(
init
);
assert_param
(
IS_ETH_SPEED
(
init
->
ETH_Speed
));
assert_param
(
IS_ETH_DUPLEX
(
init
->
ETH_Duplex
));
mac_SwReset
();
mac_SetConfig
(
init
);
mac_SetMacAddr
(
init
->
ETH_MacAddr
);
mac_SetBurst
(
ETH_BURST_MODE_MIXED
,
3
,
4
);
mac_SetPriority
(
TRUE
,
0
);
mac_SetDescMode
(
TRUE
,
0
);
mac_SetOpertionMode
();
mac_SetFrameFilter
(
init
->
ETH_Filter
);
mac_setFlowControl
();
return
TRUE
;
assert_param
(
init
);
assert_param
(
IS_ETH_SPEED
(
init
->
ETH_Speed
));
assert_param
(
IS_ETH_DUPLEX
(
init
->
ETH_Duplex
));
mac_SwReset
();
mac_SetConfig
(
init
);
mac_SetMacAddr
(
init
->
ETH_MacAddr
);
mac_SetBurst
(
ETH_BURST_MODE_MIXED
,
3
,
4
);
mac_SetPriority
(
TRUE
,
0
);
mac_SetDescMode
(
TRUE
,
0
);
mac_SetOpertionMode
();
mac_SetFrameFilter
(
init
->
ETH_Filter
);
mac_setFlowControl
();
return
TRUE
;
}
void
ETH_
EnableInt
(
uint32_t
Int
,
BOOL
enable
)
{
void
ETH_
ITConfig
(
uint32_t
Int
,
BOOL
enable
)
{
assert_param
(
IS_ETH_INT
(
Int
));
if
(
enable
)
{
...
...
@@ -426,7 +450,7 @@ void ETH_EnableInt(uint32_t Int, BOOL enable) {
}
}
}
BOOL
ETH_GetI
nt
Status
(
uint32_t
Int
)
{
BOOL
ETH_GetI
T
Status
(
uint32_t
Int
)
{
assert_param
(
IS_ETH_INT
(
Int
));
Int
&=
ETH
->
INT_EN
;
...
...
@@ -436,8 +460,7 @@ BOOL ETH_GetIntStatus(uint32_t Int) {
return
FALSE
;
}
void
ETH_ClearInt
(
uint32_t
Int
)
{
void
ETH_ClearITPendingBit
(
uint32_t
Int
)
{
uint32_t
sta
;
assert_param
(
IS_ETH_INT
(
Int
));
...
...
@@ -450,15 +473,15 @@ void ETH_ClearInt(uint32_t Int) {
if
(
IS_ETH_INT_NORMAL
(
Int
))
{
if
(
!
IS_ETH_INT_NORMAL
(
sta
))
{
// write 1 clear
ETH
->
STATUS
_b
.
NIS
=
1
;
// write 1 clear
NIS
ETH
->
STATUS
=
ETH_INT_NORMAL_SUMMARY
;
}
}
if
(
IS_ETH_INT_ABNORMAL
(
Int
))
{
if
(
!
IS_ETH_INT_ABNORMAL
(
sta
))
{
// write 1 clear
ETH
->
STATUS
_b
.
AIS
=
1
;
// write 1 clear
AIS
ETH
->
STATUS
=
ETH_INT_ABNORMAL_SUMMARY
;
}
}
}
...
...
@@ -491,12 +514,25 @@ BOOL ETH_SetTxDescRing(ETH_TX_DESC *ring) {
return
FALSE
;
}
/* If code mapping */
ring
=
(
ETH_TX_DESC
*
)
GLB_ConvertToMappingFromAddr
((
uint32_t
)
ring
);
buf
=
ring
;
do
{
INNER_ETH_TX_DESC
*
desc
=
(
INNER_ETH_TX_DESC
*
)
buf
;
uint8_t
first
=
desc
->
TX_0
.
TX0_b
.
FS
;
uint8_t
last
=
desc
->
TX_0
.
TX0_b
.
LS
;
// clear all bits
desc
->
TX_0
.
TX0
=
0
;
desc
->
TX_0
.
TX0_b
.
FS
=
first
;
desc
->
TX_0
.
TX0_b
.
LS
=
last
;
desc
->
TX_0
.
TX0_b
.
TCH
=
TRUE
;
desc
->
TX_0
.
TX0_b
.
IC
=
TRUE
;
desc
->
TX_0
.
TX0_b
.
OWN
=
ETH_DESC_OWN_BY_SELF
;
buf
->
bufAddr
=
GLB_ConvertToMappingFromAddr
(
buf
->
bufAddr
);
buf
->
nextDescAddr
=
GLB_ConvertToMappingFromAddr
(
buf
->
nextDescAddr
);
buf
=
(
ETH_TX_DESC
*
)
buf
->
nextDescAddr
;
}
while
(
buf
!=
ring
);
...
...
@@ -553,6 +589,16 @@ void ETH_ReleaseTxDesc(ETH_TX_DESC *desc) {
inner
->
TX_0
.
TX0_b
.
OWN
=
ETH_DESC_OWN_BY_HW
;
}
void
ETH_SetTxDescBufAddr
(
ETH_TX_DESC
*
desc
,
uint32_t
bufAddr
)
{
if
(
desc
)
{
desc
->
bufAddr
=
GLB_ConvertToMappingFromAddr
(
bufAddr
);;
}
}
uint32_t
ETH_GetTxDescBufAddr
(
ETH_TX_DESC
*
desc
)
{
return
(
desc
?
GLB_ConvertToMappingToAddr
(
desc
->
bufAddr
)
:
0
);
}
BOOL
ETH_SetRxDescRing
(
ETH_RX_DESC
*
ring
)
{
ETH_RX_DESC
*
buf
=
ring
;
...
...
@@ -564,12 +610,17 @@ BOOL ETH_SetRxDescRing(ETH_RX_DESC *ring) {
return
FALSE
;
}
/* If code mapping */
ring
=
(
ETH_RX_DESC
*
)
GLB_ConvertToMappingFromAddr
((
uint32_t
)
ring
);
buf
=
ring
;
do
{
INNER_ETH_RX_DESC
*
desc
=
(
INNER_ETH_RX_DESC
*
)
buf
;
desc
->
RX_1
.
RX1_b
.
RCH
=
TRUE
;
desc
->
RX_1
.
RX1_b
.
DIC
=
FALSE
;
desc
->
RX_0
.
RX0_b
.
OWN
=
ETH_DESC_OWN_BY_HW
;
buf
->
bufAddr
=
GLB_ConvertToMappingFromAddr
(
buf
->
bufAddr
);
buf
->
nextDescAddr
=
GLB_ConvertToMappingFromAddr
(
buf
->
nextDescAddr
);
buf
=
(
ETH_RX_DESC
*
)
buf
->
nextDescAddr
;
}
while
(
buf
!=
ring
);
...
...
@@ -627,3 +678,15 @@ void ETH_ReleaseRxDesc(ETH_RX_DESC *desc) {
}
void
ETH_SetRxDescBufAddr
(
ETH_RX_DESC
*
desc
,
uint32_t
bufAddr
)
{
if
(
desc
)
{
desc
->
bufAddr
=
GLB_ConvertToMappingFromAddr
(
bufAddr
);;
}
}
uint32_t
ETH_GetRxDescBufAddr
(
ETH_RX_DESC
*
desc
)
{
return
(
desc
?
GLB_ConvertToMappingToAddr
(
desc
->
bufAddr
)
:
0
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录