在当前的 LwIP 堆栈中、DHCP 和静态 IP 都通过中断和回调函数获取。
是否有人可以通过轮询以太网 Tx 和 RX 标志来帮助我们确定获取 DHCP "IP 所需的更改?
在 while 循环中,我们实施并测试 了以太网 Rx 和 Tx 轮询,发现它可以正常工作(Web 服务器打开,控件对 ping 命令作出响应。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
在当前的 LwIP 堆栈中、DHCP 和静态 IP 都通过中断和回调函数获取。
是否有人可以通过轮询以太网 Tx 和 RX 标志来帮助我们确定获取 DHCP "IP 所需的更改?
在 while 循环中,我们实施并测试 了以太网 Rx 和 Tx 轮询,发现它可以正常工作(Web 服务器打开,控件对 ping 命令作出响应。
您好 QJ、
我们在 LwIP 堆栈中进行了以下更改、
1.要通过轮询获取 DHCP IP,我们已通过轮询 Rx 和 Tx 以太网中断来重复检查状态 DHCP 状态
在 lwipplib.c 文件的 lwIPInit()中
if (ipMode = IPADDR_USE_DHCP)
{
unsigned int DHCP_FLAG = 0;
unsigned int dhcp_ries = 50;
unsigned int count;
unsigned int delay;
while (dhcp_tries --)
{
DHCP_START (&hdkNetIF[instNum]);
状态=&(hdkNetIF[instNum].DHCP->state);
if (dhcp_bound =*状态)
{
DHCP_FLAG = 1;
ipAddrPtr =(unsigned int*)&(hdkNetIF[instNum].ip_addr);
返回(*ipAddrPtr);
}
while (!((*((volatile uint32_t *)(EMAC_BASE + EMAC_MACINVECTOR))和 EMAC_MACINVECTOR_RXPEND))
{
/*等待 RX 接收标志*/
}
lwIPRxIntHandler (0U);
状态=&(hdkNetIF[instNum].DHCP->state);
if (dhcp_bound =*状态)
{
DHCP_FLAG = 1;
ipAddrPtr =(unsigned int*)&(hdkNetIF[instNum].ip_addr);
返回(*ipAddrPtr);
}
while ((*((volatile uint32_t *)(EMAC_BASE + EMAC_MACINVECTOR))和 EMAC_MACINVECTOR_TXPEND)
{
lwIPTxIntHandler (0U);
}
延迟= 0x8FFFFU;
while (delay--);
状态=&(hdkNetIF[instNum].DHCP->state);
if (dhcp_bound =*状态)
{
DHCP_FLAG = 1;
ipAddrPtr =(unsigned int*)&(hdkNetIF[instNum].ip_addr);
返回(*ipAddrPtr);
}
while (!((*((volatile uint32_t *)(EMAC_BASE + EMAC_MACINVECTOR))和 EMAC_MACINVECTOR_RXPEND))
{
/*等待 RX 接收标志*/
}
lwIPRxIntHandler (0U);
状态=&(hdkNetIF[instNum].DHCP->state);
if (dhcp_bound =*状态)
{
DHCP_FLAG = 1;
ipAddrPtr =(unsigned int*)&(hdkNetIF[instNum].ip_addr);
返回(*ipAddrPtr);
}
}
}
2.要通过轮询获取静态 IP,
在 etharp.c 文件的 etharp_raw ()函数中
结果= netif->linkoutput (netif、p);
ETHARP_STATS_INC (etharp.xmit);
while ((*((volatile uint32_t *)(EMAC_BASE + EMAC_MACINVECTOR))和 EMAC_MACINVECTOR_TXPEND)
{
lwIPTxIntHandler (0U);
}
while (!((*((volatile uint32_t *)(EMAC_BASE + EMAC_MACINVECTOR))和 EMAC_MACINVECTOR_RXPEND))
{
/*等待 RX 接收标志*/
}
lwIPRxIntHandler (0U);
/*免费 ARP 查询包*/
pbuf_free (p);
通过使用上述逻辑、如果我们在调试模式下执行代码、我们将获得 IP。 如果我们将代码置于自由运行模式,则始终报告为'0.0.0.0' ip.3。 在主 while 循环中。
请提供建议。
我们对轮询进行了后续更改。
在 while (1)循环中、
if ((*((volatile uint32_t *)(EMAC_BASE + EMAC_MACINVECTOR)))& EMAC_MACINVECTOR_TXPEND)
{
lwIPTxIntHandler (0U);
}
if (((*(volatile uint32_t *)(EMAC_BASE + EMAC_MACINVECTOR))和 EMAC_MACINVECTOR_RXPEND))
{
lwIPRxIntHandler (0U);
}
您好 Pramod、
我不明白您为什么进行了这些更改。 以下代码不起作用? 您是否启用了 INT (VIM 通道77/79)?
DHCP_START (&hdkNetIF[instNum]);
计数= 10;
/*检查 DHCP 完成的“计数”次数,每个时间用于给定的延迟。 *
while (count -)
{
延迟= 0x8FFFFU;
while (delay--);
状态=&(hdkNetIF[instNum].DHCP->state);
if (dhcp_bound =*状态)
{
DHCP_FLAG = 1;
ipAddrPtr =(unsigned int*)&(hdkNetIF[instNum].ip_addr);
返回(*ipAddrPtr);
}
}