?? lwipentry.c
字號:
//*------------------------------------------------------------------------------------------------
//* 文件名 : LwIPEntry.c
//* 功能描述 : LwIP協(xié)議棧入口函數(shù)文件
//* 作者 : 焦海波
//* 版本 : 0.1
//* 建立日期、時(shí)間 : 2006/06/06 14:50
//* 最近修改日期、時(shí)間 :
//* 修改原因 :
//*------------------------------------------------------------------------------------------------
//*------------------------------------------ 頭文件 -----------------------------------------------
//#include "/uCOS_II/includes.h"
#include "/LwIP/include/ipv4/lwip/ip_addr.h"
#include "/LwIP/include/lwip/netif.h"
#include "/LwIP/include/lwip/tcpip.h"
//#include "/at91sam7x256/include/AT91SAM7X256.h"
//#include "/at91sam7x256/include/lib_AT91SAM7X256.h"
//#include "/at91sam7x256/periph/emac/lib_emac.h"
//#include "/at91sam7x256/drivers/flash/flash.h"
//#include "/tools/search.h"
#include "dm9000.h"
//*------------------------------------------ 宏定義 -----------------------------------------------
#define HTTP_PORT 8080 //80
//*================================================================================================
//* 函 數(shù) 區(qū)
//*================================================================================================
//*------------------------------------------------------------------------------------------------
//* 函數(shù)名稱 : InitLwIP
//* 功能描述 : 初始化LwIP
//* 入口參數(shù) : 無
//* 出口參數(shù) : 無
//*------------------------------------------------------------------------------------------------
void InitLwIP(void)
{
sys_init();
mem_init();
memp_init();
pbuf_init();
netif_init();
ip_init();
tcpip_init(NULL, NULL);
udp_init();
}
//*------------------------------------------------------------------------------------------------
//* 函數(shù)名稱 : SetupLwIP
//* 功能描述 : 設(shè)置LwIP,主要是設(shè)置網(wǎng)絡(luò)接口、建立接收任務(wù)等諸如此類的初始設(shè)置工作
//* 入口參數(shù) : 無
//* 出口參數(shù) : 無
//*------------------------------------------------------------------------------------------------
void SetupLwIP(void)
{
extern err_t ethernetif_init(st_netif *stNetif);
st_ip_addr __stIpAddr, __stNetMask, __stGateway;
static st_netif __stEMACNetif;
//* 必須首先調(diào)用 netif_init() must be called first
netif_init();
//* 建立并配置EMAC接口
//IP4_ADDR(&__stIpAddr, 192,168,1,11);
IP4_ADDR(&__stIpAddr, 192,168,192,231);
IP4_ADDR(&__stNetMask, 255,255,255,0);
//IP4_ADDR(&__stGateway,192,168,1,1);
IP4_ADDR(&__stGateway,192,168,192,2);
netif_add(&__stEMACNetif, &__stIpAddr, &__stNetMask, &__stGateway, NULL, ethernetif_init, tcpip_input);
netif_set_default(&__stEMACNetif);
netif_set_up(&__stEMACNetif);
}
//*------------------------------------------------------------------------------------------------
//* 函數(shù)名稱 : T_WEBServer
//* 功能描述 : Web服務(wù)器
//* 入口參數(shù) : <pReserved>[in] 保留
//* 出口參數(shù) : 無
//*------------------------------------------------------------------------------------------------
void T_WEBServer(void *pReserved)
{
//extern void Handler_HTTP(ST_NETCONN *pstConn);
ST_NETCONN *__pstConn, *__pstNewConn;
InitLwIP();
//* 設(shè)置LwIP,主要是設(shè)置網(wǎng)絡(luò)接口、建立接收任務(wù)等諸如此類的初始設(shè)置工作
SetupLwIP();
/*__pstConn = netconn_new(NETCONN_TCP);
netconn_bind(__pstConn, NULL, HTTP_PORT);
netconn_listen(__pstConn);
*/
while(TRUE)
{
OSPrintf("Current task is in loop of T_WEBServer.\n");
/*__pstNewConn = netconn_accept(__pstConn);
if(__pstNewConn != NULL)
{
Handler_HTTP(__pstNewConn);
while(netconn_delete(__pstNewConn) != ERR_OK) {
OSTimeDlyHMSM(0, 0, 1, 0);
}
}*/
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -