OS下要包含3个任务,
1、ethernetif_input 用于从中断接收数据包,处理之后转发给tcoip任务。
2、tcpip_thread 收到处理过的数据包进行解析和其他操作
3、用户自定义应用程序
遇到的问题:
1、等待中断数据包进入硬件错误,中断信号量没有初始化。
2、程序不运行,调试模式不能进入main,因为use microLib没有勾选。
3、ping一段时间后延时不断增加,查到如下解决方案 http://blog.sina.com.cn/s/blog_a4e2465a0102ws39.html
void ethernetif_input(void *p_arg)
{
uint8_t err;
struct pbuf *p;
struct netif *netif;
netif = (struct netif *)p_arg;
while(1)
{
OSSemPend(ethSem, 0, &err);
while(1)
{
p = low_level_input(netif);
if (p == NULL)
{
break;
}
if (netif->input(p, netif) != ERR_OK)
{
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
pbuf_free(p);
p = NULL;
}
OSTimeDly(1);
}
}
}