static void ethernet_timer_init(void)
{
... ... ...
}
int ethernet_init(void)
{
... ... ...
// Initialize <B style="BACKGROUND-COLOR: #a0ffff; COLOR: black">LWIP</B>
lwip_init();
// Add our netif to <B style="BACKGROUND-COLOR: #a0ffff; COLOR: black">LWIP</B>
if (netif_add(ðernetif, &myip_addr, &netmask, &gw_addr, NULL,
ethernetif_init, <B style="BACKGROUND-COLOR: #ffff66; COLOR: black">ethernet_input</B>) == NULL)
{
return -1;
}
netif_set_default(ðernetif);
netif_set_up(ðernetif);
... ... ...
return 0;
}
void ethernet_poll(void)
{
... ... ...
// Invokes network interface driver to process incoming packets
ethernetif_input(ðernetif);
// Process <B style="BACKGROUND-COLOR: #a0ffff; COLOR: black">lwip</B> network-related timers.
... ... ...
}
int main(void)
{
... ... ...
ethernet_timer_init(); // Initialize timer for <B style="BACKGROUND-COLOR: #a0ffff; COLOR: black">lwip</B> and network interface
ethernet_init();
while (1) {
ethernet_poll(); // Poll network stack
... ... ...
}
}
lwip_循环查询方式_接受数据包
最新推荐文章于 2023-04-02 14:51:53 发布