void ethernetThread(void *pvParameters) { IP_CONFIG ipconfig; tBoolean found, found_addr; long lEEPROMRetStatus; unsigned short usdata,usdata2; ETHServiceTaskInit(0); ETHServiceTaskFlush(0,ETH_FLUSH_RX | ETH_FLUSH_TX); lEEPROMRetStatus = SoftEEPROMRead(STATIC_IPADDR_HIGH_ID, &usdata2, &found_addr); lEEPROMRetStatus = SoftEEPROMRead(IPMODE_ID, &usdata, &found); if(lEEPROMRetStatus == 0 && found && found_addr) { ipconfig.IPMode = usdata; } else { ipconfig.IPMode = IPADDR_USE_DHCP; } // read static ip address from eeprom if(ipconfig.IPMode == IPADDR_USE_STATIC) { SoftEEPROMRead(STATIC_IPADDR_LOW_ID, &usdata, &found); ipconfig.IPAddr = (usdata2 << 16 & 0xFFFF0000) | (usdata & 0x0000FFFF) ; SoftEEPROMRead(STATIC_IPMASK_HIGH_ID, &usdata2, &found); SoftEEPROMRead(STATIC_IPMASK_LOW_ID, &usdata, &found); ipconfig.NetMask = (usdata2 << 16 & 0xFFFF0000) | (usdata & 0x0000FFFF) ; SoftEEPROMRead(STATIC_IPGW_HIGH_ID, &usdata2, &found); SoftEEPROMRead(STATIC_IPGW_LOW_ID, &usdata, &found); ipconfig.GWAddr = (usdata2 << 16 & 0xFFFF0000) | (usdata & 0x0000FFFF) ; } LWIPServiceTaskInit((void *)&ipconfig); // Nothing else to do. No point hanging around. vTaskDelete( NULL); }
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; }