Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
03ff8a29
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看板
提交
03ff8a29
编写于
5月 02, 2018
作者:
L
liang yongxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][imxrt1052-evk] update enet driver: revert all change for fsl_enet.c
上级
795f9873
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
185 addition
and
12 deletion
+185
-12
bsp/imxrt1052-evk/Libraries/drivers/fsl_enet.c
bsp/imxrt1052-evk/Libraries/drivers/fsl_enet.c
+1
-6
bsp/imxrt1052-evk/drivers/drv_eth.c
bsp/imxrt1052-evk/drivers/drv_eth.c
+184
-6
未找到文件。
bsp/imxrt1052-evk/Libraries/drivers/fsl_enet.c
浏览文件 @
03ff8a29
...
...
@@ -1346,12 +1346,7 @@ status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const uint8_t *d
address
=
(
uint32_t
)
curBuffDescrip
->
buffer
;
#endif
/* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
{
// Change SDK to reduce memory copy
extern
void
pbuf2mem
(
const
uint8_t
*
data
,
void
*
dataptr
,
uint32_t
len
);
pbuf2mem
(
data
,
(
void
*
)
address
,
length
);
}
//memcpy((void *)address, data, length);
memcpy
((
void
*
)
address
,
data
,
length
);
/* Set data length. */
curBuffDescrip
->
length
=
length
;
#ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
...
...
bsp/imxrt1052-evk/drivers/drv_eth.c
浏览文件 @
03ff8a29
...
...
@@ -23,6 +23,7 @@
#include "fsl_gpio.h"
#include "fsl_iomuxc.h"
#include "fsl_phy.h"
#include "fsl_cache.h"
#ifdef RT_USING_LWIP
...
...
@@ -479,6 +480,188 @@ static rt_err_t rt_imxrt_eth_control(rt_device_t dev, int cmd, void *args)
return
RT_EOK
;
}
static
void
_ENET_ActiveSend
(
ENET_Type
*
base
,
uint32_t
ringId
)
{
assert
(
ringId
<
FSL_FEATURE_ENET_QUEUE
);
switch
(
ringId
)
{
case
0
:
base
->
TDAR
=
ENET_TDAR_TDAR_MASK
;
break
;
#if FSL_FEATURE_ENET_QUEUE > 1
case
kENET_Ring1
:
base
->
TDAR1
=
ENET_TDAR1_TDAR_MASK
;
break
;
case
kENET_Ring2
:
base
->
TDAR2
=
ENET_TDAR2_TDAR_MASK
;
break
;
#endif
/* FSL_FEATURE_ENET_QUEUE > 1 */
default:
base
->
TDAR
=
ENET_TDAR_TDAR_MASK
;
break
;
}
}
static
status_t
_ENET_SendFrame
(
ENET_Type
*
base
,
enet_handle_t
*
handle
,
const
uint8_t
*
data
,
uint32_t
length
)
{
assert
(
handle
);
assert
(
data
);
volatile
enet_tx_bd_struct_t
*
curBuffDescrip
;
uint32_t
len
=
0
;
uint32_t
sizeleft
=
0
;
uint32_t
address
;
/* Check the frame length. */
if
(
length
>
ENET_FRAME_MAX_FRAMELEN
)
{
return
kStatus_ENET_TxFrameOverLen
;
}
/* Check if the transmit buffer is ready. */
curBuffDescrip
=
handle
->
txBdCurrent
[
0
];
if
(
curBuffDescrip
->
control
&
ENET_BUFFDESCRIPTOR_TX_READY_MASK
)
{
return
kStatus_ENET_TxFrameBusy
;
}
#ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
bool
isPtpEventMessage
=
false
;
/* Check PTP message with the PTP header. */
isPtpEventMessage
=
ENET_Ptp1588ParseFrame
(
data
,
NULL
,
true
);
#endif
/* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
/* One transmit buffer is enough for one frame. */
if
(
handle
->
txBuffSizeAlign
[
0
]
>=
length
)
{
/* Copy data to the buffer for uDMA transfer. */
#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
address
=
MEMORY_ConvertMemoryMapAddress
((
uint32_t
)
curBuffDescrip
->
buffer
,
kMEMORY_DMA2Local
);
#else
address
=
(
uint32_t
)
curBuffDescrip
->
buffer
;
#endif
/* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
pbuf_copy_partial
((
const
struct
pbuf
*
)
data
,
(
void
*
)
address
,
length
,
0
);
/* Set data length. */
curBuffDescrip
->
length
=
length
;
#ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
/* For enable the timestamp. */
if
(
isPtpEventMessage
)
{
curBuffDescrip
->
controlExtend1
|=
ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK
;
}
else
{
curBuffDescrip
->
controlExtend1
&=
~
ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK
;
}
#endif
/* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
curBuffDescrip
->
control
|=
(
ENET_BUFFDESCRIPTOR_TX_READY_MASK
|
ENET_BUFFDESCRIPTOR_TX_LAST_MASK
);
/* Increase the buffer descriptor address. */
if
(
curBuffDescrip
->
control
&
ENET_BUFFDESCRIPTOR_TX_WRAP_MASK
)
{
handle
->
txBdCurrent
[
0
]
=
handle
->
txBdBase
[
0
];
}
else
{
handle
->
txBdCurrent
[
0
]
++
;
}
#if defined(FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL
/* Add the cache clean maintain. */
#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
address
=
MEMORY_ConvertMemoryMapAddress
((
uint32_t
)
curBuffDescrip
->
buffer
,
kMEMORY_DMA2Local
);
#else
address
=
(
uint32_t
)
curBuffDescrip
->
buffer
;
#endif
/* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
DCACHE_CleanByRange
(
address
,
length
);
#endif
/* FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
/* Active the transmit buffer descriptor. */
_ENET_ActiveSend
(
base
,
0
);
return
kStatus_Success
;
}
else
{
/* One frame requires more than one transmit buffers. */
do
{
#ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
/* For enable the timestamp. */
if
(
isPtpEventMessage
)
{
curBuffDescrip
->
controlExtend1
|=
ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK
;
}
else
{
curBuffDescrip
->
controlExtend1
&=
~
ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK
;
}
#endif
/* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
/* Increase the buffer descriptor address. */
if
(
curBuffDescrip
->
control
&
ENET_BUFFDESCRIPTOR_TX_WRAP_MASK
)
{
handle
->
txBdCurrent
[
0
]
=
handle
->
txBdBase
[
0
];
}
else
{
handle
->
txBdCurrent
[
0
]
++
;
}
/* update the size left to be transmit. */
sizeleft
=
length
-
len
;
if
(
sizeleft
>
handle
->
txBuffSizeAlign
[
0
])
{
/* Data copy. */
#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
address
=
MEMORY_ConvertMemoryMapAddress
((
uint32_t
)
curBuffDescrip
->
buffer
,
kMEMORY_DMA2Local
);
#else
address
=
(
uint32_t
)
curBuffDescrip
->
buffer
;
#endif
/* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
memcpy
((
void
*
)
address
,
data
+
len
,
handle
->
txBuffSizeAlign
[
0
]);
/* Data length update. */
curBuffDescrip
->
length
=
handle
->
txBuffSizeAlign
[
0
];
len
+=
handle
->
txBuffSizeAlign
[
0
];
/* Sets the control flag. */
curBuffDescrip
->
control
&=
~
ENET_BUFFDESCRIPTOR_TX_LAST_MASK
;
curBuffDescrip
->
control
|=
ENET_BUFFDESCRIPTOR_TX_READY_MASK
;
/* Active the transmit buffer descriptor*/
_ENET_ActiveSend
(
base
,
0
);
}
else
{
#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
address
=
MEMORY_ConvertMemoryMapAddress
((
uint32_t
)
curBuffDescrip
->
buffer
,
kMEMORY_DMA2Local
);
#else
address
=
(
uint32_t
)
curBuffDescrip
->
buffer
;
#endif
/* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
memcpy
((
void
*
)
address
,
data
+
len
,
sizeleft
);
curBuffDescrip
->
length
=
sizeleft
;
/* Set Last buffer wrap flag. */
curBuffDescrip
->
control
|=
ENET_BUFFDESCRIPTOR_TX_READY_MASK
|
ENET_BUFFDESCRIPTOR_TX_LAST_MASK
;
#if defined(FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL
/* Add the cache clean maintain. */
#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
address
=
MEMORY_ConvertMemoryMapAddress
((
uint32_t
)
curBuffDescrip
->
buffer
,
kMEMORY_DMA2Local
);
#else
address
=
(
uint32_t
)
curBuffDescrip
->
buffer
;
#endif
/* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
DCACHE_CleanByRange
(
address
,
handle
->
txBuffSizeAlign
[
0
]);
#endif
/* FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
/* Active the transmit buffer descriptor. */
_ENET_ActiveSend
(
base
,
0
);
return
kStatus_Success
;
}
/* Get the current buffer descriptor address. */
curBuffDescrip
=
handle
->
txBdCurrent
[
0
];
}
while
(
!
(
curBuffDescrip
->
control
&
ENET_BUFFDESCRIPTOR_TX_READY_MASK
));
return
kStatus_ENET_TxFrameBusy
;
}
}
/* ethernet device interface */
/* transmit packet. */
rt_err_t
rt_imxrt_eth_tx
(
rt_device_t
dev
,
struct
pbuf
*
p
)
...
...
@@ -497,7 +680,7 @@ rt_err_t rt_imxrt_eth_tx(rt_device_t dev, struct pbuf *p)
do
{
result
=
ENET_SendFrame
(
imxrt_eth_device
.
enet_base
,
enet_handle
,
(
const
uint8_t
*
)
p
,
p
->
tot_len
);
result
=
_
ENET_SendFrame
(
imxrt_eth_device
.
enet_base
,
enet_handle
,
(
const
uint8_t
*
)
p
,
p
->
tot_len
);
if
(
result
==
kStatus_ENET_TxFrameBusy
)
{
...
...
@@ -511,11 +694,6 @@ rt_err_t rt_imxrt_eth_tx(rt_device_t dev, struct pbuf *p)
return
RT_EOK
;
}
void
pbuf2mem
(
const
uint8_t
*
data
,
void
*
dataptr
,
uint32_t
len
)
{
pbuf_copy_partial
((
const
struct
pbuf
*
)
data
,
dataptr
,
len
,
0
);
}
/* reception packet. */
struct
pbuf
*
rt_imxrt_eth_rx
(
rt_device_t
dev
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录