32 #define TRACE_LEVEL NIC_TRACE_LEVEL
45 #if defined(__ICCARM__)
48 #pragma data_alignment = 8
49 #pragma location = PIC32CZ_ETH_RAM_SECTION
52 #pragma data_alignment = 8
53 #pragma location = PIC32CZ_ETH_RAM_SECTION
56 #pragma data_alignment = 8
57 #pragma location = PIC32CZ_ETH_RAM_SECTION
60 #pragma data_alignment = 8
61 #pragma location = PIC32CZ_ETH_RAM_SECTION
65 #pragma data_alignment = 8
66 #pragma location = PIC32CZ_ETH_RAM_SECTION
69 #pragma data_alignment = 8
70 #pragma location = PIC32CZ_ETH_RAM_SECTION
73 #pragma data_alignment = 8
74 #pragma location = PIC32CZ_ETH_RAM_SECTION
77 #pragma data_alignment = 8
78 #pragma location = PIC32CZ_ETH_RAM_SECTION
113 static uint_t txBufferIndex;
115 static uint_t rxBufferIndex;
152 volatile uint32_t status;
155 TRACE_INFO(
"Initializing PIC32CZ Ethernet MAC...\r\n");
158 nicDriverInterface = interface;
161 GCLK_REGS->GCLK_PCHCTRL[ETH_GCLK_ID_TX] = GCLK_PCHCTRL_GEN_GCLK2 |
162 GCLK_PCHCTRL_CHEN_Msk;
165 while((GCLK_REGS->GCLK_PCHCTRL[ETH_GCLK_ID_TX] & GCLK_PCHCTRL_CHEN_Msk) == 0)
170 GCLK_REGS->GCLK_PCHCTRL[ETH_GCLK_ID_TSU] = GCLK_PCHCTRL_GEN_GCLK2 |
171 GCLK_PCHCTRL_CHEN_Msk;
174 while((GCLK_REGS->GCLK_PCHCTRL[ETH_GCLK_ID_TSU] & GCLK_PCHCTRL_CHEN_Msk) == 0)
179 MCLK_REGS->MCLK_CLKMSK[ETH_MCLK_ID_APB / 32] |= (1U << (ETH_MCLK_ID_APB % 32));
180 MCLK_REGS->MCLK_CLKMSK[ETH_MCLK_ID_AXI / 32] |= (1U << (ETH_MCLK_ID_AXI % 32));
183 ETH_REGS->ETH_CTRLA = ETH_CTRLA_ENABLE_Msk;
186 while(ETH_REGS->ETH_SYNCB != 0)
191 ETH_REGS->ETH_NCR = 0;
197 ETH_REGS->ETH_NCFGR = ETH_NCFGR_DBW(1) | ETH_NCFGR_CLK(6);
199 ETH_REGS->ETH_NCR |= ETH_NCR_MPE_Msk;
202 if(interface->phyDriver != NULL)
205 error = interface->phyDriver->init(interface);
207 else if(interface->switchDriver != NULL)
210 error = interface->switchDriver->init(interface);
225 ETH_REGS->SA[0].ETH_SAB = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
226 ETH_REGS->SA[0].ETH_SAT = interface->macAddr.w[2];
229 ETH_REGS->SA[1].ETH_SAB = 0;
230 ETH_REGS->SA[2].ETH_SAB = 0;
231 ETH_REGS->SA[3].ETH_SAB = 0;
234 ETH_REGS->ETH_HRB = 0;
235 ETH_REGS->ETH_HRT = 0;
238 ETH_REGS->ETH_NCFGR |= ETH_NCFGR_MAXFS_Msk | ETH_NCFGR_MTIHEN_Msk;
242 ETH_DCFGR_TXPBMS_Msk | ETH_DCFGR_RXBMS(3) | ETH_DCFGR_FBLDO(4);
254 ETH_REGS->ETH_TSR = ETH_TSR_HRESP_Msk | ETH_TSR_UND_Msk |
255 ETH_TSR_TXCOMP_Msk | ETH_TSR_TFC_Msk | ETH_TSR_TXGO_Msk |
256 ETH_TSR_RLE_Msk | ETH_TSR_COL_Msk | ETH_TSR_UBR_Msk;
259 ETH_REGS->ETH_RSR = ETH_RSR_HNO_Msk | ETH_RSR_RXOVR_Msk |
260 ETH_RSR_REC_Msk | ETH_RSR_BNA_Msk;
263 ETH_REGS->ETH_IDR = 0xFFFFFFFF;
264 ETH_REGS->ETH_IDRQ[0] = 0xFFFFFFFF;
265 ETH_REGS->ETH_IDRQ[1] = 0xFFFFFFFF;
266 ETH_REGS->ETH_IDRQ[2] = 0xFFFFFFFF;
267 ETH_REGS->ETH_IDRQ[3] = 0xFFFFFFFF;
268 ETH_REGS->ETH_IDRQ[4] = 0xFFFFFFFF;
271 ETH_REGS->ETH_IER = ETH_IER_HRESP_Msk | ETH_IER_ROVR_Msk |
272 ETH_IER_TCOMP_Msk | ETH_IER_TFC_Msk | ETH_IER_RLEX_Msk |
273 ETH_IER_TUR_Msk | ETH_IER_RXUBR_Msk | ETH_IER_RCOMP_Msk;
276 status = ETH_REGS->ETH_ISR;
277 status = ETH_REGS->ETH_ISRQ[0];
278 status = ETH_REGS->ETH_ISRQ[1];
279 status = ETH_REGS->ETH_ISRQ[2];
280 status = ETH_REGS->ETH_ISRQ[3];
281 status = ETH_REGS->ETH_ISRQ[4];
292 ETH_REGS->ETH_NCR |= ETH_NCR_TXEN_Msk | ETH_NCR_RXEN_Msk;
310 #if defined(USE_PIC32CZ_CA80_CURIOSITY_ULTRA) || \
311 defined(USE_PIC32CZ_CA90_CURIOSITY_ULTRA)
315 MCLK_REGS->MCLK_CLKMSK[PORT_MCLK_ID_APB / 32] |= (1U << (PORT_MCLK_ID_APB % 32));
316 MCLK_REGS->MCLK_CLKMSK[PORT_MCLK_ID_AHB / 32] |= (1U << (PORT_MCLK_ID_AHB % 32));
319 PORT_REGS->GROUP[0].PORT_PINCFG[0] |= PORT_PINCFG_PMUXEN_Msk;
320 temp = PORT_REGS->GROUP[0].PORT_PMUX[0] & ~PORT_PMUX_PMUXE_Msk;
321 PORT_REGS->GROUP[0].PORT_PMUX[0] = temp | PORT_PMUX_PMUXE(MUX_PA00K_ETH_TXD1);
324 PORT_REGS->GROUP[0].PORT_PINCFG[1] |= PORT_PINCFG_PMUXEN_Msk;
325 temp = PORT_REGS->GROUP[0].PORT_PMUX[0] & ~PORT_PMUX_PMUXO_Msk;
326 PORT_REGS->GROUP[0].PORT_PMUX[0] = temp | PORT_PMUX_PMUXO(MUX_PA01K_ETH_TXD0);
329 PORT_REGS->GROUP[0].PORT_PINCFG[2] |= PORT_PINCFG_PMUXEN_Msk;
330 temp = PORT_REGS->GROUP[0].PORT_PMUX[1] & ~PORT_PMUX_PMUXE_Msk;
331 PORT_REGS->GROUP[0].PORT_PMUX[1] = temp | PORT_PMUX_PMUXE(MUX_PA02K_ETH_TXEN);
334 PORT_REGS->GROUP[0].PORT_PINCFG[3] |= PORT_PINCFG_PMUXEN_Msk;
335 temp = PORT_REGS->GROUP[0].PORT_PMUX[1] & ~PORT_PMUX_PMUXO_Msk;
336 PORT_REGS->GROUP[0].PORT_PMUX[1] = temp | PORT_PMUX_PMUXO(MUX_PA03K_ETH_MDC);
339 PORT_REGS->GROUP[0].PORT_PINCFG[4] |= PORT_PINCFG_PMUXEN_Msk;
340 temp = PORT_REGS->GROUP[0].PORT_PMUX[2] & ~PORT_PMUX_PMUXE_Msk;
341 PORT_REGS->GROUP[0].PORT_PMUX[2] = temp | PORT_PMUX_PMUXE(MUX_PA04K_ETH_MDIO);
344 PORT_REGS->GROUP[0].PORT_PINCFG[5] |= PORT_PINCFG_PMUXEN_Msk;
345 temp = PORT_REGS->GROUP[0].PORT_PMUX[2] & ~PORT_PMUX_PMUXO_Msk;
346 PORT_REGS->GROUP[0].PORT_PMUX[2] = temp | PORT_PMUX_PMUXO(MUX_PA05K_ETH_RXDV);
349 PORT_REGS->GROUP[0].PORT_PINCFG[6] |= PORT_PINCFG_PMUXEN_Msk;
350 temp = PORT_REGS->GROUP[0].PORT_PMUX[3] & ~PORT_PMUX_PMUXE_Msk;
351 PORT_REGS->GROUP[0].PORT_PMUX[3] = temp | PORT_PMUX_PMUXE(MUX_PA06K_ETH_RXER);
354 PORT_REGS->GROUP[0].PORT_PINCFG[21] |= PORT_PINCFG_PMUXEN_Msk;
355 temp = PORT_REGS->GROUP[0].PORT_PMUX[10] & ~PORT_PMUX_PMUXO_Msk;
356 PORT_REGS->GROUP[0].PORT_PMUX[10] = temp | PORT_PMUX_PMUXO(MUX_PA21K_ETH_TX_CLK);
359 PORT_REGS->GROUP[3].PORT_PINCFG[2] |= PORT_PINCFG_PMUXEN_Msk;
360 temp = PORT_REGS->GROUP[3].PORT_PMUX[1] & ~PORT_PMUX_PMUXE_Msk;
361 PORT_REGS->GROUP[3].PORT_PMUX[1] = temp | PORT_PMUX_PMUXE(MUX_PD02K_ETH_TXER);
364 PORT_REGS->GROUP[3].PORT_PINCFG[3] |= PORT_PINCFG_PMUXEN_Msk;
365 temp = PORT_REGS->GROUP[3].PORT_PMUX[1] & ~PORT_PMUX_PMUXO_Msk;
366 PORT_REGS->GROUP[3].PORT_PMUX[1] = temp | PORT_PMUX_PMUXO(MUX_PD03K_ETH_TXD3);
369 PORT_REGS->GROUP[3].PORT_PINCFG[4] |= PORT_PINCFG_PMUXEN_Msk;
370 temp = PORT_REGS->GROUP[3].PORT_PMUX[2] & ~PORT_PMUX_PMUXE_Msk;
371 PORT_REGS->GROUP[3].PORT_PMUX[2] = temp | PORT_PMUX_PMUXE(MUX_PD04K_ETH_TXD2);
374 PORT_REGS->GROUP[3].PORT_PINCFG[5] |= PORT_PINCFG_PMUXEN_Msk;
375 temp = PORT_REGS->GROUP[3].PORT_PMUX[2] & ~PORT_PMUX_PMUXO_Msk;
376 PORT_REGS->GROUP[3].PORT_PMUX[2] = temp | PORT_PMUX_PMUXO(MUX_PD05L_ETH_GTX_CLK);
379 PORT_REGS->GROUP[3].PORT_PINCFG[6] |= PORT_PINCFG_PMUXEN_Msk;
380 temp = PORT_REGS->GROUP[3].PORT_PMUX[3] & ~PORT_PMUX_PMUXE_Msk;
381 PORT_REGS->GROUP[3].PORT_PMUX[3] = temp | PORT_PMUX_PMUXE(MUX_PD06K_ETH_RXD3);
384 PORT_REGS->GROUP[3].PORT_PINCFG[7] |= PORT_PINCFG_PMUXEN_Msk;
385 temp = PORT_REGS->GROUP[3].PORT_PMUX[3] & ~PORT_PMUX_PMUXO_Msk;
386 PORT_REGS->GROUP[3].PORT_PMUX[3] = temp | PORT_PMUX_PMUXO(MUX_PD07K_ETH_RXD2);
389 PORT_REGS->GROUP[3].PORT_PINCFG[8] |= PORT_PINCFG_PMUXEN_Msk;
390 temp = PORT_REGS->GROUP[3].PORT_PMUX[4] & ~PORT_PMUX_PMUXE_Msk;
391 PORT_REGS->GROUP[3].PORT_PMUX[4] = temp | PORT_PMUX_PMUXE(MUX_PD08K_ETH_COL);
394 PORT_REGS->GROUP[3].PORT_PINCFG[9] |= PORT_PINCFG_PMUXEN_Msk;
395 temp = PORT_REGS->GROUP[3].PORT_PMUX[4] & ~PORT_PMUX_PMUXO_Msk;
396 PORT_REGS->GROUP[3].PORT_PMUX[4] = temp | PORT_PMUX_PMUXO(MUX_PD09K_ETH_CRS);
399 PORT_REGS->GROUP[3].PORT_PINCFG[10] |= PORT_PINCFG_PMUXEN_Msk;
400 temp = PORT_REGS->GROUP[3].PORT_PMUX[5] & ~PORT_PMUX_PMUXE_Msk;
401 PORT_REGS->GROUP[3].PORT_PMUX[5] = temp | PORT_PMUX_PMUXE(MUX_PD10K_ETH_RXD1);
404 PORT_REGS->GROUP[3].PORT_PINCFG[11] |= PORT_PINCFG_PMUXEN_Msk;
405 temp = PORT_REGS->GROUP[3].PORT_PMUX[5] & ~PORT_PMUX_PMUXO_Msk;
406 PORT_REGS->GROUP[3].PORT_PMUX[5] = temp | PORT_PMUX_PMUXO(MUX_PD11K_ETH_RXD0);
409 PORT_REGS->GROUP[3].PORT_PINCFG[12] |= PORT_PINCFG_PMUXEN_Msk;
410 temp = PORT_REGS->GROUP[3].PORT_PMUX[6] & ~PORT_PMUX_PMUXE_Msk;
411 PORT_REGS->GROUP[3].PORT_PMUX[6] = temp | PORT_PMUX_PMUXE(MUX_PD12L_ETH_RX_CLK);
414 PORT_REGS->GROUP[3].PORT_PINCFG[14] |= PORT_PINCFG_PMUXEN_Msk;
415 temp = PORT_REGS->GROUP[3].PORT_PMUX[7] & ~PORT_PMUX_PMUXE_Msk;
416 PORT_REGS->GROUP[3].PORT_PMUX[7] = temp | PORT_PMUX_PMUXE(MUX_PD14K_ETH_TXD7);
419 PORT_REGS->GROUP[3].PORT_PINCFG[15] |= PORT_PINCFG_PMUXEN_Msk;
420 temp = PORT_REGS->GROUP[3].PORT_PMUX[7] & ~PORT_PMUX_PMUXO_Msk;
421 PORT_REGS->GROUP[3].PORT_PMUX[7] = temp | PORT_PMUX_PMUXO(MUX_PD15K_ETH_TXD6);
424 PORT_REGS->GROUP[3].PORT_PINCFG[16] |= PORT_PINCFG_PMUXEN_Msk;
425 temp = PORT_REGS->GROUP[3].PORT_PMUX[8] & ~PORT_PMUX_PMUXE_Msk;
426 PORT_REGS->GROUP[3].PORT_PMUX[8] = temp | PORT_PMUX_PMUXE(MUX_PD16K_ETH_TXD5);
429 PORT_REGS->GROUP[3].PORT_PINCFG[17] |= PORT_PINCFG_PMUXEN_Msk;
430 temp = PORT_REGS->GROUP[3].PORT_PMUX[8] & ~PORT_PMUX_PMUXO_Msk;
431 PORT_REGS->GROUP[3].PORT_PMUX[8] = temp | PORT_PMUX_PMUXO(MUX_PD17K_ETH_TXD4);
434 PORT_REGS->GROUP[3].PORT_PINCFG[18] |= PORT_PINCFG_PMUXEN_Msk;
435 temp = PORT_REGS->GROUP[3].PORT_PMUX[9] & ~PORT_PMUX_PMUXE_Msk;
436 PORT_REGS->GROUP[3].PORT_PMUX[9] = temp | PORT_PMUX_PMUXE(MUX_PD18K_ETH_RXD7);
439 PORT_REGS->GROUP[3].PORT_PINCFG[19] |= PORT_PINCFG_PMUXEN_Msk;
440 temp = PORT_REGS->GROUP[3].PORT_PMUX[9] & ~PORT_PMUX_PMUXO_Msk;
441 PORT_REGS->GROUP[3].PORT_PMUX[9] = temp | PORT_PMUX_PMUXO(MUX_PD19K_ETH_RXD6);
444 PORT_REGS->GROUP[3].PORT_PINCFG[20] |= PORT_PINCFG_PMUXEN_Msk;
445 temp = PORT_REGS->GROUP[3].PORT_PMUX[10] & ~PORT_PMUX_PMUXE_Msk;
446 PORT_REGS->GROUP[3].PORT_PMUX[10] = temp | PORT_PMUX_PMUXE(MUX_PD20K_ETH_RXD4);
449 PORT_REGS->GROUP[3].PORT_PINCFG[21] |= PORT_PINCFG_PMUXEN_Msk;
450 temp = PORT_REGS->GROUP[3].PORT_PMUX[10] & ~PORT_PMUX_PMUXO_Msk;
451 PORT_REGS->GROUP[3].PORT_PMUX[10] = temp | PORT_PMUX_PMUXO(MUX_PD21K_ETH_RXD5);
454 ETH_REGS->ETH_CTRLB |= ETH_CTRLB_GMIIEN_Msk | ETH_CTRLB_GBITCLKREQ_Msk;
457 while(ETH_REGS->ETH_SYNCB != 0)
462 PORT_REGS->GROUP[0].PORT_PINCFG[5] |= PORT_PINCFG_PULLEN_Msk;
463 PORT_REGS->GROUP[0].PORT_OUTCLR = PORT_PA05;
466 PORT_REGS->GROUP[3].PORT_PINCFG[6] |= PORT_PINCFG_PULLEN_Msk;
467 PORT_REGS->GROUP[3].PORT_OUTCLR = PORT_PD06;
470 PORT_REGS->GROUP[3].PORT_PINCFG[7] |= PORT_PINCFG_PULLEN_Msk;
471 PORT_REGS->GROUP[3].PORT_OUTCLR = PORT_PD07;
474 PORT_REGS->GROUP[3].PORT_PINCFG[10] |= PORT_PINCFG_PULLEN_Msk;
475 PORT_REGS->GROUP[3].PORT_OUTCLR = PORT_PD10;
478 PORT_REGS->GROUP[3].PORT_PINCFG[11] |= PORT_PINCFG_PULLEN_Msk;
479 PORT_REGS->GROUP[3].PORT_OUTSET = PORT_PD11;
482 PORT_REGS->GROUP[3].PORT_PINCFG[12] |= PORT_PINCFG_PULLEN_Msk;
483 PORT_REGS->GROUP[3].PORT_OUTSET = PORT_PD12;
486 PORT_REGS->GROUP[1].PORT_DIRSET = PORT_PB23;
489 PORT_REGS->GROUP[1].PORT_OUTCLR = PORT_PB23;
491 PORT_REGS->GROUP[1].PORT_OUTSET = PORT_PB23;
531 rxBufferDesc[i].
status = 0;
543 address = (uint32_t) dummyTxBuffer[i];
557 address = (uint32_t) dummyRxBuffer[i];
561 dummyRxBufferDesc[i].
status = 0;
568 ETH_REGS->ETH_TBQB = (uint32_t) txBufferDesc;
569 ETH_REGS->ETH_TBPQB[0] = (uint32_t) dummyTxBufferDesc;
570 ETH_REGS->ETH_TBPQB[1] = (uint32_t) dummyTxBufferDesc;
571 ETH_REGS->ETH_TBPQB[2] = (uint32_t) dummyTxBufferDesc;
572 ETH_REGS->ETH_TBPQB[3] = (uint32_t) dummyTxBufferDesc;
573 ETH_REGS->ETH_TBPQB[4] = (uint32_t) dummyTxBufferDesc;
576 ETH_REGS->ETH_RBQB = (uint32_t) rxBufferDesc;
577 ETH_REGS->ETH_RBPQB[0] = (uint32_t) dummyRxBufferDesc;
578 ETH_REGS->ETH_RBPQB[1] = (uint32_t) dummyRxBufferDesc;
579 ETH_REGS->ETH_RBPQB[2] = (uint32_t) dummyRxBufferDesc;
580 ETH_REGS->ETH_RBPQB[3] = (uint32_t) dummyRxBufferDesc;
581 ETH_REGS->ETH_RBPQB[4] = (uint32_t) dummyRxBufferDesc;
597 if(interface->phyDriver != NULL)
600 interface->phyDriver->tick(interface);
602 else if(interface->switchDriver != NULL)
605 interface->switchDriver->tick(interface);
622 NVIC_EnableIRQ(ETH_PRI_Q_0_IRQn);
625 if(interface->phyDriver != NULL)
628 interface->phyDriver->enableIrq(interface);
630 else if(interface->switchDriver != NULL)
633 interface->switchDriver->enableIrq(interface);
650 NVIC_DisableIRQ(ETH_PRI_Q_0_IRQn);
653 if(interface->phyDriver != NULL)
656 interface->phyDriver->disableIrq(interface);
658 else if(interface->switchDriver != NULL)
661 interface->switchDriver->disableIrq(interface);
677 volatile uint32_t isr;
678 volatile uint32_t tsr;
679 volatile uint32_t rsr;
689 isr = ETH_REGS->ETH_ISR;
690 tsr = ETH_REGS->ETH_TSR;
691 rsr = ETH_REGS->ETH_RSR;
694 ETH_REGS->ETH_ISR = isr;
697 if((tsr & (ETH_TSR_HRESP_Msk | ETH_TSR_UND_Msk |
698 ETH_TSR_TXCOMP_Msk | ETH_TSR_TFC_Msk | ETH_TSR_TXGO_Msk |
699 ETH_TSR_RLE_Msk | ETH_TSR_COL_Msk | ETH_TSR_UBR_Msk)) != 0)
702 ETH_REGS->ETH_TSR = tsr;
705 if((txBufferDesc[txBufferIndex].status &
ETH_TX_USED) != 0)
713 if((rsr & (ETH_RSR_HNO_Msk | ETH_RSR_RXOVR_Msk | ETH_RSR_REC_Msk |
714 ETH_RSR_BNA_Msk)) != 0)
717 nicDriverInterface->nicEvent =
TRUE;
738 rsr = ETH_REGS->ETH_RSR;
741 if((rsr & (ETH_RSR_HNO_Msk | ETH_RSR_RXOVR_Msk | ETH_RSR_REC_Msk |
742 ETH_RSR_BNA_Msk)) != 0)
745 ETH_REGS->ETH_RSR = rsr;
787 if((txBufferDesc[txBufferIndex].status &
ETH_TX_USED) == 0)
819 ETH_REGS->ETH_NCR |= ETH_NCR_TSTART_Msk;
822 if((txBufferDesc[txBufferIndex].status &
ETH_TX_USED) != 0)
860 j = rxBufferIndex + i;
876 if((rxBufferDesc[j].status &
ETH_RX_SOF) != 0)
883 if((rxBufferDesc[j].status &
ETH_RX_EOF) != 0 && sofIndex != UINT_MAX)
897 if(eofIndex != UINT_MAX)
901 else if(sofIndex != UINT_MAX)
914 for(i = 0; i < j; i++)
917 if(eofIndex != UINT_MAX && i >= sofIndex && i <= eofIndex)
977 uint32_t hashTable[2];
985 ETH_REGS->SA[0].ETH_SAB = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
986 ETH_REGS->SA[0].ETH_SAT = interface->macAddr.w[2];
1002 entry = &interface->macAddrFilter[i];
1014 k = (
p[0] >> 6) ^
p[0];
1015 k ^= (
p[1] >> 4) ^ (
p[1] << 2);
1016 k ^= (
p[2] >> 2) ^ (
p[2] << 4);
1017 k ^= (
p[3] >> 6) ^
p[3];
1018 k ^= (
p[4] >> 4) ^ (
p[4] << 2);
1019 k ^= (
p[5] >> 2) ^ (
p[5] << 4);
1025 hashTable[k / 32] |= (1 << (k % 32));
1033 unicastMacAddr[j] = entry->
addr;
1041 k = (
p[0] >> 6) ^
p[0];
1042 k ^= (
p[1] >> 4) ^ (
p[1] << 2);
1043 k ^= (
p[2] >> 2) ^ (
p[2] << 4);
1044 k ^= (
p[3] >> 6) ^
p[3];
1045 k ^= (
p[4] >> 4) ^ (
p[4] << 2);
1046 k ^= (
p[5] >> 2) ^ (
p[5] << 4);
1052 hashTable[k / 32] |= (1 << (k % 32));
1065 ETH_REGS->SA[1].ETH_SAB = unicastMacAddr[0].w[0] | (unicastMacAddr[0].w[1] << 16);
1066 ETH_REGS->SA[1].ETH_SAT = unicastMacAddr[0].w[2];
1071 ETH_REGS->SA[1].ETH_SAB = 0;
1078 ETH_REGS->SA[2].ETH_SAB = unicastMacAddr[1].w[0] | (unicastMacAddr[1].w[1] << 16);
1079 ETH_REGS->SA[2].ETH_SAT = unicastMacAddr[1].w[2];
1084 ETH_REGS->SA[2].ETH_SAB = 0;
1091 ETH_REGS->SA[3].ETH_SAB = unicastMacAddr[2].w[0] | (unicastMacAddr[2].w[1] << 16);
1092 ETH_REGS->SA[3].ETH_SAT = unicastMacAddr[2].w[2];
1097 ETH_REGS->SA[3].ETH_SAB = 0;
1103 ETH_REGS->ETH_NCFGR |= ETH_NCFGR_UNIHEN_Msk;
1107 ETH_REGS->ETH_NCFGR &= ~ETH_NCFGR_UNIHEN_Msk;
1111 ETH_REGS->ETH_HRB = hashTable[0];
1112 ETH_REGS->ETH_HRT = hashTable[1];
1115 TRACE_DEBUG(
" HRB = %08" PRIX32
"\r\n", ETH_REGS->ETH_HRB);
1116 TRACE_DEBUG(
" HRT = %08" PRIX32
"\r\n", ETH_REGS->ETH_HRT);
1134 config = ETH_REGS->ETH_NCFGR;
1139 config |= ETH_NCFGR_GIGE_Msk;
1140 config &= ~ETH_NCFGR_SPD_Msk;
1145 config &= ~ETH_NCFGR_GIGE_Msk;
1146 config |= ETH_NCFGR_SPD_Msk;
1151 config &= ~ETH_NCFGR_GIGE_Msk;
1152 config &= ~ETH_NCFGR_SPD_Msk;
1158 config |= ETH_NCFGR_FD_Msk;
1162 config &= ~ETH_NCFGR_FD_Msk;
1166 ETH_REGS->ETH_NCFGR = config;
1190 temp = ETH_MAN_CLTTO_Msk | ETH_MAN_OP(1) | ETH_MAN_WTN(2);
1192 temp |= ETH_MAN_PHYA(phyAddr);
1194 temp |= ETH_MAN_REGA(
regAddr);
1196 temp |= ETH_MAN_DATA(
data);
1199 ETH_REGS->ETH_MAN = temp;
1201 while((ETH_REGS->ETH_NSR & ETH_NSR_IDLE_Msk) == 0)
1230 temp = ETH_MAN_CLTTO_Msk | ETH_MAN_OP(2) | ETH_MAN_WTN(2);
1232 temp |= ETH_MAN_PHYA(phyAddr);
1234 temp |= ETH_MAN_REGA(
regAddr);
1237 ETH_REGS->ETH_MAN = temp;
1239 while((ETH_REGS->ETH_NSR & ETH_NSR_IDLE_Msk) == 0)
1244 data = ETH_REGS->ETH_MAN & ETH_MAN_DATA_Msk;