Hello!
I didn't get the use of following bold statements of the code,
This example demonstrates the use of the Ethernet Controller and lwIP
// TCP/IP stack to control various peripherals on the board via a web
// browser.
//
//*****************************************************************************
int
main(void)
{
uint32_t ui32User0, ui32User1;
uint8_t pui8MACArray[8];
//
// Make sure the main oscillator is enabled because this is required by
// the PHY. The system must have a 25MHz crystal attached to the OSC
// pins. The SYSCTL_MOSC_HIGHFREQ parameter is used when the crystal
// frequency is 10MHz or higher.
//
SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);
//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet(true, false);
//
// Configure debug port for internal use.
//
UARTStdioConfig(0, 115200, g_ui32SysClock);
//
// Clear the terminal and print a banner.
//
UARTprintf("\033[2J\033[H");
UARTprintf("Ethernet IO Example\n\n");
//
// Configure SysTick for a periodic interrupt.
//
MAP_SysTickPeriodSet(g_ui32SysClock / SYSTICKHZ);
MAP_SysTickEnable();
MAP_SysTickIntEnable();
//
// Configure the hardware MAC address for Ethernet Controller filtering of
// incoming packets. The MAC address will be stored in the non-volatile
// USER0 and USER1 registers.
//
MAP_FlashUserGet(&ui32User0, &ui32User1);
if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
{
//
// Let the user know there is no MAC address
//
UARTprintf("No MAC programmed!\n");
while(1)
{
}
}
//
// Tell the user what we are doing just now.
//
UARTprintf("Waiting for IP.\n");
//
// Convert the 24/24 split MAC address from NV ram into a 32/16 split
// MAC address needed to program the hardware registers, then program
// the MAC address into the Ethernet Controller registers.
//
pui8MACArray[0] = ((ui32User0 >> 0) & 0xff);
pui8MACArray[1] = ((ui32User0 >> 8) & 0xff);
pui8MACArray[2] = ((ui32User0 >> 16) & 0xff);
pui8MACArray[3] = ((ui32User1 >> 0) & 0xff);
pui8MACArray[4] = ((ui32User1 >> 8) & 0xff);
pui8MACArray[5] = ((ui32User1 >> 16) & 0xff);
//
// Initialze the lwIP library, using DHCP.
//
lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_DHCP);
//
// Setup the device locator service.
//
LocatorInit();
LocatorMACAddrSet(pui8MACArray);
LocatorAppTitleSet("EK-TM4C1294XL enet_io");
//
// Initialize a sample httpd server.
//
httpd_init();
//
// Set the interrupt priorities. We set the SysTick interrupt to a higher
// priority than the Ethernet interrupt to ensure that the file system
// tick is processed if SysTick occurs while the Ethernet handler is being
// processed. This is very likely since all the TCP/IP and HTTP work is
// done in the context of the Ethernet interrupt.
//
MAP_IntPrioritySet(INT_EMAC0, ETHERNET_INT_PRIORITY);
MAP_IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
//
// Pass our tag information to the HTTP server.
//
http_set_ssi_handler((tSSIHandler)SSIHandler, g_pcConfigSSITags,
NUM_CONFIG_SSI_TAGS);
//
// Pass our CGI handlers to the HTTP server.
//
http_set_cgi_handlers(g_psConfigCGIURIs, NUM_CONFIG_CGI_URIS);
//
// Initialize IO controls
//
io_init();
//
// Loop forever, processing the on-screen animation. All other work is
// done in the interrupt handlers.
//
while(1)
{
//
// Wait for a new tick to occur.
//
while(!g_ulFlags)
{
//
// Do nothing.
//
}
//
// Clear the flag now that we have seen it.
//
HWREGBITW(&g_ulFlags, FLAG_TICK) = 0;
//
// Toggle the GPIO
//
MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1,
(MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1) ^
GPIO_PIN_1));
}
}
I have the following queries :-
Why we need MAC address and its 24/24 to 32/16 conversion is required ?
Can we omit the lwip from enet_io ? Why do we use the LWIP ?
What is meaning of Locator ?is it pointing to our device ?
If I just wana I/O control Demo2 using HTML cgi function can I omit the LWIP ?
My English is not so good, I apologize.
Regards