LWIP Network Interface network card initialization to STM32 as an example will be useful after 2G or 4G module in the form of PPP dial-up virtual network card, so first of all, this is the premise
LWIP has a structure that describes the physical interface of the Netif Struct, the great god of Chu has a detailed explanation of this: http://blog.csdn.net/zhzht19861011/article/details/6690 534
The LWIP website also has a detailed description of the structure: http://www.nongnu.org/lwip/2_0_x/structnetif.html
The code I use is the official ST demo routine that can be downloaded here to stm32f407 + DP83848
Project Open Path: C:\Users\admin\Desktop\STM32F4x7_ETH_LwIP_V1.1.0\Project\FreeRTOS\udptcp_echo_server_netconn\MDK-ARM
See how ST defines a NIC variable and initializes the
First look at the definition of the place:
Then look at how this variable is initialized:
/*-Netif_add (struct netif *netif, struct ip_addr *ipaddr,
struct ip_addr *netmask, struct ip_addr *GW,
void *state, err_t (* init) (struct netif *netif),
err_t (* input) (struct pbuf *p, struct netif *netif))
Adds your network interface to the netif_list. Allocate a struct
Netif and pass a pointer to this structure as the first argument.
Give pointers to cleared IP_ADDR structures when using DHCP,
or fill them with sane numbers otherwise. The state pointer could be NULL.
The INIT function pointer must point to a initialization function for
Your Ethernet Netif interface. The following code illustrates it ' s use.*/
Netif_add (&xnetif, &ipaddr, &netmask, &GW, NULL, ðernetif_init, &tcpip_input);
Used Netif_add (&xnetif, &ipaddr, &netmask, &GW, NULL, ðernetif_init, &tcpip_input); This function initializes the NIC.
This function is a function provided by LWIP, let's take a look at the official explanation: HTTP://WWW.NONGNU.ORG/LWIP/2_0_X/GROUP__NETIF.HTML#GADE5498543E74067F28CC6BEF02 09e3be
First step: We need to define a variable of netif Struct type first
LWIP Network Interface network card initialization to STM32 as an example will be useful after 2G or 4G module in the form of PPP dial-up virtual network card, so first of all, this is the premise