示例#1
0
/* NOTE: please not use it in interrupt when no RxThread exist */
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up)
{
    if (up == RT_TRUE)
        netifapi_netif_set_link_up(dev->netif);
    else
        netifapi_netif_set_link_down(dev->netif);

    return RT_EOK;
}
示例#2
0
/* Ethernet Rx Thread */
static void eth_rx_thread_entry(void* parameter)
{
    struct eth_device* device;

    while (1)
    {
        if (rt_mb_recv(&eth_rx_thread_mb, (UInt32*)&device, RT_WAITING_FOREVER) == RT_EOK)
        {
            struct pbuf *p;

            /* check link status */
            if (device->link_changed)
            {
                int status;
                UInt32 level;

                level = rt_hw_interrupt_disable();
                status = device->link_status;
                device->link_changed = 0x00;
                rt_hw_interrupt_enable(level);

                if (status)
                    netifapi_netif_set_link_up(device->netif);
                else
                    netifapi_netif_set_link_down(device->netif);
            }

            /* receive all of buffer */
            while (1)
            {
                p = device->eth_rx(&(device->parent));
                if (p != NULL)
                {
                    /* notify to upper layer */
                    if( device->netif->input(p, device->netif) != ERR_OK )
                    {
                        LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: Input error\n"));
                        pbuf_free(p);
                        p = NULL;
                    }
                }
                else break;
            }
        }
        else
        {
            LWIP_ASSERT("Should not happen!\n",0);
        }
    }
}
示例#3
0
/* ethernet buffer */
void eth_rx_thread_entry(void* parameter)
{
	struct eth_device* device;
	err_t err_ret;


	while (1) {
		if (rt_mb_recv(&eth_rx_thread_mb, (rt_uint32_t*)&device, RT_WAITING_FOREVER) == RT_EOK) {
			struct pbuf *p;
			/* check link status */
			if (device->link_changed) {
				int status;
				rt_uint32_t level;

				level = rt_hw_interrupt_disable();
				status = device->link_status;
				device->link_changed = 0x00;
				rt_hw_interrupt_enable(level);

				if (status)
					netifapi_netif_set_link_up(device->netif);
				else
					netifapi_netif_set_link_down(device->netif);
			}

			/* receive all of buffer */
			while (1) {
				p = device->eth_rx(&(device->parent));
				if (p != RT_NULL) {
					/* notify to upper layer */
					if( (err_ret=device->netif->input(p, device->netif)) != ERR_OK ) {
						printf_syn("ethernetif_input: Input error(%d)\n", err_ret);
						pbuf_free(p);
						p = NULL;
					}
				} else {
					break;
				}
			}
		}
	}
}