Skip to content

Commit 62605df

Browse files
author
Sergio Scaglia
committed
- Added initialization for Tx Fifo values and provided value for TFWR bits in ENET_TFWR register
Signed-off-by: Sergio Scaglia <[email protected]>
1 parent ea4b6f7 commit 62605df

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/enet/fsl_enet_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void enet_hal_config_tx_fifo(uint32_t instance, enet_config_tx_fifo_t *threshold
148148
BW_ENET_TFWR_STRFWD(instance, thresholdCfg->isStoreForwardEnabled); /* Set store and forward mode*/
149149
if(!thresholdCfg->isStoreForwardEnabled)
150150
{
151-
BW_ENET_TFWR_TFWR(instance, thresholdCfg->txFifoWrite); /* Set transmit FIFO write bytes*/
152151
assert(thresholdCfg->txFifoWrite <= BM_ENET_TFWR_TFWR);
152+
BW_ENET_TFWR_TFWR(instance, thresholdCfg->txFifoWrite); /* Set transmit FIFO write bytes*/
153153
}
154154
BW_ENET_TSEM_TX_SECTION_EMPTY(instance,thresholdCfg->txEmpty); /* Set transmit FIFO empty threshold*/
155155
BW_ENET_TAEM_TX_ALMOST_EMPTY(instance,thresholdCfg->txAlmostEmpty); /* Set transmit FIFO almost empty threshold*/

libraries/net/eth/lwip-eth/arch/TARGET_K64F/fsl_enet_driver.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ uint32_t enet_mac_configure_fifo_accel(enet_dev_if_t * enetIfPtr)
264264
{
265265
return kStatus_ENET_InvalidInput;
266266
}
267+
268+
/* Initialize values that will not be initialized later on */
269+
rxFifo.rxEmpty = 0;
270+
rxFifo.rxFull = 0;
271+
txFifo.isStoreForwardEnabled = 0;
272+
txFifo.txFifoWrite = 0;
273+
txFifo.txEmpty = 0;
267274

268275
/* Configure tx/rx accelerator*/
269276
if (enetIfPtr->macCfgPtr->isRxAccelEnabled)
@@ -290,6 +297,16 @@ uint32_t enet_mac_configure_fifo_accel(enet_dev_if_t * enetIfPtr)
290297
txFifo.isStoreForwardEnabled = 1;
291298
}
292299

300+
301+
/* Set TFWR value if STRFWD is not being used */
302+
if (txFifo.isStoreForwardEnabled == 1)
303+
txFifo.txFifoWrite = 0;
304+
else
305+
/* TFWR value is a trade-off between transmit latency and risk of transmit FIFO underrun due to contention for the system bus
306+
TFWR = 15 means transmission will begin once 960 bytes has been written to the Tx FIFO (for frames larger than 960 bytes)
307+
See Section 45.4.18 - Transmit FIFO Watermark Register of the K64F Reference Manual for details */
308+
txFifo.txFifoWrite = 15;
309+
293310
/* Configure tx/rx FIFO with default value*/
294311
rxFifo.rxAlmostEmpty = 4;
295312
rxFifo.rxAlmostFull = 4;

0 commit comments

Comments
 (0)