Go to the documentation of this file.
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
44 #if defined(__ICCARM__)
47 #pragma data_alignment = 4
50 #pragma data_alignment = 4
53 #pragma data_alignment = 4
56 #pragma data_alignment = 4
119 TRACE_INFO(
"Initializing M467 Ethernet MAC...\r\n");
122 nicDriverInterface = interface;
128 SYS_ResetModule(EMAC0_RST);
130 CLK_EnableModuleClock(EMAC0_MODULE);
143 if(interface->phyDriver != NULL)
146 error = interface->phyDriver->init(interface);
148 else if(interface->switchDriver != NULL)
151 error = interface->switchDriver->init(interface);
217 #if defined(USE_NUMAKER_IOT_M467)
221 CLK->AHBCLK0 |= CLK_AHBCLK0_GPACKEN_Msk;
222 CLK->AHBCLK0 |= CLK_AHBCLK0_GPCCKEN_Msk;
223 CLK->AHBCLK0 |= CLK_AHBCLK0_GPECKEN_Msk;
226 SET_EMAC0_RMII_RXERR_PA6();
228 SET_EMAC0_RMII_CRSDV_PA7();
230 SET_EMAC0_RMII_RXD1_PC6();
232 SET_EMAC0_RMII_RXD0_PC7();
234 SET_EMAC0_RMII_REFCLK_PC8();
236 SET_EMAC0_RMII_MDC_PE8();
238 SET_EMAC0_RMII_MDIO_PE9();
240 SET_EMAC0_RMII_TXD0_PE10();
242 SET_EMAC0_RMII_TXD1_PE11();
244 SET_EMAC0_RMII_TXEN_PE12();
248 temp = (temp & ~GPIO_SLEWCTL_HSREN10_Msk) | (GPIO_SLEWCTL_HIGH << GPIO_SLEWCTL_HSREN10_Pos);
249 temp = (temp & ~GPIO_SLEWCTL_HSREN11_Msk) | (GPIO_SLEWCTL_HIGH << GPIO_SLEWCTL_HSREN11_Pos);
250 temp = (temp & ~GPIO_SLEWCTL_HSREN12_Msk) | (GPIO_SLEWCTL_HIGH << GPIO_SLEWCTL_HSREN11_Pos);
333 if(interface->phyDriver != NULL)
336 interface->phyDriver->tick(interface);
338 else if(interface->switchDriver != NULL)
341 interface->switchDriver->tick(interface);
358 NVIC_EnableIRQ(EMAC0_TXRX_IRQn);
361 if(interface->phyDriver != NULL)
364 interface->phyDriver->enableIrq(interface);
366 else if(interface->switchDriver != NULL)
369 interface->switchDriver->enableIrq(interface);
386 NVIC_DisableIRQ(EMAC0_TXRX_IRQn);
389 if(interface->phyDriver != NULL)
392 interface->phyDriver->disableIrq(interface);
394 else if(interface->switchDriver != NULL)
397 interface->switchDriver->disableIrq(interface);
445 nicDriverInterface->nicEvent =
TRUE;
638 acceptMulticast =
FALSE;
645 entry = &interface->macAddrFilter[i];
654 acceptMulticast =
TRUE;
662 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
void m467EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
void EMAC0_IRQHandler(void)
M467 Ethernet MAC interrupt service routine.
#define EMAC_BUS_MODE_AAB
#define EMAC_BUS_MODE_PBL_1
#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 M467_ETH_TX_BUFFER_COUNT
#define EMAC_GMII_ADDR_CR_DIV_102
uint_t refCount
Reference count for the current entry.
error_t m467EthInit(NetInterface *interface)
M467 Ethernet MAC initialization.
const NicDriver m467EthDriver
M467 Ethernet MAC driver.
#define EMAC_INTERRUPT_ENABLE_RIE
uint16_t m467EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
#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)
error_t m467EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
Nuvoton M467 Ethernet MAC driver.
error_t m467EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
#define EMAC_INTERRUPT_MASK
#define EMAC_MAC_CONFIG_FES
#define EMAC_OPERATION_MODE_ST
#define EMAC_FLOW_CONTROL
#define EMAC_INTERRUPT_MASK_TSIM
#define EMAC_INTERRUPT_ENABLE_NIE
#define M467_ETH_IRQ_GROUP_PRIORITY
#define EMAC_MAC_FRAME_FILTER_PM
#define EMAC_GMII_DATA_GD
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
@ ERROR_FAILURE
Generic error code.
#define M467_ETH_IRQ_PRIORITY_GROUPING
error_t m467EthReceivePacket(NetInterface *interface)
Receive a packet.
#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
#define M467_ETH_TX_BUFFER_SIZE
#define EMAC_MAC_CONFIG_DO
Enhanced RX DMA descriptor.
#define EMAC_BUS_MODE_ATDS
#define EMAC_OPERATION_MODE_TSF
#define EMAC_MAC_ADDR2_LOW
#define EMAC_MAC_ADDR3_LOW
void m467EthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
#define EMAC_GMII_ADDR_GR
#define EMAC_MAC_CONFIG_DM
#define EMAC_RECEIVE_POLL_DEMAND
void m467EthTick(NetInterface *interface)
M467 Ethernet MAC timer handler.
#define EMAC_GMII_ADDR_GB
#define EMAC_TRANSMIT_DESCRIPTOR_LIST_ADDR
#define EMAC_MAC_ADDR0_LOW
#define EMAC_GMII_ADDR_CR
void m467EthEnableIrq(NetInterface *interface)
Enable interrupts.
#define M467_ETH_RX_BUFFER_SIZE
#define EMAC_MAC_FRAME_FILTER
#define EMAC_MAC_ADDR1_HIGH_AE
#define EMAC_OPERATION_MODE_RSF
#define EMAC_TRANSMIT_POLL_DEMAND
#define M467_ETH_RX_BUFFER_COUNT
Enhanced TX DMA descriptor.
#define EMAC_BUS_MODE_USP
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define EMAC_MAC_CONFIG_TE
error_t m467EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
#define EMAC_OPERATION_MODE
#define EMAC_BUS_MODE_SWR
#define M467_ETH_IRQ_SUB_PRIORITY
void m467EthEventHandler(NetInterface *interface)
M467 Ethernet MAC event handler.
#define EMAC_INTERRUPT_MASK_PMTIM
__weak_func void m467EthInitGpio(NetInterface *interface)
GPIO configuration.
#define EMAC_MAC_ADDR2_HIGH_AE
const MacAddr MAC_UNSPECIFIED_ADDR
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
#define EMAC_MAC_ADDR1_HIGH
void m467EthDisableIrq(NetInterface *interface)
Disable interrupts.
@ NIC_TYPE_ETHERNET
Ethernet interface.
#define EMAC_MAC_ADDR0_HIGH
#define EMAC_BUS_MODE_RPBL_1