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 RX63N Ethernet MAC...\r\n");
123 nicDriverInterface = interface;
126 SYSTEM.PRCR.WORD = 0xA50B;
130 SYSTEM.PRCR.WORD = 0xA500;
136 EDMAC.EDMR.BIT.SWR = 1;
141 if(interface->phyDriver != NULL)
144 error = interface->phyDriver->init(interface);
146 else if(interface->switchDriver != NULL)
149 error = interface->switchDriver->init(interface);
169 ETHERC.IPGR.LONG = 0x14;
172 ETHERC.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
173 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
176 ETHERC.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
179 EDMAC.EDMR.BIT.DL = 0;
181 #ifdef _CPU_BIG_ENDIAN
183 EDMAC.EDMR.BIT.DE = 0;
186 EDMAC.EDMR.BIT.DE = 1;
190 EDMAC.TFTR.BIT.TFT = 0;
193 EDMAC.FDR.BIT.TFD = 7;
195 EDMAC.FDR.BIT.RFD = 7;
198 EDMAC.RMCR.BIT.RNR = 1;
201 EDMAC.TRIMD.BIT.TIM = 0;
202 EDMAC.TRIMD.BIT.TIS = 1;
205 EDMAC.EESIPR.LONG = 0;
207 EDMAC.EESIPR.BIT.TWBIP = 1;
208 EDMAC.EESIPR.BIT.FRIP = 1;
214 ETHERC.ECMR.BIT.TE = 1;
215 ETHERC.ECMR.BIT.RE = 1;
218 EDMAC.EDRRR.BIT.RR = 1;
235 #if defined(USE_RDK_RX63N)
237 MPC.PWPR.BIT.B0WI = 0;
238 MPC.PWPR.BIT.PFSWE = 1;
241 MPC.PFENET.BIT.PHYMODE = 0;
244 PORTA.PMR.BIT.B3 = 1;
245 MPC.PA3PFS.BYTE = 0x11;
248 PORTA.PMR.BIT.B4 = 1;
249 MPC.PA4PFS.BYTE = 0x11;
252 PORTA.PMR.BIT.B5 = 1;
253 MPC.PA5PFS.BYTE = 0x11;
256 PORTB.PMR.BIT.B0 = 1;
257 MPC.PB0PFS.BYTE = 0x12;
260 PORTB.PMR.BIT.B1 = 1;
261 MPC.PB1PFS.BYTE = 0x12;
264 PORTB.PMR.BIT.B2 = 1;
265 MPC.PB2PFS.BYTE = 0x12;
268 PORTB.PMR.BIT.B3 = 1;
269 MPC.PB3PFS.BYTE = 0x12;
272 PORTB.PMR.BIT.B4 = 1;
273 MPC.PB4PFS.BYTE = 0x12;
276 PORTB.PMR.BIT.B5 = 1;
277 MPC.PB5PFS.BYTE = 0x12;
280 PORTB.PMR.BIT.B6 = 1;
281 MPC.PB6PFS.BYTE = 0x12;
284 PORTB.PMR.BIT.B7 = 1;
285 MPC.PB7PFS.BYTE = 0x12;
288 MPC.PWPR.BIT.PFSWE = 0;
289 MPC.PWPR.BIT.B0WI = 0;
291 #elif defined(USE_RSK_RX63N) || defined(USE_RSK_RX63N_256K)
293 MPC.PWPR.BIT.B0WI = 0;
294 MPC.PWPR.BIT.PFSWE = 1;
297 MPC.PFENET.BIT.PHYMODE = 1;
300 PORT7.PMR.BIT.B1 = 1;
301 MPC.P71PFS.BYTE = 0x11;
304 PORT7.PMR.BIT.B2 = 1;
305 MPC.P72PFS.BYTE = 0x11;
308 PORT7.PMR.BIT.B4 = 1;
309 MPC.P74PFS.BYTE = 0x11;
312 PORT7.PMR.BIT.B5 = 1;
313 MPC.P75PFS.BYTE = 0x11;
316 PORT7.PMR.BIT.B6 = 1;
317 MPC.P76PFS.BYTE = 0x11;
320 PORT7.PMR.BIT.B7 = 1;
321 MPC.P77PFS.BYTE = 0x11;
324 PORT8.PMR.BIT.B0 = 1;
325 MPC.P80PFS.BYTE = 0x11;
328 PORT8.PMR.BIT.B1 = 1;
329 MPC.P81PFS.BYTE = 0x11;
332 PORT8.PMR.BIT.B2 = 1;
333 MPC.P82PFS.BYTE = 0x11;
336 PORT8.PMR.BIT.B3 = 1;
337 MPC.P83PFS.BYTE = 0x11;
340 PORTC.PMR.BIT.B0 = 1;
341 MPC.PC0PFS.BYTE = 0x11;
344 PORTC.PMR.BIT.B1 = 1;
345 MPC.PC1PFS.BYTE = 0x11;
348 PORTC.PMR.BIT.B2 = 1;
349 MPC.PC2PFS.BYTE = 0x11;
352 PORTC.PMR.BIT.B3 = 1;
353 MPC.PC3PFS.BYTE = 0x11;
356 PORTC.PMR.BIT.B4 = 1;
357 MPC.PC4PFS.BYTE = 0x11;
360 PORTC.PMR.BIT.B5 = 1;
361 MPC.PC5PFS.BYTE = 0x11;
364 PORTC.PMR.BIT.B6 = 1;
365 MPC.PC6PFS.BYTE = 0x11;
368 PORTC.PMR.BIT.B7 = 1;
369 MPC.PC7PFS.BYTE = 0x11;
372 MPC.PWPR.BIT.PFSWE = 0;
373 MPC.PWPR.BIT.B0WI = 0;
442 if(interface->phyDriver != NULL)
445 interface->phyDriver->tick(interface);
447 else if(interface->switchDriver != NULL)
450 interface->switchDriver->tick(interface);
467 IEN(ETHER, EINT) = 1;
470 if(interface->phyDriver != NULL)
473 interface->phyDriver->enableIrq(interface);
475 else if(interface->switchDriver != NULL)
478 interface->switchDriver->enableIrq(interface);
495 IEN(ETHER, EINT) = 0;
498 if(interface->phyDriver != NULL)
501 interface->phyDriver->disableIrq(interface);
503 else if(interface->switchDriver != NULL)
506 interface->switchDriver->disableIrq(interface);
519 #pragma vector = VECT_ETHER_EINT
526 __enable_interrupt();
532 status = EDMAC.EESR.LONG;
552 EDMAC.EESIPR.BIT.FRIP = 0;
555 nicDriverInterface->nicEvent =
TRUE;
591 EDMAC.EESIPR.BIT.TWBIP = 1;
592 EDMAC.EESIPR.BIT.FRIP = 1;
654 EDMAC.EDTRR.BIT.TR = 1;
733 EDMAC.EDRRR.BIT.RR = 1;
761 ETHERC.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
762 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
765 ETHERC.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
768 acceptMulticast =
FALSE;
775 if(interface->macAddrFilter[i].refCount > 0)
778 acceptMulticast =
TRUE;
787 EDMAC.EESR.BIT.RMAF = 1;
791 EDMAC.EESR.BIT.RMAF = 0;
810 ETHERC.ECMR.BIT.RTM = 1;
814 ETHERC.ECMR.BIT.RTM = 0;
820 ETHERC.ECMR.BIT.DM = 1;
824 ETHERC.ECMR.BIT.DM = 0;
909 ETHERC.PIR.BIT.MMD = 1;
915 if((
data & 0x80000000) != 0)
917 ETHERC.PIR.BIT.MDO = 1;
921 ETHERC.PIR.BIT.MDO = 0;
926 ETHERC.PIR.BIT.MDC = 1;
929 ETHERC.PIR.BIT.MDC = 0;
948 ETHERC.PIR.BIT.MMD = 0;
957 ETHERC.PIR.BIT.MDC = 1;
960 ETHERC.PIR.BIT.MDC = 0;
964 if(ETHERC.PIR.BIT.MDI != 0)
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
__interrupt void rx63nEthIrqHandler(void)
RX63N Ethernet MAC interrupt service routine.
#define EDMAC_RD0_RFP_EOF
#define RX63N_ETH_RX_BUFFER_SIZE
error_t rx63nEthInit(NetInterface *interface)
RX63N Ethernet MAC initialization.
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
void rx63nEthTick(NetInterface *interface)
RX63N Ethernet MAC timer handler.
void rx63nEthWriteSmi(uint32_t data, uint_t length)
SMI write operation.
#define RX63N_ETH_RX_BUFFER_COUNT
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
error_t rx63nEthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
#define RX63N_ETH_IRQ_PRIORITY
#define EDMAC_RD0_RFP_SOF
uint32_t rx63nEthReadSmi(uint_t length)
SMI read operation.
__weak_func void rx63nEthInitGpio(NetInterface *interface)
GPIO configuration.
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
@ ERROR_FAILURE
Generic error code.
#define EDMAC_RD0_RFS_RMAF
#define EDMAC_RD0_RFS_MASK
#define RX63N_ETH_TX_BUFFER_COUNT
void rx63nEthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
#define EDMAC_TD0_TFP_SOF
void rx63nEthEnableIrq(NetInterface *interface)
Enable interrupts.
error_t rx63nEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
void rx63nEthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
#define RX63N_ETH_TX_BUFFER_SIZE
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
error_t rx63nEthReceivePacket(NetInterface *interface)
Receive a packet.
const NicDriver rx63nEthDriver
RX63N Ethernet MAC driver.
Renesas RX63N Ethernet MAC driver.
error_t rx63nEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
void rx63nEthEventHandler(NetInterface *interface)
RX63N Ethernet MAC event handler.
uint16_t rx63nEthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
#define EDMAC_TD0_TFP_EOF
@ NIC_TYPE_ETHERNET
Ethernet interface.
void rx63nEthDisableIrq(NetInterface *interface)
Disable interrupts.