LWIP network interface 網卡 初始化 以 STM32 為例子 後面會有 用 2G 或者4G 模組 用 PPP撥號的 形式 虛擬出網卡 所以先以 這個為 前提

來源:互聯網
上載者:User

標籤:dex   init   follow   需要   結構體   user   str   ipad   樣本   

LWIP   network interface   網卡 初始化    以  STM32  為例子  後面會有 用  2G 或者4G 模組 用 PPP撥號的 形式  虛擬出網卡  所以先以 這個為  前提 

 

LWIP   有 一個 結構體 是 描述 物理 介面 的  即  netif Struct, 大神朱工 對這個 有個 詳細的 解釋 :http://blog.csdn.net/zhzht19861011/article/details/6690534

 

LWIP  官網  對 這個  結構體 也有 詳細 的 描述  :http://www.nongnu.org/lwip/2_0_x/structnetif.html

 

 

 

我 使用 的 代碼 是  ST  官方 提供   的 示範常式 , 可以在 這裡下載到  STM32F407 + DP83848

工程 開啟路徑  : C:\Users\admin\Desktop\STM32F4x7_ETH_LwIP_V1.1.0\Project\FreeRTOS\udptcp_echo_server_netconn\MDK-ARM

 

 

 

看看 ST  是怎麼 定義 一個 網卡 變數   並 初始化的 

 

首先看 定義 的 地方  :

 

然後  看看    對 這個變數  怎麼 初始化 的  。。

 

/* - 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 may 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, &ethernetif_init, &tcpip_input);

 

使用  了     netif_add(&xnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input); 這個 函數  對 這個 網卡 進行 了 初始化  。

 

這個 函數 是   LWIP   提供的  函數  ,我們 看一下 官方 的 解釋 :http://www.nongnu.org/lwip/2_0_x/group__netif.html#gade5498543e74067f28cc6bef0209e3be

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

第一步 : 我 們 需要 先 定義 一個 netif Struct  類型 的變數 

LWIP network interface 網卡 初始化 以 STM32 為例子 後面會有 用 2G 或者4G 模組 用 PPP撥號的 形式 虛擬出網卡 所以先以 這個為 前提

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.