コード例 #1
0
ファイル: demo_ethe.c プロジェクト: eyeye/LPC1788_Demos
void ETHE_Task(void *p_arg)
{
    (void)p_arg;

    ip_addr_t ipaddr, netmask, gw;
    volatile s32_t tcpipdone = 0;

    /* Wait until the TCP/IP thread is finished before
       continuing or wierd things may happen */
    LWIP_DEBUGF(LWIP_DBG_ON, ("Waiting for TCPIP thread to initialize...\n"));
    tcpip_init(tcpip_init_done_signal, (void*)&tcpipdone);
    while (!tcpipdone)
    {
        sys_msleep(20);
    }

    LWIP_DEBUGF(LWIP_DBG_ON, ("Starting LWIP TCP echo server...\n"));

    /* Static IP assignment */
#if LWIP_DHCP
    IP4_ADDR(&gw, 0, 0, 0, 0);
    IP4_ADDR(&ipaddr, 0, 0, 0, 0);
    IP4_ADDR(&netmask, 0, 0, 0, 0);
#else
    IP4_ADDR(&gw, 192, 168, 1, 1);
    IP4_ADDR(&ipaddr, 192, 168, 1, 234);
    IP4_ADDR(&netmask, 255, 255, 255, 0);
#endif

    /* Add netif interface for lpc17xx_8x */
    memset((void*)&lpc_netif, 0, sizeof(lpc_netif));
    if (!netif_add(&lpc_netif, &ipaddr, &netmask, &gw, NULL, lpc_enetif_init,
        tcpip_input))
        LWIP_ASSERT("Net interface failed to initialize\r\n", 0);

    netif_set_default(&lpc_netif);
    netif_set_up(&lpc_netif);

    /* Enable MAC interrupts */
    NVIC_SetPriority(ENET_IRQn, ((0x01 << 3) | 0x01));
    NVIC_EnableIRQ(ENET_IRQn);

#if LWIP_DHCP
    dhcp_start(&lpc_netif);
#endif

    /* Initialize and start application */
    tcpecho_init();

    /* This loop monitors the PHY link and will handle cable events
       via the PHY driver. */
    while (1)
    {
        /* Call the PHY status update state machine once in a while
           to keep the link status up-to-date */
        if (lpc_phy_sts_sm(&lpc_netif) != 0) {
            /* Set the state of the LED to on if the ethernet link is
               active or off is disconnected. */
            if (lpc_netif.flags & NETIF_FLAG_LINK_UP)
                LED_On(3);
            else
                LED_Off(3);
        }

        /* Non-blocking delay for link detection */
        sys_msleep(250);
    }
}
コード例 #2
0
ファイル: lpc17_emac.c プロジェクト: mgramli1/pyelixys
/* periodic PHY status update */
void phy_update(void const *nif) {
    lpc_phy_sts_sm((struct netif*)nif);
}
コード例 #3
0
ファイル: ea1788_http_freertos.c プロジェクト: 10code/lwip
/** \brief  LWIP kickoff and PHY link monitor thread

	\param[in]    pvParameters    Not used
	\return       Does not return
 */
static portTASK_FUNCTION( vSetupIFTask, pvParameters )
{
	ip_addr_t ipaddr, netmask, gw;
	volatile s32_t tcpipdone = 0;

	/* Wait until the TCP/IP thread is finished before
	   continuing or wierd things may happen */
	LWIP_DEBUGF(LWIP_DBG_ON, ("Waiting for TCPIP thread to initialize...\n"));
	tcpip_init(tcpip_init_done_signal, &tcpipdone);
	while (!tcpipdone);

	LWIP_DEBUGF(LWIP_DBG_ON, ("Starting LWIP HTTP server...\n"));

	/* Static IP assignment */
#if LWIP_DHCP
	IP4_ADDR(&gw, 0, 0, 0, 0);
	IP4_ADDR(&ipaddr, 0, 0, 0, 0);
	IP4_ADDR(&netmask, 0, 0, 0, 0);
#else
	IP4_ADDR(&gw, 10, 1, 10, 1);
	IP4_ADDR(&ipaddr, 10, 1, 10, 234);
	IP4_ADDR(&netmask, 255, 255, 255, 0);
	APP_PRINT_IP(&ipaddr);
#endif

	/* Add netif interface for lpc17xx_8x */
	memset(lpc_netif, 0, sizeof(lpc_netif));
	if (!netif_add(&lpc_netif, &ipaddr, &netmask, &gw, NULL, lpc_enetif_init,
		ethernet_input))
		LWIP_ASSERT("Net interface failed to initialize\r\n", 0);

	netif_set_default(&lpc_netif);
	netif_set_up(&lpc_netif);

   	/* Enable MAC interrupts */
   	NVIC_SetPriority(ENET_IRQn, ((0x01 << 3) | 0x01));
    NVIC_EnableIRQ(ENET_IRQn);

#if LWIP_DHCP
	dhcp_start(&lpc_netif);
#endif

	/* Initialize and start application */
	http_server_netconn_init();

	/* This loop monitors the PHY link and will handle cable events
	   via the PHY driver. */
	while (1)
	{
		/* Call the PHY status update state machine once in a while
		   to keep the link status up-to-date */
		if (lpc_phy_sts_sm(&lpc_netif) != 0) {
			/* Set the state of the LED to on if the ethernet link is
			   active or off is disconnected. */
			if (lpc_netif.flags & NETIF_FLAG_LINK_UP)
				led_set(1);
			else
				led_set(0);
		}

		/* Non-blocking delay for link detection */
		msDelay(250);
	}
}