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 RX65N Ethernet MAC...\r\n");
123 nicDriverInterface = interface;
126 SYSTEM.PRCR.WORD = 0xA50B;
130 SYSTEM.PRCR.WORD = 0xA500;
136 EDMAC0.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 ETHERC0.IPGR.LONG = 0x14;
172 ETHERC0.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
173 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
176 ETHERC0.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
179 EDMAC0.EDMR.BIT.DL = 0;
181 #ifdef _CPU_BIG_ENDIAN
183 EDMAC0.EDMR.BIT.DE = 0;
186 EDMAC0.EDMR.BIT.DE = 1;
190 EDMAC0.TFTR.BIT.TFT = 0;
193 EDMAC0.FDR.BIT.TFD = 7;
195 EDMAC0.FDR.BIT.RFD = 7;
198 EDMAC0.RMCR.BIT.RNR = 1;
201 EDMAC0.TRIMD.BIT.TIM = 0;
202 EDMAC0.TRIMD.BIT.TIS = 1;
205 EDMAC0.EESIPR.LONG = 0;
207 EDMAC0.EESIPR.BIT.TWBIP = 1;
208 EDMAC0.EESIPR.BIT.FRIP = 1;
211 ICU.GENAL1.BIT.EN_EDMAC0_EINT0 = 1;
216 ETHERC0.ECMR.BIT.TE = 1;
217 ETHERC0.ECMR.BIT.RE = 1;
220 EDMAC0.EDRRR.BIT.RR = 1;
238 #if defined(USE_RSK_RX65N) || defined(USE_RSK_RX65N_2M)
240 MPC.PWPR.BIT.B0WI = 0;
241 MPC.PWPR.BIT.PFSWE = 1;
244 MPC.PFENET.BIT.PHYMODE0 = 1;
247 PORT7.PMR.BIT.B1 = 1;
248 MPC.P71PFS.BYTE = 0x11;
251 PORT7.PMR.BIT.B2 = 1;
252 MPC.P72PFS.BYTE = 0x11;
255 PORT7.PMR.BIT.B4 = 1;
256 MPC.P74PFS.BYTE = 0x11;
259 PORT7.PMR.BIT.B5 = 1;
260 MPC.P75PFS.BYTE = 0x11;
263 PORT7.PMR.BIT.B6 = 1;
264 MPC.P76PFS.BYTE = 0x11;
267 PORT7.PMR.BIT.B7 = 1;
268 MPC.P77PFS.BYTE = 0x11;
271 PORT8.PMR.BIT.B0 = 1;
272 MPC.P80PFS.BYTE = 0x11;
275 PORT8.PMR.BIT.B1 = 1;
276 MPC.P81PFS.BYTE = 0x11;
279 PORT8.PMR.BIT.B2 = 1;
280 MPC.P82PFS.BYTE = 0x11;
283 PORT8.PMR.BIT.B3 = 1;
284 MPC.P83PFS.BYTE = 0x11;
287 PORTC.PMR.BIT.B0 = 1;
288 MPC.PC0PFS.BYTE = 0x11;
291 PORTC.PMR.BIT.B1 = 1;
292 MPC.PC1PFS.BYTE = 0x11;
295 PORTC.PMR.BIT.B2 = 1;
296 MPC.PC2PFS.BYTE = 0x11;
299 PORTC.PMR.BIT.B3 = 1;
300 MPC.PC3PFS.BYTE = 0x11;
303 PORTC.PMR.BIT.B4 = 1;
304 MPC.PC4PFS.BYTE = 0x11;
307 PORTC.PMR.BIT.B5 = 1;
308 MPC.PC5PFS.BYTE = 0x11;
311 PORTC.PMR.BIT.B6 = 1;
312 MPC.PC6PFS.BYTE = 0x11;
315 PORTC.PMR.BIT.B7 = 1;
316 MPC.PC7PFS.BYTE = 0x11;
319 MPC.PWPR.BIT.PFSWE = 0;
320 MPC.PWPR.BIT.B0WI = 0;
389 if(interface->phyDriver != NULL)
392 interface->phyDriver->tick(interface);
394 else if(interface->switchDriver != NULL)
397 interface->switchDriver->tick(interface);
414 IEN(ICU, GROUPAL1) = 1;
417 if(interface->phyDriver != NULL)
420 interface->phyDriver->enableIrq(interface);
422 else if(interface->switchDriver != NULL)
425 interface->switchDriver->enableIrq(interface);
442 IEN(ICU, GROUPAL1) = 0;
445 if(interface->phyDriver != NULL)
448 interface->phyDriver->disableIrq(interface);
450 else if(interface->switchDriver != NULL)
453 interface->switchDriver->disableIrq(interface);
472 __enable_interrupt();
478 status = EDMAC0.EESR.LONG;
498 EDMAC0.EESIPR.BIT.FRIP = 0;
501 nicDriverInterface->nicEvent =
TRUE;
537 EDMAC0.EESIPR.BIT.TWBIP = 1;
538 EDMAC0.EESIPR.BIT.FRIP = 1;
600 EDMAC0.EDTRR.BIT.TR = 1;
679 EDMAC0.EDRRR.BIT.RR = 1;
707 ETHERC0.MAHR = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
708 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
711 ETHERC0.MALR.BIT.MA = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
714 acceptMulticast =
FALSE;
721 if(interface->macAddrFilter[i].refCount > 0)
724 acceptMulticast =
TRUE;
733 EDMAC0.EESR.BIT.RMAF = 1;
737 EDMAC0.EESR.BIT.RMAF = 0;
756 ETHERC0.ECMR.BIT.RTM = 1;
760 ETHERC0.ECMR.BIT.RTM = 0;
766 ETHERC0.ECMR.BIT.DM = 1;
770 ETHERC0.ECMR.BIT.DM = 0;
855 ETHERC0.PIR.BIT.MMD = 1;
861 if((
data & 0x80000000) != 0)
863 ETHERC0.PIR.BIT.MDO = 1;
867 ETHERC0.PIR.BIT.MDO = 0;
872 ETHERC0.PIR.BIT.MDC = 1;
875 ETHERC0.PIR.BIT.MDC = 0;
894 ETHERC0.PIR.BIT.MMD = 0;
903 ETHERC0.PIR.BIT.MDC = 1;
906 ETHERC0.PIR.BIT.MDC = 0;
910 if(ETHERC0.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
__weak_func void rx65nEthInitGpio(NetInterface *interface)
GPIO configuration.
#define RX65N_ETH_TX_BUFFER_COUNT
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
const NicDriver rx65nEthDriver
RX65N Ethernet MAC driver.
void rx65nEthTick(NetInterface *interface)
RX65N Ethernet MAC timer handler.
Structure describing a buffer that spans multiple chunks.
#define MAC_ADDR_FILTER_SIZE
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
void rx65nEthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define RX65N_ETH_IRQ_PRIORITY
void rx65nEthWriteSmi(uint32_t data, uint_t length)
SMI write operation.
void rx65nEthEnableIrq(NetInterface *interface)
Enable interrupts.
Renesas RX65N Ethernet MAC driver.
#define EDMAC_RD0_RFP_SOF
uint16_t rx65nEthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
void rx65nEthEventHandler(NetInterface *interface)
RX65N Ethernet MAC event handler.
@ ERROR_FAILURE
Generic error code.
void rx65nEthDisableIrq(NetInterface *interface)
Disable interrupts.
#define EDMAC_RD0_RFS_RMAF
#define EDMAC_RD0_RFS_MASK
error_t rx65nEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
error_t rx65nEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
void rx65nEthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
#define EDMAC_TD0_TFP_SOF
uint32_t rx65nEthReadSmi(uint_t length)
SMI read operation.
#define RX65N_ETH_RX_BUFFER_COUNT
error_t rx65nEthInit(NetInterface *interface)
RX65N Ethernet MAC initialization.
#define RX65N_ETH_RX_BUFFER_SIZE
error_t rx65nEthReceivePacket(NetInterface *interface)
Receive a packet.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define RX65N_ETH_TX_BUFFER_SIZE
error_t rx65nEthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
void rx65nEthIrqHandler(void)
RX65N Ethernet MAC interrupt service routine.
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
#define EDMAC_TD0_TFP_EOF
@ NIC_TYPE_ETHERNET
Ethernet interface.