From 42103f089dfe09b7d366fc6188f141fa6e72e1db Mon Sep 17 00:00:00 2001 From: cyliangtw Date: Tue, 10 Dec 2019 10:40:03 +0800 Subject: [PATCH] Correct the definition of M487/NUC472 EMAC NU_ETH_MAX_FLEN & PACKET_BUFFER_SIZE --- .../emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c | 2 +- .../emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.h | 2 +- .../emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c | 2 +- .../emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.h | 2 +- .../netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac.cpp | 2 +- .../emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac_config.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c index 5bb093237c3..67883619a32 100644 --- a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c +++ b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.c @@ -263,7 +263,7 @@ void numaker_eth_init(uint8_t *mac_addr) EMAC->CAMEN = 1; // Enable CAM entry 0 /* Limit the max receive frame length to 1514 + 4 */ - EMAC->MRFL = 1518; + EMAC->MRFL = NU_ETH_MAX_FLEN; reset_phy(); EMAC_ENABLE_RX(); diff --git a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.h b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.h index 6661c351999..9a1be26de9a 100644 --- a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.h +++ b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_M480/m480_eth.h @@ -85,7 +85,7 @@ #define RX_DESCRIPTOR_NUM NU_RX_RING_LEN//4 //2 // 4: Max Number of Rx Frame Descriptors #define TX_DESCRIPTOR_NUM NU_TX_RING_LEN//4 //2 // 4: Max number of Tx Frame Descriptors -#define PACKET_BUFFER_SIZE NU_ETH_MAX_FLEN//1520 +#define PACKET_BUFFER_SIZE ( NU_ETH_MAX_FLEN + ((NU_ETH_MAX_FLEN%4) ? (4 - (NU_ETH_MAX_FLEN%4)) : 0) ) //For DMA 4 bytes alignment #define CONFIG_PHY_ADDR 1 diff --git a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c index f7f3f50830e..3b6bbf270f8 100644 --- a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c +++ b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.c @@ -230,7 +230,7 @@ void numaker_eth_init(uint8_t *mac_addr) numaker_set_mac_addr(mac_addr); // need to reconfigure hardware address 'cos we just RESET emc... /* Limit the max receive frame length to 1514 + 4 */ - EMAC->MRFL = 1518; + EMAC->MRFL = NU_ETH_MAX_FLEN; reset_phy(); EMAC->CTL |= EMAC_CTL_STRIPCRC_Msk | EMAC_CTL_RXON_Msk | EMAC_CTL_TXON_Msk | EMAC_CTL_RMIIEN_Msk | EMAC_CTL_RMIIRXCTL_Msk; diff --git a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.h b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.h index 267ec070ef8..1766b03cf89 100644 --- a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.h +++ b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/TARGET_NUC472/nuc472_eth.h @@ -84,7 +84,7 @@ #define RX_DESCRIPTOR_NUM NU_RX_RING_LEN//4 //2 // 4: Max Number of Rx Frame Descriptors #define TX_DESCRIPTOR_NUM NU_TX_RING_LEN//4 //2 // 4: Max number of Tx Frame Descriptors -#define PACKET_BUFFER_SIZE NU_ETH_MAX_FLEN//1520 +#define PACKET_BUFFER_SIZE ( NU_ETH_MAX_FLEN + ((NU_ETH_MAX_FLEN%4) ? (4 - (NU_ETH_MAX_FLEN%4)) : 0) ) //For DMA 4 bytes alignment #define CONFIG_PHY_ADDR 1 diff --git a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac.cpp b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac.cpp index 1fa47510cb3..7e7af3ed66b 100644 --- a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac.cpp +++ b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac.cpp @@ -42,7 +42,7 @@ #define NU_BUFF_ALIGNMENT 4 #define PHY_LINKED_STATE 1 #define PHY_UNLINKED_STATE 0 -#define PACKET_BUFFER_SIZE NU_ETH_MAX_FLEN +#define PACKET_BUFFER_SIZE ( NU_ETH_MAX_FLEN + ((NU_ETH_MAX_FLEN%4) ? (4 - (NU_ETH_MAX_FLEN%4)) : 0) ) //For DMA 4 bytes alignment extern "C" void numaker_eth_rx_next(void); /* \brief Flags for worker thread */ diff --git a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac_config.h b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac_config.h index cf52f351c4f..7bb83c3646f 100644 --- a/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac_config.h +++ b/features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac_config.h @@ -22,7 +22,7 @@ #define NU_RX_RING_LEN (8) #define NU_TX_RING_LEN (4) -#define NU_ETH_MAX_FLEN (1520) +#define NU_ETH_MAX_FLEN (1518) #define NU_HWADDR_SIZE (6)