Exemple #1
0
bool startLwip(LWIP_IF* const lwipIfPort)
{
    const unsigned int ifNum = DEFAULT_INST_NUM;
    bool ret;

    /*Initialization of low level device*/
    cpswInit();
    /*Initialization of the PHY and getting of MAC Address.*/
    phyInit(lwipIfPort);
    /*Set ISR for the device*/
    interruptSetup();
    printk("Acquiring IP Address... \n\r" );
    /*Set up lwipIfPort properly for the desired mode*/
    startLwipIf(lwipIfPort);
    /*Start Lwip stack with the desired address*/
    ret = lwIPInit(lwipIfPort, ifNum);

    if(ret)
    {       
        IpAddrDisplay(&cpswNetIF[ifNum].ip_addr);
    }
    else /*Failed lwipinit, Print a message and reset the board*/
    {
        ipFailed();
    }
    return ret;
}
Exemple #2
0
/*
** Action to be taken when the demo is to be driven via Ethernet
*/
static void ActionEnetInit(void)
{
    unsigned int linkFlag = FALSE;

    if(!EnetIfIsUp())
    {
        ContextReset();
        linkFlag = FALSE;
        EnetHttpServerInit();

        if(ipAddr)
        {
            linkFlag = TRUE;
        }
    }
    else
    {
        if(EnetLinkIsUp())
        {
            linkFlag = TRUE;
        }
        else
        {
            ContextReset();
            linkFlag = FALSE;
        }
    }

    if((TRUE == linkFlag) && (ipAddr != 0))
    {
        ConsoleUtilsPrintf("\n\rAccess the home page using http://");
        IpAddrDisplay();
        ConsoleUtilsPrintf("/index.html \n\r");
    }
    else
    {
        ConsoleUtilsPrintf("\n\rNetwork Connection failed.\n\r");
    }

    UpdateUartConsoleHelp();
}
/*
** The main function
*/
int main(void)
{
    unsigned int ipAddr;
    LWIP_IF lwipIfPort1, lwipIfPort2;

    MMUConfigAndEnable();

#ifdef LWIP_CACHE_ENABLED
    CacheEnable(CACHE_ALL);
#endif

    CPSWPinMuxSetup();
    CPSWClkEnable();

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();

    /* Select the console type based on compile time check */
    ConsoleUtilsSetType(CONSOLE_UART);

    /* Chip configuration RGMII selection */
    EVMPortMIIModeSelect();

    /* Get the MAC address */
    EVMMACAddrGet(0, lwipIfPort1.macArray); 
    EVMMACAddrGet(1, lwipIfPort2.macArray); 

    AintcCPSWIntrSetUp();
    //DelayTimerSetup();

    ConsoleUtilsPrintf("\n\rStarterWare Ethernet Echo Application. \n\r\n\r" );
   
    ConsoleUtilsPrintf("Acquiring IP Address for Port 1... \n\r" );

#if STATIC_IP_ADDRESS_PORT1

    lwipIfPort1.instNum = 0;
    lwipIfPort1.slvPortNum = 1; 
    lwipIfPort1.ipAddr = STATIC_IP_ADDRESS_PORT1; 
    lwipIfPort1.netMask = 0; 
    lwipIfPort1.gwAddr = 0; 
    lwipIfPort1.ipMode = IPADDR_USE_STATIC; 

    ipAddr = lwIPInit(&lwipIfPort1);

#else

    lwipIfPort1.instNum = 0;
    lwipIfPort1.slvPortNum = 1; 
    lwipIfPort1.ipAddr = 0; 
    lwipIfPort1.netMask = 0; 
    lwipIfPort1.gwAddr = 0; 
    lwipIfPort1.ipMode = IPADDR_USE_DHCP; 

    ipAddr = lwIPInit(&lwipIfPort1);

#endif
    if(ipAddr)
    {
        ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Assigned: ");
        IpAddrDisplay(ipAddr);
    }
    else
    {
        ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Acquisition Failed.");
    }

    /* Initialize the sample httpd server. */
    echo_init();
   
    /* Loop forever.  All the work is done in interrupt handlers. */
    while(1)
    {
        ; /* Perform nothing */
    }
}
Exemple #4
0
/*
** Check for any change in ethernet link status. If so, update
** ip address
*/
static void EnetStatusCheckNUpdate(void)
{
    unsigned int linkFlag = FALSE;
    static unsigned int prevEnState = 0;
    static unsigned int nxtEnState = 1;

    if(prevEnState != nxtEnState)
    {
        if(!EnetIfIsUp())
        {
            ContextReset();
            linkFlag = FALSE;
            EnetHttpServerInit( IPAddress );

            if(ipAddr)
            {
                linkFlag = TRUE; 
                prevEnState = 1;
            }
        }
        else
        {
            if(EnetLinkIsUp())
            {
                linkFlag = TRUE;
                nxtEnState = 1;
            }
            else
            {
                ContextReset();
                linkFlag = FALSE;
                prevEnState = 0;
                nxtEnState = 0;
            }
        }

        if((TRUE == linkFlag) && (ipAddr != 0))
        {
            prevEnState = 1;
            UARTPuts("\n\rAccess the home page using http://", -1);
            IpAddrDisplay();
            UARTPuts("/index.html \n\r", -1);
            LedOn( USER_LED_4 );
        }
        else
        {
            UARTPuts("\n\rNetwork Connection failed.\n\r", -1);
            LedOff( USER_LED_4 );
        }
    }
    else
    {
        if(EnetLinkIsUp())
        {  
            nxtEnState = 1;
        }
        else
        {
            nxtEnState = 0;
        }
    }
}