sif_hwinit()函数 6. * 来完成以太网硬件的设置.
7. * This function should be passed as a parameter to netif_add(). 8. * 这个函数作为一个参数传递给netif_add()函数.
9. * @paramnetif the lwip network interface structure for this ethernetif
10.* @return ERR_OK if the loopif is initialized 11.* ERR_MEM if private data couldn't be allocated 12.* any other err_t on error 13.*/ 14.err_t
15.stellarisif_init(structnetif *netif) 16.{
17.LWIP_ASSERT("netif != NULL", (netif != NULL)); 18.
19.#if LWIP_NETIF_HOSTNAME
20./* Initialize interface hostname */
21.netif->hostname ="lwip";//初始化接口主机名字 22.#endif /* LWIP_
NETIF_HOSTNAME */ 23. 24./*
25.* Initialize the snmp variables and counters inside the structnetif.
26.* The last argument should be replaced with your link speed, in units 27.* of bits per second. 28.*/
29.NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 1000000);//初始化snmp变量 30.
31.netif->state = &;stellarisif_data;//指向以太网接口的私有数据,包括pbuf数据链和MAC地址
32.netif->name[0] = IFNAME0; 33.netif->name[1] = IFNAME1;
34./* We directly use etharp_output() here to save a function call. 35.* You can instead declare your own function an call etharp_output() 36.* from it if you have to do some checks before sending (e.g. if link 37.* is available...) */
38.netif->output = etharp_output;//IP层将一包数据发往网络接口时调用此函数
39.netif->linkoutput = stellarisif_output;//ARP模块将一包数据发往网络接口时调用此函数 40.
41.stellarisif_data.ethaddr = (structeth_addr *)&;(netif->hwaddr[0]);//初始化MAC地址
42.stellarisif_data.txq.qread = stellarisif_data.txq.qwrite = 0;//初始化pbuf数据链
43.stellarisif_data.txq.overflow = 0; 44.
45./* initialize the hardware */
46.stellarisif_hwinit(netif);//初始化Stellaris以太网硬件 47.
48.returnERR_OK; 49.}
/** * Should be called at the beginning of the program to set up the * network interface. It calls the function stellarisif_hwinit() to do the * actual setup of t