/** * In this function, the hardware should be initialized. * Called from stellarisif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */ static void stellarisif_hwinit(struct netif *netif) { u32_t temp; //struct stellarisif *stellarisif = netif->state; /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; #if 1 // // Enable the Link OK and Link Activity LEDS. // GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3); GPIOPinConfigure(GPIO_PF3_LED0); GPIOPinConfigure(GPIO_PF2_LED1); #endif /* set MAC hardware address */ EthernetMACAddrGet(ETH_BASE, &(netif->hwaddr[0])); /* maximum transfer unit */ netif->mtu = 1500; /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; /* Do whatever else is needed to initialize interface. */ /* Disable all Ethernet Interrupts. */ EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX)); temp = EthernetIntStatus(ETH_BASE, false); EthernetIntClear(ETH_BASE, temp); /* Initialize the Ethernet Controller. */ EthernetInitExpClk(ETH_BASE, SysCtlClockGet()); /* * Configure the Ethernet Controller for normal operation. * - Enable TX Duplex Mode * - Enable TX Padding * - Enable TX CRC Generation * - Enable RX Multicast Reception */ EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN |ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN)); /* Enable the Ethernet Controller transmitter and receiver. */ EthernetEnable(ETH_BASE); /* Enable the Ethernet Interrupt handler. */ IntEnable(INT_ETH); /* Enable Ethernet TX and RX Packet Interrupts. */ EthernetIntEnable(ETH_BASE, ETH_INT_RX | ETH_INT_TX); }
/** * In this function, the hardware should be initialized. * Called from ethernetif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */ static void low_level_init(struct netif *netif) { u32_t temp; MAC_Type* mac = (MAC_Type*)netif->state; //struct ethernetif *ethernetif = netif->state; /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; /* set MAC hardware address */ EthernetMACAddrGet(mac, &(netif->hwaddr[0])); /* maximum transfer unit */ netif->mtu = 1500; /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP ;//| NETIF_FLAG_LINK_UP; /* Do whatever else is needed to initialize interface. */ /* Disable all Ethernet Interrupts. */ EthernetIntDisable( mac, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX)); temp = EthernetIntStatus(mac, false); EthernetIntClear(mac, temp); /* Initialize the Ethernet Controller. */ EthernetInitExpClk(mac, system_clock_frequency);//SysCtlClockGet()); /* * Configure the Ethernet Controller for normal operation. * - Enable TX Duplex Mode * - Enable TX Padding * - Enable TX CRC Generation * - Enable RX Multicast Reception */ EthernetConfigSet( mac, (ETH_CFG_TX_DPLXEN | ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN)); /* Enable the Ethernet Controller transmitter and receiver. */ EthernetEnable(mac); /* Enable the Ethernet Interrupt handler. */ // IntEnable( INT_ETH); NVIC_EnableIRQ(Ethernet_IRQn); //THIS IS BAD! /* Enable Ethernet TX and RX Packet Interrupts. */ EthernetIntEnable(mac, ETH_INT_RX | ETH_INT_TX); }
/** * In this function, the hardware should be initialized. * Called from stellarisif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */ static void stellarisif_hwinit(struct netif *netif) { u32_t temp; //struct stellarisif *stellarisif = netif->state; /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; /* set MAC hardware address */ EthernetMACAddrGet(ETH_BASE, &(netif->hwaddr[0])); /* maximum transfer unit */ netif->mtu = 1500; /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; /* Do whatever else is needed to initialize interface. */ /* Disable all Ethernet Interrupts. */ EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX)); temp = EthernetIntStatus(ETH_BASE, false); EthernetIntClear(ETH_BASE, temp); /* Initialize the Ethernet Controller. */ EthernetInitExpClk(ETH_BASE, SysCtlClockGet()); /* * Configure the Ethernet Controller for normal operation. * - Enable TX Duplex Mode * - Enable TX Padding * - Enable TX CRC Generation * - Enable RX Multicast Reception */ EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN |ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN)); /* Enable the Ethernet Controller transmitter and receiver. */ EthernetEnable(ETH_BASE); IntPrioritySet(INT_ETH, configKERNEL_INTERRUPT_PRIORITY); /* Enable the Ethernet Interrupt handler. */ IntEnable(INT_ETH); EthernetPHYWrite(ETH_BASE, PHY_MR17, PHY_MR17_LSCHG_IE); /* Enable Ethernet TX and RX Packet Interrupts. */ EthernetIntEnable(ETH_BASE, ETH_INT_PHY | ETH_INT_RX | ETH_INT_TX); }
//***************************************************************************** // //! Returns the local MAC/HW address for this interface. //! //! \param pucMAC is a pointer to an array of bytes used to store the MAC //! address. //! //! This function will read the currently assigned MAC address into the array //! passed in \e pucMAC. //! //! \return None. // //***************************************************************************** void lwIPLocalMACGet(unsigned char *pucMAC) { EthernetMACAddrGet(ETH_BASE, pucMAC); }
void ethernetThread(void *pParams) { IP_CONFIG ipconfig; unsigned char hwaddr[6] = {0, 0, 0, 0, 0, 0}; char s[64]; /* sprintf string */ ETHServiceTaskInit(0); ETHServiceTaskFlush(0,ETH_FLUSH_RX | ETH_FLUSH_TX); /* * Allow make SET_IP_ADR="-D SET_IP_ADR=\"(192<<24|168<<16|98<<8|29)\"" * to build application with a recovery IP address. */ #ifndef SET_IP_ADR #define SET_IP_ADR 0 #endif if (SET_IP_ADR) { ipconfig.IPMode = IPADDR_USE_STATIC; ipconfig.IPAddr = SET_IP_ADR; #ifndef SET_NET_MASK #define SET_NET_MASK 0xffffff00 #endif ipconfig.NetMask = SET_NET_MASK; #ifndef SET_GW_ADR #define SET_GW_ADR (((SET_IP_ADR)&(SET_NET_MASK))|0x00000001) #endif ipconfig.GWAddr = SET_GW_ADR; } else { ipconfig.IPMode = usercfg.IPMode; ipconfig.IPAddr = IP2LONG(usercfg.ip[0], usercfg.ip[1], usercfg.ip[2], usercfg.ip[3]); ipconfig.NetMask = IP2LONG(usercfg.netmask[0], usercfg.netmask[1], usercfg.netmask[2], usercfg.netmask[3]); ipconfig.GWAddr= IP2LONG(usercfg.gateway[0], usercfg.gateway[1], usercfg.gateway[2], usercfg.gateway[3]); } LWIPServiceTaskInit(&ipconfig); /* * Get actual MAC and IP address programmed */ EthernetMACAddrGet(ETH_BASE, &hwaddr[0]); LWIPServiceTaskIPConfigGet(&lwip_netif, &ipconfig); /* * Print Ethernet configuration to serial */ lprintf("\r\n"); lprintf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n", hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); lprintf(" IP: %d.%d.%d.%d\r\n", ipconfig.IPAddr>>0 & 0xff, ipconfig.IPAddr>>8 & 0xff, ipconfig.IPAddr>>16 & 0xff, ipconfig.IPAddr>>24 & 0xff ); lprintf("\r\n"); #if (PART == LM3S8962) /* * Print Ethernet configuration to OLED screen */ sprintf(s, "MAC %02X:%02X:%02X:%02X:%02X:%02X", hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); RIT128x96x4StringDraw(s, 0, RITLINE(5), 15); sprintf(s, "IP %d.%d.%d.%d", ipconfig.IPAddr>>0 & 0xff, ipconfig.IPAddr>>8 & 0xff, ipconfig.IPAddr>>16 & 0xff, ipconfig.IPAddr>>24 & 0xff ); RIT128x96x4StringDraw(s, 0, RITLINE(6), 15); #endif syslogInit(); syslog(facility_local0 , level_err, "A message from QuickStart" ); /* Nothing else to do. No point hanging around. */ vTaskDelete( NULL); /* We should not get here. */ return; }