MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / tivaif_hwinit

Function tivaif_hwinit

bsp/tm4c129x/drivers/drv_eth.c:347–448  ·  view source on GitHub ↗

* In this function, the hardware should be initialized. * Called from tivaif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */

Source from the content-addressed store, hash-verified

345 * for this ethernetif
346 */
347static void
348tivaif_hwinit(struct netif *psNetif)
349{
350 uint16_t ui16Val;
351
352 /* clear the EEE Link Active flag */
353#if EEE_SUPPORT
354 g_bEEELinkActive = false;
355#endif
356
357 /* Set MAC hardware address length */
358 psNetif->hwaddr_len = ETHARP_HWADDR_LEN;
359
360 /* Set MAC hardware address */
361 EMACAddrGet(EMAC0_BASE, 0, &(psNetif->hwaddr[0]));
362
363 /* Maximum transfer unit */
364 psNetif->mtu = 1500;
365
366 /* Device capabilities */
367 psNetif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
368
369 /* Initialize the DMA descriptors. */
370 InitDMADescriptors();
371
372#if defined(EMAC_PHY_IS_EXT_MII) || defined(EMAC_PHY_IS_EXT_RMII)
373 /* If PHY is external then reset the PHY before configuring it */
374 EMACPHYWrite(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_BMCR,
375 EPHY_BMCR_MIIRESET);
376
377 while((EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_BMCR) &
378 EPHY_BMCR_MIIRESET) == EPHY_BMCR_MIIRESET);
379#endif
380
381 /* Clear any stray PHY interrupts that may be set. */
382 ui16Val = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_MISR1);
383 ui16Val = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_MISR2);
384
385 /* Configure and enable the link status change interrupt in the PHY. */
386 ui16Val = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_SCR);
387 ui16Val |= (EPHY_SCR_INTEN_EXT | EPHY_SCR_INTOE_EXT);
388 EMACPHYWrite(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_SCR, ui16Val);
389 EMACPHYWrite(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_MISR1, (EPHY_MISR1_LINKSTATEN |
390 EPHY_MISR1_SPEEDEN | EPHY_MISR1_DUPLEXMEN | EPHY_MISR1_ANCEN));
391
392 /* Read the PHY interrupt status to clear any stray events. */
393 ui16Val = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_MISR1);
394
395 /**
396 * Set MAC filtering options. We receive all broadcast and mui32ticast
397 * packets along with those addressed specifically for us.
398 */
399 EMACFrameFilterSet(EMAC0_BASE, (EMAC_FRMFILTER_HASH_AND_PERFECT |
400 EMAC_FRMFILTER_PASS_MULTICAST));
401
402#if LWIP_PTPD
403 //
404 // Enable timestamping on all received packets.

Callers 1

eth_dev_initFunction · 0.85

Calls 15

InitDMADescriptorsFunction · 0.85
EMACAddrGetFunction · 0.50
EMACPHYWriteFunction · 0.50
EMACPHYReadFunction · 0.50
EMACFrameFilterSetFunction · 0.50
EMACTimestampConfigSetFunction · 0.50
EMACTimestampAddendSetFunction · 0.50
EMACTimestampEnableFunction · 0.50
EMACIntClearFunction · 0.50
EMACIntStatusFunction · 0.50
EMACTxEnableFunction · 0.50
EMACRxEnableFunction · 0.50

Tested by

no test coverage detected