Go to the documentation of this file.
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
36 #include <intrinsics.h>
45 #if defined(__ICCRX__)
48 #pragma data_alignment = 32
51 #pragma data_alignment = 32
54 #pragma data_alignment = 32
57 #pragma data_alignment = 32
120 TRACE_INFO(
"Initializing RX62N Ethernet MAC...\r\n");
123 nicDriverInterface = interface;
132 EDMAC.EDMR.BIT.SWR = 1;
137 if(interface->phyDriver != NULL)
140 error = interface->phyDriver->init(interface);
142 else if(interface->switchDriver != NULL)
145 error = interface->switchDriver->init(interface);
165 ETHERC.IPGR.LONG = 0x14;
168 ETHERC.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
169 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
172 ETHERC.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
175 EDMAC.EDMR.BIT.DL = 0;
177 #ifdef _CPU_BIG_ENDIAN
179 EDMAC.EDMR.BIT.DE = 0;
182 EDMAC.EDMR.BIT.DE = 1;
186 EDMAC.TFTR.BIT.TFT = 0;
189 EDMAC.FDR.BIT.TFD = 7;
191 EDMAC.FDR.BIT.RFD = 7;
194 EDMAC.RMCR.BIT.RNR = 1;
197 EDMAC.TRIMD.BIT.TIM = 0;
198 EDMAC.TRIMD.BIT.TIS = 1;
201 EDMAC.EESIPR.LONG = 0;
203 EDMAC.EESIPR.BIT.TWBIP = 1;
204 EDMAC.EESIPR.BIT.FRIP = 1;
210 ETHERC.ECMR.BIT.TE = 1;
211 ETHERC.ECMR.BIT.RE = 1;
214 EDMAC.EDRRR.BIT.RR = 1;
232 #if defined(USE_RDK_RX62N)
234 IOPORT.PFENET.BIT.PHYMODE = 0;
237 IOPORT.PFENET.BIT.EE = 1;
239 IOPORT.PFENET.BIT.ENETE0 = 0;
241 IOPORT.PFENET.BIT.ENETE1 = 1;
243 IOPORT.PFENET.BIT.ENETE2 = 0;
245 IOPORT.PFENET.BIT.ENETE3 = 0;
248 PORTA.ICR.BIT.B3 = 1;
250 PORTA.ICR.BIT.B5 = 1;
252 PORTB.ICR.BIT.B0 = 1;
254 PORTB.ICR.BIT.B1 = 1;
256 PORTB.ICR.BIT.B2 = 1;
258 PORTB.ICR.BIT.B3 = 1;
260 PORTB.ICR.BIT.B7 = 1;
329 if(interface->phyDriver != NULL)
332 interface->phyDriver->tick(interface);
334 else if(interface->switchDriver != NULL)
337 interface->switchDriver->tick(interface);
354 IEN(ETHER, EINT) = 1;
357 if(interface->phyDriver != NULL)
360 interface->phyDriver->enableIrq(interface);
362 else if(interface->switchDriver != NULL)
365 interface->switchDriver->enableIrq(interface);
382 IEN(ETHER, EINT) = 0;
385 if(interface->phyDriver != NULL)
388 interface->phyDriver->disableIrq(interface);
390 else if(interface->switchDriver != NULL)
393 interface->switchDriver->disableIrq(interface);
406 #pragma vector = VECT_ETHER_EINT
413 __enable_interrupt();
419 status = EDMAC.EESR.LONG;
439 EDMAC.EESIPR.BIT.FRIP = 0;
442 nicDriverInterface->nicEvent =
TRUE;
478 EDMAC.EESIPR.BIT.TWBIP = 1;
479 EDMAC.EESIPR.BIT.FRIP = 1;
541 EDMAC.EDTRR.BIT.TR = 1;
620 EDMAC.EDRRR.BIT.RR = 1;
648 ETHERC.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
649 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
652 ETHERC.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
655 acceptMulticast =
FALSE;
662 if(interface->macAddrFilter[i].refCount > 0)
665 acceptMulticast =
TRUE;
674 EDMAC.EESR.BIT.RMAF = 1;
678 EDMAC.EESR.BIT.RMAF = 0;
697 ETHERC.ECMR.BIT.RTM = 1;
701 ETHERC.ECMR.BIT.RTM = 0;
707 ETHERC.ECMR.BIT.DM = 1;
711 ETHERC.ECMR.BIT.DM = 0;
796 ETHERC.PIR.BIT.MMD = 1;
802 if((
data & 0x80000000) != 0)
804 ETHERC.PIR.BIT.MDO = 1;
808 ETHERC.PIR.BIT.MDO = 0;
813 ETHERC.PIR.BIT.MDC = 1;
816 ETHERC.PIR.BIT.MDC = 0;
835 ETHERC.PIR.BIT.MMD = 0;
844 ETHERC.PIR.BIT.MDC = 1;
847 ETHERC.PIR.BIT.MDC = 0;
851 if(ETHERC.PIR.BIT.MDI != 0)
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
#define EDMAC_RD0_RFP_EOF
error_t rx62nEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
#define RX62N_ETH_IRQ_PRIORITY
error_t rx62nEthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Renesas RX62N Ethernet MAC driver.
Structure describing a buffer that spans multiple chunks.
#define MAC_ADDR_FILTER_SIZE
void rx62nEthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
#define RX62N_ETH_RX_BUFFER_COUNT
#define RX62N_ETH_TX_BUFFER_SIZE
uint16_t rx62nEthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
#define EDMAC_RD0_RFP_SOF
#define RX62N_ETH_RX_BUFFER_SIZE
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
@ ERROR_FAILURE
Generic error code.
#define EDMAC_RD0_RFS_RMAF
void rx62nEthDisableIrq(NetInterface *interface)
Disable interrupts.
#define EDMAC_RD0_RFS_MASK
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
uint32_t rx62nEthReadSmi(uint_t length)
SMI read operation.
void rx62nEthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define EDMAC_TD0_TFP_SOF
__interrupt void rx62nEthIrqHandler(void)
RX62N Ethernet MAC interrupt service routine.
const NicDriver rx62nEthDriver
RX62N Ethernet MAC driver.
void rx62nEthEnableIrq(NetInterface *interface)
Enable interrupts.
error_t rx62nEthReceivePacket(NetInterface *interface)
Receive a packet.
void rx62nEthEventHandler(NetInterface *interface)
RX62N Ethernet MAC event handler.
#define RX62N_ETH_TX_BUFFER_COUNT
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
error_t rx62nEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
void rx62nEthTick(NetInterface *interface)
RX62N Ethernet MAC timer handler.
error_t rx62nEthInit(NetInterface *interface)
RX62N Ethernet MAC initialization.
void rx62nEthWriteSmi(uint32_t data, uint_t length)
SMI write operation.
__weak_func void rx62nEthInitGpio(NetInterface *interface)
GPIO configuration.
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
#define EDMAC_TD0_TFP_EOF
@ NIC_TYPE_ETHERNET
Ethernet interface.