Go to the documentation of this file.
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
44 #if defined(__ICCARM__)
47 #pragma data_alignment = 4
48 #pragma location = M5531_ETH_RAM_SECTION
51 #pragma data_alignment = 4
52 #pragma location = M5531_ETH_RAM_SECTION
55 #pragma data_alignment = 8
56 #pragma location = M5531_ETH_RAM_SECTION
59 #pragma data_alignment = 8
60 #pragma location = M5531_ETH_RAM_SECTION
123 TRACE_INFO(
"Initializing M5531 Ethernet MAC...\r\n");
126 nicDriverInterface = interface;
132 SYS_ResetModule(SYS_EMAC0RST);
134 CLK_EnableModuleClock(EMAC0_MODULE);
147 if(interface->phyDriver != NULL)
150 error = interface->phyDriver->init(interface);
152 else if(interface->switchDriver != NULL)
155 error = interface->switchDriver->init(interface);
221 #if defined(USE_NUMAKER_X_M55M1D)
223 CLK_EnableModuleClock(GPIOA_MODULE);
224 CLK_EnableModuleClock(GPIOC_MODULE);
225 CLK_EnableModuleClock(GPIOE_MODULE);
228 SET_EMAC0_RMII_RXERR_PA6();
230 SET_EMAC0_RMII_CRSDV_PA7();
232 SET_EMAC0_RMII_RXD1_PC6();
234 SET_EMAC0_RMII_RXD0_PC7();
236 SET_EMAC0_RMII_REFCLK_PC8();
238 SET_EMAC0_RMII_MDC_PE8();
240 SET_EMAC0_RMII_MDIO_PE9();
242 SET_EMAC0_RMII_TXD0_PE10();
244 SET_EMAC0_RMII_TXD1_PE11();
246 SET_EMAC0_RMII_TXEN_PE12();
249 GPIO_SetSlewCtl(PE, BIT10 | BIT11 | BIT12, GPIO_SLEWCTL_FAST1);
331 if(interface->phyDriver != NULL)
334 interface->phyDriver->tick(interface);
336 else if(interface->switchDriver != NULL)
339 interface->switchDriver->tick(interface);
356 NVIC_EnableIRQ(EMAC0_IRQn);
359 if(interface->phyDriver != NULL)
362 interface->phyDriver->enableIrq(interface);
364 else if(interface->switchDriver != NULL)
367 interface->switchDriver->enableIrq(interface);
384 NVIC_DisableIRQ(EMAC0_IRQn);
387 if(interface->phyDriver != NULL)
390 interface->phyDriver->disableIrq(interface);
392 else if(interface->switchDriver != NULL)
395 interface->switchDriver->disableIrq(interface);
443 nicDriverInterface->nicEvent =
TRUE;
639 acceptMulticast =
FALSE;
646 entry = &interface->macAddrFilter[i];
655 acceptMulticast =
TRUE;
663 unicastMacAddr[j++] = entry->
addr;
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
#define EMAC_RECEIVE_DESCRIPTOR_LIST_ADDR
Enhanced TX DMA descriptor.
#define EMAC_BUS_MODE_AAB
#define EMAC_GMII_ADDR_GW
#define EMAC_MAC_ADDR3_HIGH
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Structure describing a buffer that spans multiple chunks.
#define MAC_ADDR_FILTER_SIZE
#define EMAC_OPERATION_MODE_SR
#define EMAC_MAC_ADDR3_HIGH_AE
#define EMAC_MAC_ADDR1_LOW
#define EMAC_GMII_ADDR_CR_DIV_102
uint_t refCount
Reference count for the current entry.
error_t m5531EthInit(NetInterface *interface)
M5531 Ethernet MAC initialization.
Enhanced RX DMA descriptor.
#define EMAC_BUS_MODE_PBL_32
__weak_func void m5531EthInitGpio(NetInterface *interface)
GPIO configuration.
#define EMAC_MAC_CONFIG_RESERVED15
#define EMAC_INTERRUPT_ENABLE_RIE
#define EMAC_INTERRUPT_ENABLE_TIE
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
#define macIsMulticastAddr(macAddr)
#define M5531_ETH_TX_BUFFER_COUNT
#define EMAC_BUS_MODE_RPBL_32
#define M5531_ETH_IRQ_SUB_PRIORITY
#define EMAC_INTERRUPT_MASK
#define EMAC_MAC_CONFIG_FES
#define EMAC_OPERATION_MODE_ST
#define EMAC_FLOW_CONTROL
void m5531EthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
#define EMAC_INTERRUPT_MASK_TSIM
error_t m5531EthReceivePacket(NetInterface *interface)
Receive a packet.
#define EMAC_INTERRUPT_ENABLE_NIE
#define EMAC_MAC_FRAME_FILTER_PM
#define M5531_ETH_IRQ_GROUP_PRIORITY
#define EMAC_GMII_DATA_GD
void m5531EthEventHandler(NetInterface *interface)
M5531 Ethernet MAC event handler.
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
@ ERROR_FAILURE
Generic error code.
void EMAC0_IRQHandler(void)
M5531 Ethernet MAC interrupt service routine.
error_t m5531EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
#define EMAC_MAC_ADDR2_HIGH
#define EMAC_MAC_CONFIG_RE
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
#define EMAC_INTERRUPT_ENABLE
#define EMAC_GMII_ADDR_PA
void m5531EthDisableIrq(NetInterface *interface)
Disable interrupts.
#define EMAC_MAC_CONFIG_DO
#define EMAC_BUS_MODE_ATDS
#define EMAC_OPERATION_MODE_TSF
#define EMAC_MAC_ADDR2_LOW
#define EMAC_MAC_ADDR3_LOW
#define EMAC_GMII_ADDR_GR
#define EMAC_MAC_CONFIG_DM
#define EMAC_RECEIVE_POLL_DEMAND
#define EMAC_GMII_ADDR_GB
#define EMAC_TRANSMIT_DESCRIPTOR_LIST_ADDR
const NicDriver m5531EthDriver
M5531 Ethernet MAC driver.
#define EMAC_MAC_ADDR0_LOW
#define EMAC_GMII_ADDR_CR
#define M5531_ETH_IRQ_PRIORITY_GROUPING
error_t m5531EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
#define EMAC_MAC_FRAME_FILTER
#define EMAC_MAC_ADDR1_HIGH_AE
#define EMAC_OPERATION_MODE_RSF
#define EMAC_TRANSMIT_POLL_DEMAND
#define EMAC_BUS_MODE_USP
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define EMAC_MAC_CONFIG_TE
#define M5531_ETH_RX_BUFFER_SIZE
Nuvoton M5531 Ethernet MAC driver.
void m5531EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define EMAC_OPERATION_MODE
#define EMAC_BUS_MODE_SWR
#define M5531_ETH_RX_BUFFER_COUNT
void m5531EthTick(NetInterface *interface)
M5531 Ethernet MAC timer handler.
#define EMAC_INTERRUPT_MASK_PMTIM
#define M5531_ETH_TX_BUFFER_SIZE
#define EMAC_MAC_ADDR2_HIGH_AE
const MacAddr MAC_UNSPECIFIED_ADDR
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
#define EMAC_MAC_ADDR1_HIGH
error_t m5531EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
uint16_t m5531EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
void m5531EthEnableIrq(NetInterface *interface)
Enable interrupts.
@ NIC_TYPE_ETHERNET
Ethernet interface.
#define EMAC_MAC_ADDR0_HIGH
#define M5531_ETH_RAM_SECTION