⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lwipentry.c

📁 uCOS-II下实现的lwip协议栈实现Ping功能
💻 C
字号:
//*------------------------------------------------------------------------------------------------
//* 文件名				: LwIPEntry.c
//* 功能描述			: LwIP协议栈入口函数文件
//* 作者    			: 焦海波
//* 版本				: 0.1
//* 建立日期、时间		: 2006/06/06 14:50
//* 最近修改日期、时间	: 
//* 修改原因			: 
//*------------------------------------------------------------------------------------------------
//*------------------------------------------ 头文件 -----------------------------------------------
//#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
//*================================================================================================
//*											函	数	区
//*================================================================================================
//*------------------------------------------------------------------------------------------------
//* 函数名称 : InitLwIP
//* 功能描述 : 初始化LwIP
//* 入口参数 : 无
//* 出口参数 : 无
//*------------------------------------------------------------------------------------------------
void InitLwIP(void)
{
	sys_init();
	mem_init();
	memp_init();
	pbuf_init(); 
	netif_init();
	ip_init();
	tcpip_init(NULL, NULL);
	udp_init();
}

//*------------------------------------------------------------------------------------------------
//* 函数名称 : SetupLwIP
//* 功能描述 : 设置LwIP,主要是设置网络接口、建立接收任务等诸如此类的初始设置工作
//* 入口参数 : 无
//* 出口参数 : 无
//*------------------------------------------------------------------------------------------------
void SetupLwIP(void)
{
	extern err_t ethernetif_init(st_netif *stNetif);

	st_ip_addr __stIpAddr, __stNetMask, __stGateway;
	static st_netif __stEMACNetif;

	//* 必须首先调用 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);
}

//*------------------------------------------------------------------------------------------------
//* 函数名称 : T_WEBServer
//* 功能描述 : Web服务器
//* 入口参数 : <pReserved>[in] 保留
//* 出口参数 : 无
//*------------------------------------------------------------------------------------------------
void T_WEBServer(void *pReserved)
{
	//extern void Handler_HTTP(ST_NETCONN *pstConn);
	
	ST_NETCONN *__pstConn, *__pstNewConn;
	
	InitLwIP();

	//* 设置LwIP,主要是设置网络接口、建立接收任务等诸如此类的初始设置工作
	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);
			}
		}*/
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -