This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Being thrown into Fault ISR when using enet_io example

Other Parts Discussed in Thread: LM3S8962, EK-LM3S8962, LM3S6965

Hey,

So I've been using the enet_io example to control some io of the Stellaris using the lm3s8962 eval board.  I modified it in order to be able to use Uart send and receive but am running into trouble when the website attempts to send a toggle request externally over uart tx.  Here's all the code ive modified:

//*****************************************************************************
//
// enet_io.c - I/O control via a web server.
//
// Copyright (c) 2007-2011 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 7243 of the EK-LM3S8962 Firmware Package.
//
//*****************************************************************************

#include <string.h>
#include <stdlib.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#include "driverlib/ethernet.h"
#include "driverlib/flash.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "utils/locator.h"
#include "utils/lwiplib.h"
#include "utils/uartstdio.h"
#include "utils/ustdlib.h"
#include "httpserver_raw/httpd.h"
#include "drivers/rit128x96x4.h"
#include "io.h"
#include "cgifuncs.h"
#include "driverlib/debug.h"
#include "driverlib/hibernate.h"
#include "driverlib/uart.h"
#include "inc/lm3s8962.h"
#include "inc/hw_pwm.h"
#include "driverlib/pwm.h"


void UART_Config();
//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Ethernet-based I/O Control (enet_io)</h1>
//!
//! This example application demonstrates web-based I/O control using the
//! Stellaris Ethernet controller and the lwIP TCP/IP Stack.  DHCP is used to
//! obtain an Ethernet address.  If DHCP times out without obtaining an
//! address, a static IP address will be chosen using AutoIP.  The address that
//! is selected will be shown on the OLED display allowing you to access the
//! internal web pages served by the application via your normal web browser.
//!
//! Two different methods of controlling board peripherals via web pages are
//! illustrated via pages labelled "IO Control Demo 1" and "IO Control Demo 2"
//! in the navigation menu on the left of the application's home page.
//!
//! "IO Control Demo 1" uses JavaScript running in the web browser to send
//! HTTP requests for particular special URLs.  These special URLs are
//! intercepted in the file system support layer (lmi_fs.c) and used to
//! control the LED and speaker PWM.  Responses generated by the board are
//! returned to the browser and inserted into the page HTML dynamically by
//! more JavaScript code.
//!
//! "IO Control Demo 2" uses standard HTML forms to pass parameters to CGI
//! (Common Gateway Interface) handlers running on the board.  These handlers
//! process the form data and control the PWM and LED as requested before
//! sending a response page (in this case, the original form) back to the
//! browser.  The application registers the names and handlers for each of its
//! CGIs with the HTTPD server during initialization and the server calls
//! these handlers after parsing URL parameters each time one of the CGI URLs
//! is requested.
//!
//! Information on the state of the various controls in the second demo is
//! inserted into the served HTML using SSI (Server Side Include) tags which
//! are parsed by the HTTPD server in the application.  As with the CGI
//! handlers, the application registers its list of SSI tags and a handler
//! function with the web server during initialization and this handler is
//! called whenever any registered tag is found in a .shtml, .ssi or .shtm
//! file being served to the browser.
//!
//! Note that the web server used by this example has been modified from the
//! example shipped with the basic lwIP package.  Additions include SSI and
//! CGI support along with the ability to have the server automatically insert
//! the HTTP headers rather than having these built in to the files in the
//! file system image.
//!
//! For additional details on lwIP, refer to the lwIP web page at:
//! http://savannah.nongnu.org/projects/lwip/
//
//*****************************************************************************



//*****************************************************************************
//
// A set of flags.  The flag bits are defined as follows:
//
//     0 -> An indicator that a SysTick interrupt has occurred.
//
//*****************************************************************************
#define FLAG_SYSTICK            0
static volatile unsigned long g_ulFlags;

//*****************************************************************************
//
// External Application references.
//
//*****************************************************************************
extern void httpd_init(void);

//*****************************************************************************
//
// SSI tag indices for each entry in the g_pcSSITags array.
//
//*****************************************************************************
#define SSI_INDEX_LEDSTATE  0
#define SSI_INDEX_PWMSTATE  1
#define SSI_INDEX_PWMFREQ   2
#define SSI_INDEX_PWMDUTY   3
#define SSI_INDEX_FORMVARS  4

//*****************************************************************************
//
// This array holds all the strings that are to be recognized as SSI tag
// names by the HTTPD server.  The server will call SSIHandler to request a
// replacement string whenever the pattern <!--#tagname--> (where tagname
// appears in the following array) is found in ".ssi", ".shtml" or ".shtm"
// files that it serves.
//
//*****************************************************************************
static const char *g_pcConfigSSITags[] =
{
    "LEDtxt",        // SSI_INDEX_LEDSTATE
    "PWMtxt",        // SSI_INDEX_PWMSTATE
    "PWMfreq",       // SSI_INDEX_PWMFREQ
    "PWMduty",       // SSI_INDEX_PWMDUTY
    "FormVars"       // SSI_INDEX_FORMVARS
};

//*****************************************************************************
//
//! The number of individual SSI tags that the HTTPD server can expect to
//! find in our configuration pages.
//
//*****************************************************************************
#define NUM_CONFIG_SSI_TAGS     (sizeof(g_pcConfigSSITags) / sizeof (char *))

//*****************************************************************************
//
//! Prototypes for the various CGI handler functions.
//
//*****************************************************************************
static char *ControlCGIHandler(int iIndex, int iNumParams, char *pcParam[],
                              char *pcValue[]);
static char *SetTextCGIHandler(int iIndex, int iNumParams, char *pcParam[],
                              char *pcValue[]);

//*****************************************************************************
//
//! Prototype for the main handler used to process server-side-includes for the
//! application's web-based configuration screens.
//
//*****************************************************************************
static int SSIHandler(int iIndex, char *pcInsert, int iInsertLen);

//*****************************************************************************
//
// CGI URI indices for each entry in the g_psConfigCGIURIs array.
//
//*****************************************************************************
#define CGI_INDEX_CONTROL       0
#define CGI_INDEX_TEXT          1

//*****************************************************************************
//
//! This array is passed to the HTTPD server to inform it of special URIs
//! that are treated as common gateway interface (CGI) scripts.  Each URI name
//! is defined along with a pointer to the function which is to be called to
//! process it.
//
//*****************************************************************************
static const tCGI g_psConfigCGIURIs[] =
{
    { "/iocontrol.cgi", ControlCGIHandler },      // CGI_INDEX_CONTROL
    { "/settxt.cgi", SetTextCGIHandler }          // CGI_INDEX_TEXT
};

//*****************************************************************************
//
//! The number of individual CGI URIs that are configured for this system.
//
//*****************************************************************************
#define NUM_CONFIG_CGI_URIS     (sizeof(g_psConfigCGIURIs) / sizeof(tCGI))

//*****************************************************************************
//
//! The file sent back to the browser by default following completion of any
//! of our CGI handlers.  Each individual handler returns the URI of the page
//! to load in response to it being called.
//
//*****************************************************************************
#define DEFAULT_CGI_RESPONSE    "/io_cgi.ssi"

//*****************************************************************************
//
//! The file sent back to the browser in cases where a parameter error is
//! detected by one of the CGI handlers.  This should only happen if someone
//! tries to access the CGI directly via the broswer command line and doesn't
//! enter all the required parameters alongside the URI.
//
//*****************************************************************************
#define PARAM_ERROR_RESPONSE    "/perror.htm"

#define JAVASCRIPT_HEADER                                                     \
    "<script type='text/javascript' language='JavaScript'><!--\n"
#define JAVASCRIPT_FOOTER                                                     \
    "//--></script>\n"

//*****************************************************************************
//
// Timeout for DHCP address request (in seconds).
//
//*****************************************************************************
#ifndef DHCP_EXPIRE_TIMER_SECS
#define DHCP_EXPIRE_TIMER_SECS  45
#endif

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif

//******************************************************************************
//
//UART_Config()
//
//This config function is built to set up all pin configurations, constants and
//    other values the need to be pre-configured before using the functions run
//    within.
//
//Inputs: None
//
//Return Values: None
//******************************************************************************
void
UART_Config()
{
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);


    //
    // Set GPIO A0 and A1 as UART pins.
    //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Configure the UART for 9600, 8-N-1 operation.
    //
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600,
                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                         UART_CONFIG_PAR_NONE));

    //
    // Enable the UART interrupt.
    //
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    
}

//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
    //
    //Set default error value
    //
    char returnCharacter = MSG_ERROR;
    unsigned long ulStatus;


    //
    // Get the interrrupt status.
    //
    ulStatus = UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    UARTIntClear(UART0_BASE, ulStatus);
    

    //
    // Loop while there are characters in the receive FIFO.
    //
    while(UARTCharsAvail(UART0_BASE))
    {
        UART_Receive();
    }
    return;
}


//*****************************************************************************
//
// This CGI handler is called whenever the web browser requests iocontrol.cgi.
//
//*****************************************************************************
static char *
ControlCGIHandler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
{
    tBoolean bParamError;
    long lLEDState, lPWMState, lPWMDutyCycle, lPWMFrequency;

    //
    // We have not encountered any parameter errors yet.
    //
    bParamError = false;

    //
    // Get each of the 4 expected parameters.
    //
    lLEDState = FindCGIParameter("LEDOn", pcParam, iNumParams);
    lPWMState = FindCGIParameter("PWMOn", pcParam, iNumParams);
    lPWMDutyCycle = GetCGIParam("PWMDutyCycle", pcParam, pcValue, iNumParams,
                                &bParamError);
    lPWMFrequency = GetCGIParam("PWMFrequency", pcParam, pcValue, iNumParams,
                                &bParamError);

    //
    // Was there any error reported by the parameter parser?
    //
    if(bParamError || (lPWMDutyCycle < 0) || (lPWMDutyCycle > 100) ||
       (lPWMFrequency < 200) || (lPWMFrequency > 20000))
    {
        return(PARAM_ERROR_RESPONSE);
    }

    //
    // We got all the parameters and the values were within the expected ranges
    // so go ahead and make the changes.
    //
    io_set_device(((lLEDState == -1) ? false : true), 'x'); //default all; add extra parameter pertaining to device being set as on/off


    //
    // Send back the default response page.
    //
    return(DEFAULT_CGI_RESPONSE);
}

//*****************************************************************************
//
// This CGI handler is called whenever the web browser requests settxt.cgi.
//
//*****************************************************************************
static char *
SetTextCGIHandler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
{
    long lStringParam;
    char pcDecodedString[24];

    //
    // Find the parameter that has the string we need to display.
    //
    lStringParam = FindCGIParameter("DispText", pcParam, iNumParams);

    //
    // If the parameter was not found, show the error page.
    //
    if(lStringParam == -1)
    {
        return(PARAM_ERROR_RESPONSE);
    }

    //
    // The parameter is present. We need to decode the text for display.
    //
    DecodeFormString(pcValue[lStringParam], pcDecodedString, 24);

    //
    // Claim the SSI for communication with the display.
    //
    RIT128x96x4Enable(1000000);

    //
    // Erase the previous string and overwrite it with the new one.
    //
    RIT128x96x4StringDraw("                      ", 0, 64, 12);
    RIT128x96x4StringDraw(pcDecodedString, 0, 64, 12);

    //
    // Release the SSI.
    //
    RIT128x96x4Disable();

    //
    // Tell the HTTPD server which file to send back to the client.
    //
    return(DEFAULT_CGI_RESPONSE);
}

//*****************************************************************************
//
// This function is called by the HTTP server whenever it encounters an SSI
// tag in a web page.  The iIndex parameter provides the index of the tag in
// the g_pcConfigSSITags array. This function writes the substitution text
// into the pcInsert array, writing no more than iInsertLen characters.
//
//*****************************************************************************
static int
SSIHandler(int iIndex, char *pcInsert, int iInsertLen)
{
     unsigned long ulVal;

    //
    // Which SSI tag have we been passed?
    //
    switch(iIndex)
    {
        case SSI_INDEX_LEDSTATE:
            io_get_ledstate(pcInsert, iInsertLen, 'x', 100000); //not using SSI so this doesn't really matter; get state based on device; add extra parameter
            break;

        case SSI_INDEX_PWMSTATE:
            io_get_pwmstate(pcInsert, iInsertLen);
            break;

        case SSI_INDEX_PWMFREQ:
            ulVal = io_get_pwmfreq();
            usnprintf(pcInsert, iInsertLen, "%d", ulVal);
            break;

        case SSI_INDEX_PWMDUTY:
            ulVal = io_get_pwmdutycycle();
            usnprintf(pcInsert, iInsertLen, "%d", ulVal);
            break;

        case SSI_INDEX_FORMVARS:
            usnprintf(pcInsert, iInsertLen,
                      "%sps=%d;\nls=%d;\npf=%d;\npd=%d;\n%s",
                      JAVASCRIPT_HEADER,
                      io_is_pwm_on(),
                      io_is_led_on('a', 100000),
                      io_get_pwmfreq(),
                      io_get_pwmdutycycle(),
                      JAVASCRIPT_FOOTER);
            break;

        default:
            usnprintf(pcInsert, iInsertLen, "??");
            break;
    }

    //
    // Tell the server how many characters our insert string contains.
    //
    return(strlen(pcInsert));

}

//*****************************************************************************
//
// Display an lwIP type IP Address.
//
//*****************************************************************************
void
DisplayIPAddress(unsigned long ipaddr, unsigned long ulCol,
                 unsigned long ulRow)
{
    char pucBuf[16];
    unsigned char *pucTemp = (unsigned char *)&ipaddr;

    //
    // Convert the IP Address into a string.
    //
    usprintf(pucBuf, "%d.%d.%d.%d", pucTemp[0], pucTemp[1], pucTemp[2],
             pucTemp[3]);

    //
    // Display the string.
    //
    RIT128x96x4StringDraw(pucBuf, ulCol, ulRow, 15);
}

//*****************************************************************************
//
// The interrupt handler for the SysTick interrupt.
//
//*****************************************************************************
void
SysTickIntHandler(void)
{
    //
    // Indicate that a SysTick interrupt has occurred.
    //
    HWREGBITW(&g_ulFlags, FLAG_SYSTICK) = 1;

    //
    // Call the lwIP timer handler.
    //
    lwIPTimer(SYSTICKMS);
}

//*****************************************************************************
//
// Required by lwIP library to support any host-related timer functions.
//
//*****************************************************************************
void
lwIPHostTimerHandler(void)
{
    static unsigned long ulLastIPAddress = 0;
    unsigned long ulIPAddress;

    ulIPAddress = lwIPLocalIPAddrGet();

    //
    // If IP Address has not yet been assigned, update the display accordingly
    //
    if(ulIPAddress == 0)
    {
        static int iColumn = 6;

        //
        // Update status bar on the display.
        //
        RIT128x96x4Enable(1000000);
        if(iColumn < 12)
        {
            RIT128x96x4StringDraw(" >", 114, 24, 15);
            RIT128x96x4StringDraw("< ", 0, 24, 15);
            RIT128x96x4StringDraw("*",iColumn, 24, 7);
        }
        else
        {
            RIT128x96x4StringDraw(" *",iColumn - 6, 24, 7);
        }

        iColumn += 4;
        if(iColumn > 114)
        {
            iColumn = 6;
            RIT128x96x4StringDraw(" >", 114, 24, 15);
        }
        RIT128x96x4Disable();
    }

    //
    // Check if IP address has changed, and display if it has.
    //
    else if(ulLastIPAddress != ulIPAddress)
    {
        ulLastIPAddress = ulIPAddress;
        RIT128x96x4Enable(1000000);
        RIT128x96x4StringDraw("                       ", 0, 16, 15);
        RIT128x96x4StringDraw("                       ", 0, 24, 15);
        RIT128x96x4StringDraw("IP:   ", 0, 16, 15);
        RIT128x96x4StringDraw("MASK: ", 0, 24, 15);
        RIT128x96x4StringDraw("GW:   ", 0, 32, 15);
        DisplayIPAddress(ulIPAddress, 36, 16);
        ulIPAddress = lwIPLocalNetMaskGet();
        DisplayIPAddress(ulIPAddress, 36, 24);
        ulIPAddress = lwIPLocalGWAddrGet();
        DisplayIPAddress(ulIPAddress, 36, 32);
        RIT128x96x4Disable();
    }
}

//*****************************************************************************
//
// 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)
{
    unsigned long ulUser0, ulUser1;
    unsigned char pucMACArray[8];



    
    //
    // Initialize the OLED display.
    //
    RIT128x96x4Init(1000000);
    RIT128x96x4StringDraw("Web-Based I/O Control", 0, 0, 15);
    RIT128x96x4StringDraw("Browser Message:", 0, 53, 15);

    //
    // Enable and Reset the Ethernet Controller.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
    SysCtlPeripheralReset(SYSCTL_PERIPH_ETH);

    //
    // Enable Port F for Ethernet LEDs.
    //  LED0        Bit 3   Output
    //  LED1        Bit 2   Output
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);

    //
    // Configure SysTick for a periodic interrupt.
    //
    SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
    SysTickEnable();
    SysTickIntEnable();

    //
    // Configure the hardware MAC address for Ethernet Controller filtering of
    // incoming packets.
    //
    // For the LM3S6965 Evaluation Kit, the MAC address will be stored in the
    // non-volatile USER0 and USER1 registers.  These registers can be read
    // using the FlashUserGet function, as illustrated below.
    //
    FlashUserGet(&ulUser0, &ulUser1);
    if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff))
    {
        //
        // We should never get here.  This is an error if the MAC address
        // has not been programmed into the device.  Exit the program.
        //
        RIT128x96x4StringDraw("MAC Address", 0, 16, 15);
        RIT128x96x4StringDraw("Not Programmed!", 0, 24, 15);
        while(1);
    }

    //
    // 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.
    //
    pucMACArray[0] = ((ulUser0 >>  0) & 0xff);
    pucMACArray[1] = ((ulUser0 >>  8) & 0xff);
    pucMACArray[2] = ((ulUser0 >> 16) & 0xff);
    pucMACArray[3] = ((ulUser1 >>  0) & 0xff);
    pucMACArray[4] = ((ulUser1 >>  8) & 0xff);
    pucMACArray[5] = ((ulUser1 >> 16) & 0xff);

    //
    // Initialze the lwIP library, using DHCP.
    //
    lwIPInit(pucMACArray, 0, 0, 0, IPADDR_USE_DHCP);

    //
    // Setup the device locator service.
    //
    LocatorInit();
    LocatorMACAddrSet(pucMACArray);
    LocatorAppTitleSet("EK-LM3S8962 enet_io");

    //
    // Initialize a sample httpd server.
    //
    httpd_init();


    //
    // Pass our CGI handlers to the HTTP server.
    //
    http_set_cgi_handlers(g_psConfigCGIURIs, NUM_CONFIG_CGI_URIS);


    initializeMemory();    
    //
    // Loop forever.  All the work is done in interrupt handlers.
    
    //
    //Set initial configurations
    //
    UART_Config();
    //
    while(1)
    {
    }
}

//*****************************************************************************
//
// io.c - I/O routines for the enet_io example application.
//
// Copyright (c) 2007-2011 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 7243 of the EK-LM3S8962 Firmware Package.
//
//*****************************************************************************

#include <string.h>
#include <stdlib.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#include "driverlib/ethernet.h"
#include "driverlib/flash.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "utils/locator.h"
#include "utils/lwiplib.h"
#include "utils/uartstdio.h"
#include "utils/ustdlib.h"
#include "httpserver_raw/httpd.h"
#include "drivers/rit128x96x4.h"
#include "driverlib/debug.h"
#include "driverlib/hibernate.h"
#include "driverlib/uart.h"
#include "inc/lm3s8962.h"
#include "inc/hw_pwm.h"
#include "driverlib/pwm.h"
#include "io.h"


int MEM_START[TOTAL_DEVICES];

//*****************************************************************************
//
// Default all mem locations to -1
//
//*****************************************************************************
void initializeMemory()
{
    int i;
    for(i = 0; i < TOTAL_DEVICES; i++)
    {
        if(i == 5)
        {
            MEM_START[i] = 0;
        }
        else
            MEM_START[i] = -1;
    }
}

int memHash(char key)
{
    int m1 = 0, m2 = 0, m4 = 0;
    char h1, h2, h4;
    h1 = (key & HASH_MASK_1) >> 1;
    if((h1&0x01) == 0x01)
    {
        m1 = 1;
    }
    
    if((h1&0x02) == 0x02)
    {
        m1 += 2;
    }
    
    h2 = (key & HASH_MASK_2) >> 3;
    if((h2&0x01) == 0x01)
    {
        m2 = 1;
    }
    h4 = (key & HASH_MASK_4) >> 4;
    if((h4&0x01) == 0x01)
    {
        m4 = 1;
    }
    
    if((h4&0x02) == 0x02)
    {
        m4 += 2;
    }

    return (m1 + m2*2 + m4*4);
}
    
    
//*****************************************************************************
//
// LEDON used to flash a status LED on and off for debugging purposes
//
//*****************************************************************************
void
LEDON()
{
    volatile unsigned long ulLoop;

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;

    //
    // Do a dummy read to insert a few cycles after enabling the peripheral.
    //
    ulLoop = SYSCTL_RCGC2_R;

    //
    // Enable the GPIO pin for the LED (PF0).  Set the direction as output, and
    // enable the GPIO pin for digital function.
    //
    GPIO_PORTF_DIR_R = 0x01;
    GPIO_PORTF_DEN_R = 0x01;

        //
        // Turn on the LED.
        //
        GPIO_PORTF_DATA_R |= 0x01;

        //
        // Delay for a bit.
        //
        SysCtlDelay(800000);

        //
        // Turn off the LED.
        //
        GPIO_PORTF_DATA_R &= ~(0x01);
}



//******************************************************************************
//
//UART_Send()
//
//This send function takes in a char (2 hex bits) and outputs it to the FIFO
//    to be output via the RF module; Waits for Received value to confirm successful send
//
//Inputs: char dataOut - data to be sent out to corresponding address
//
//Return Values: none
//
//******************************************************************************
void    
UART_Send(char dataOut, int timeout)
{
    int x = 1000;
    char ack, addr, addr2, valid;
    //Send out character automatically
    UARTCharPutNonBlocking(UART0_BASE, dataOut);
    
    //Flash LED for debugging purposes
    LEDON();
    SysCtlDelay(400000);
    LEDON();
    if(dataOut & 0x0F != 0x0F)
    {
        ack = UART_Receive();
        addr = ack & 0xF0;
        addr2 = dataOut & 0xF0;
        valid = ack & 0x0F;
        //Try to send at changing intervals until defined timeout occurs
        while(addr != addr2 || valid != 0x0F || addr2 != 0x0F || timeout < TIMEOUT)    
        {
            UART_Send(dataOut, timeout++);
            SysCtlDelay(x*timeout);
        }
    }
}

//******************************************************************************
//
//UART_Receive()
//
//This receive function takes in no value; It is called when the FIFO buffer is
//    full, meaning data has been sent in and therefore the data needs to be read
//    in
//
//Inputs: none
//
//Return Values: char value that is the dataIn value returned from the function
//
//******************************************************************************    
char
UART_Receive()
{
    char receiveCharacter, valid;
    
    //
    //Return character that's in the FIFO Buffer
    //
    receiveCharacter = (char)UARTCharGetNonBlocking(UART0_BASE);
    
    LEDON();
    
    valid = receiveCharacter & 0x0F;
    if(valid != 0x0F && receiveCharacter != 255)
    {
        UART_Store(receiveCharacter);
    }
    UART_Send(receiveCharacter || 0x1F, 1);
    return receiveCharacter;
}

//******************************************************************************
//
//UART_Store()
//
//This store function takes in the latest status as sent by one of the MSP430
//    devices and stores that status within the corresponding status register
//
//Inputs: char dataIn - value containing both address of device and latest
//    configuration of said device
//
//Return Values: none
//
//******************************************************************************        
void
UART_Store(char data)
{
    int index = memHash(data);
    data&= DEV_STATUS_MASK;
    MEM_START[index] = (int)data;
    
}

//******************************************************************************
//
//UART_Retrieve()
//
//This store function retrieves the latest status when requested and returns
//    that status as requested in the form of a char value
//
//Inputs: char address - address used to move to correct place in register
//    in order to locate status of device at said address
//
//Return Values: char value which is the address passed in with the status
//appended to it
//
//******************************************************************************     
int
UART_Retrieve(char address)
{
    int index;
    index = memHash(address);
    return MEM_START[index];
}

//*****************************************************************************
//
// Set the status LED on or off.
//
//*****************************************************************************
void
io_set_device(int isOn, char data)
{
       
    //Send out status to device as requested by parameter passed in
    if(isOn == 1)
    {
        data |= DEV_STATUS_MASK;
    }
    else
    {
        data |= ~(DEV_STATUS_MASK);
    }
    UART_Send(data, 1);
    //Store new configuration
    UART_Store(data);
}

//*****************************************************************************
//
// Return LED state
//
//*****************************************************************************
void
io_get_devstate(char * pcBuf, int iBufLen, char location, int delayTime)
{
    //
    // Get the state of the LED
    //
    if(UART_Retrieve(location) == 1)
    {
        //usnprintf(pcBuf, iBufLen, "ON");
    }
    else if(UART_Retrieve(location) == 0)
    {
        //usnprintf(pcBuf, iBufLen, "OFF");
    }
    //Device status unknown
    else if(delayTime > MAX_DELAY)
    {
        return;
    }
    else
    {
        //Send out for status;  In doing so, write new status to mem location; Now, recursively call io_is_led_on again
        location |= REQUEST_MASK;
        UART_Send(location, 1);
        SysCtlDelay(delayTime);
        io_get_devstate(pcBuf, iBufLen, location, delayTime*10);
    }

}

//*****************************************************************************
//
// Return LED state as an integer, 1 on, 0 off.
//
//*****************************************************************************
int
io_is_dev_on(char locChar, int delayTime)
{
    //
    // Get the state of the LED
    //
    if(UART_Retrieve(locChar) == 1)
    {
        return(1);
    }
    else if(UART_Retrieve(locChar) == 0)
    {
        return(0);
    }
    //Device Status unknown
    else if(delayTime > MAX_DELAY)
    {
        return (-1);
    }
    else
    {
        //Send out for status;  In doing so, write new status to mem location; Now, recursively call io_is_led_on again
        locChar |= REQUEST_MASK;
        UART_Send(locChar, 1);
        SysCtlDelay(delayTime);
        return io_is_dev_on(locChar, delayTime*10);
    }
}

//*****************************************************************************
//
// lmi_fs.c - File System Processing for enet_io application.
//
// Copyright (c) 2007-2011 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 7243 of the EK-LM3S8962 Firmware Package.
//
//*****************************************************************************

#include <string.h>
#include "inc/hw_types.h"
#include "utils/lwiplib.h"
#include "utils/ustdlib.h"
#include "httpserver_raw/fs.h"
#include "httpserver_raw/fsdata.h"
#include "io.h"


//*****************************************************************************
//
// Include the file system data for this application.  This file is generated
// by the makefsfile utility, using the following command (all on one line):
//
//     makefsfile -i fs -o io_fsdata.h -r -h
//
// If any changes are made to the static content of the web pages served by the
// application, this script must be used to regenerate io_fsdata.h in order
// for those changes to be picked up by the web server.
//
//*****************************************************************************
#include "io_fsdata.h"

//*****************************************************************************
//
// Global Settings for demo page content.
//
//*****************************************************************************
static char g_cSampleTextBuffer[16] = {0};

//*****************************************************************************
//
// Open a file and return a handle to the file, if found.  Otherwise,
// return NULL.  This function also looks for special filenames used to
// provide specific status information or to control various subsystems.
// These filenames are used by the JavaScript on the "IO Control Demo 1"
// example web page.
//
//*****************************************************************************
struct fs_file *
fs_open(char *name)
{

    const struct fsdata_file *ptTree;
    struct fs_file *ptFile = NULL;

    //
    // Allocate memory for the file system structure.
    //
    ptFile = mem_malloc(sizeof(struct fs_file));
    if(NULL == ptFile)
    {
        return(NULL);
    }

    //
    // Process request to toggle STATUS LED
    //
    if(strncmp(name, "/cgi-bin/toggle_led", 19) == 0)
    {
            //
            // Toggle the STATUS LED
            //
            io_set_device(!io_is_dev_on((name[24] - 0x30), 10), (name[26] - 0x30));

        //
        // Setup the file structure to return whatever.
        //
        ptFile->data = NULL;
        ptFile->len = 0;
        ptFile->index = 0;
        ptFile->pextension = NULL;

        //
        // Return the file system pointer.
        //
        return(ptFile);
    }
    
    //
    // Request for LED State?
    //
    if(strncmp(name, "/ledstate?", 9) == 0)
    {
        static char pcBuf[4];

        //
        // Get the state of the LED
        //
           io_get_devstate(pcBuf, 4, (name[14] - 0x30), 10);

        ptFile->data = pcBuf;
        ptFile->len = strlen(pcBuf);
        ptFile->index = ptFile->len;
        ptFile->pextension = NULL;
        return(ptFile);
    }
    
   
    //
    // If I can't find it there, look in the rest of the main file system
    //
    else
    {
        //
        // Initialize the file system tree pointer to the root of the linked list.
        //
        ptTree = FS_ROOT;

        //
        // Begin processing the linked list, looking for the requested file name.
        //
        while(NULL != ptTree)
        {
            //
            // Compare the requested file "name" to the file name in the
            // current node.
            //
            if(strncmp(name, (char *)ptTree->name, ptTree->len) == 0)
            {
                //
                // Fill in the data pointer and length values from the
                // linked list node.
                //
                ptFile->data = (char *)ptTree->data;
                ptFile->len = ptTree->len;

                //
                // For now, we setup the read index to the end of the file,
                // indicating that all data has been read.
                //
                ptFile->index = ptTree->len;

                //
                // We are not using any file system extensions in this
                // application, so set the pointer to NULL.
                //
                ptFile->pextension = NULL;

                //
                // Exit the loop and return the file system pointer.
                //
                break;
            }

            //
            // If we get here, we did not find the file at this node of the linked
            // list.  Get the next element in the list.
            //
            ptTree = ptTree->next;
        }
    }

    //
    // If we didn't find the file, ptTee will be NULL.  Make sure we
    // return a NULL pointer if this happens.
    //
    if(NULL == ptTree)
    {
        mem_free(ptFile);
        ptFile = NULL;
    }

    //
    // Return the file system pointer.
    //
    return(ptFile);
}

//*****************************************************************************
//
// Close an opened file designated by the handle.
//
//*****************************************************************************
void
fs_close(struct fs_file *file)
{
    //
    // Free the main file system object.
    //
    mem_free(file);
}

//*****************************************************************************
//
// Read the next chunck of data from the file.  Return the count of data
// that was read.  Return 0 if no data is currently available.  Return
// a -1 if at the end of file.
//
//*****************************************************************************
int
fs_read(struct fs_file *file, char *buffer, int count)
{
    int iAvailable;

    //
    // Check to see if a command (pextension = 1).
    //
    if(file->pextension == (void *)1)
    {
        //
        // Nothting to do for this file type.
        //
        file->pextension = NULL;
        return(-1);
    }

    //
    // Check to see if more data is available.
    //
    if(file->len == file->index)
    {
        //
        // There is no remaining data.  Return a -1 for EOF indication.
        //
        return(-1);
    }

    //
    // Determine how much data we can copy.  The minimum of the 'count'
    // parameter or the available data in the file system buffer.
    //
    iAvailable = file->len - file->index;
    if(iAvailable > count)
    {
        iAvailable = count;
    }

    //
    // Copy the data.
    //
    memcpy(buffer, file->data + iAvailable, iAvailable);
    file->index += iAvailable;

    //
    // Return the count of data that we copied.
    //
    return(iAvailable);
}

and the GUI:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<!-- Copyright (c) 2009-2011 Texas Instruments Incorporated.  All rights reserved. -->
<meta http-equiv="content-type" content="text/html;charset=ISO-8869-1"><title>I/O Control Demo 1</title>

<script language="JavaScript">
<!--
function toggle_led()
{
    var req = false;
    var led = false;
    function ledComplete()
    {
        if (led.readyState == 4 && led.status == 200)
        {
            document.getElementById("ledstate").innerHTML = "<div>" + led.responseText + "</div>";
        }
    }
    if(window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        led = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        led = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (req)
    {
        req.open("GET", "/cgi-bin/toggle_led?loc=B&id" + Math.random(), true);
        req.send(null);
    }
    if(led)
    {
        led.open("GET", "/ledstate?loc=Bid=" + Math.random(), true);
        led.onreadystatechange = ledComplete;
        led.send(null);
    }
}

function pwm_onoff()
{
    var req = false;
    var pwm = false;
    function pwmComplete()
    {
        if(pwm.readyState == 4)
        {
            if(pwm.status == 200)
            {
                document.getElementById("pwmstate").innerHTML = "<div>" + pwm.responseText + "</div>";
            }
        }
    }
    if(window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        pwm = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        pwm = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(req)
    {
        req.open("GET", "/cgi-bin/pwm_onoff?id" + Math.random(), true);
        req.send(null);
    }
    if(pwm)
    {
        pwm.open("GET", "/pwmstate?id=" + Math.random(), true);
        pwm.onreadystatechange = pwmComplete;
        pwm.send(null);
    }
}

function pwm_freq_set()
{
    var req = false;
    var pwmfreq = false;
    var FreqText = document.getElementById("pwmfreqtxt");
    function pwmfreqComplete()
    {
        if(pwmfreq.readyState == 4)
        {
            if(pwmfreq.status == 200)
            {
                document.getElementById("pwmfreq").innerHTML = "<div>" + pwmfreq.responseText + "</div>";
            }
        }
    }
    if(window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        pwmfreq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        pwmfreq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(req)
    {
        if(FreqText.value != "")
        {
            req.open("GET", "/pwm_freq?value=" + FreqText.value + "&id=" + Math.random(), true);
            req.send(null);
        }
    }
    if(pwmfreq)
    {
        pwmfreq.open("GET", "/pwmfreqget?id=" + Math.random(), true);
        pwmfreq.onreadystatechange = pwmfreqComplete;
        pwmfreq.send(null);
    }
}

function pwm_dutycycle_set()
{
    var req = false;
    var pwmdutycycle = false;
    var DutyCycleText = document.getElementById("pwmdutycycletxt");
    function pwmdutycycleComplete()
    {
        if(pwmdutycycle.readyState == 4)
        {
            if(pwmdutycycle.status == 200)
            {
                document.getElementById("pwmdutycycle").innerHTML = "<div>" + pwmdutycycle.responseText + "</div>";
            }
        }
    }
    if(window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        pwmdutycycle = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        pwmdutycycle = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(req)
    {
        if(DutyCycleText.value != "")
        {
            req.open("GET", "/pwm_dutycycle?value=" + DutyCycleText.value + "&id=" + Math.random(), true);
            req.send(null);
        }
    }
    if(pwmdutycycle)
    {
        pwmdutycycle.open("GET", "/pwmdutycycleget?id=" + Math.random(), true);
        pwmdutycycle.onreadystatechange = pwmdutycycleComplete;
        pwmdutycycle.send(null);
    }
}

function ledstateGet()
{
    var led = false;
    function ledComplete()
    {
        if(led.readyState == 4)
        {
            if(led.status == 200)
            {
                document.getElementById("ledstate").innerHTML = "<div>" + led.responseText + "</div>";
            }
        }
    }
    if(window.XMLHttpRequest)
    {
        led = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        led = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(led)
    {
        led.open("GET", "/ledstate?id=" + Math.random(), true);
        led.onreadystatechange = ledComplete;
        led.send(null);
    }
}

function pwmstateGet()
{
    var pwm = false;
    function pwmComplete()
    {
        if(pwm.readyState == 4)
        {
            if(pwm.status == 200)
            {
                document.getElementById("pwmstate").innerHTML = "<div>" + pwm.responseText + "</div>";
            }
        }
    }
    if(window.XMLHttpRequest)
    {
        pwm = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        pwm = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(pwm)
    {
        pwm.open("GET", "/pwmstate?id=" + Math.random(), true);
        pwm.onreadystatechange = pwmComplete;
        pwm.send(null);
    }
}
    
function pwmfreqGet()
{
    var pwmfreq = false;
    function pwmfreqComplete()
    {
        if(pwmfreq.readyState == 4)
        {
            if(pwmfreq.status == 200)
            {
                document.getElementById("pwmfreq").innerHTML = "<div>" + pwmfreq.responseText + "</div>";
            }
        }
    }
    if(window.XMLHttpRequest)
    {
        pwmfreq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        pwmfreq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(pwmfreq)
    {
        pwmfreq.open("GET", "/pwmfreqget?id=" + Math.random(), true);
        pwmfreq.onreadystatechange = pwmfreqComplete;
        pwmfreq.send(null);
    }
}

function pwmdutycycleGet()
{
    var pwmdutycycle = false;
    function pwmdutycycleComplete()
    {
        if(pwmdutycycle.readyState == 4)
        {
            if(pwmdutycycle.status == 200)
            {
                document.getElementById("pwmdutycycle").innerHTML = "<div>" + pwmdutycycle.responseText + "</div>";
            }
        }
    }
    if(window.XMLHttpRequest)
    {
        pwmdutycycle = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        pwmdutycycle = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(pwmdutycycle)
    {
        pwmdutycycle.open("GET", "/pwmdutycycleget?id=" + Math.random(), true);
        pwmdutycycle.onreadystatechange = pwmdutycycleComplete;
        pwmdutycycle.send(null);
    }
}
//-->
</script>
<style type="text/css">
body
{
font-family: Arial;
background-color: white;
margin: 10px;
padding: 0px
}
h1
{
color: #7C7369;
font-family: Arial;
font-size: 24pt;
font-style: italic;
}
h2
{
color: #000000;
font-family: Arial;
font-size: 18pt;
font-style: bold;
}
h3
{
color: #7C7369;
font-family: Arial;
font-size: 12pt;
font-style: bold;
}
</style>
</head>
<body onload="ledstateGet();pwmstateGet();pwmfreqGet();pwmdutycycleGet();"
    background="images/circle%20spiral%201600x12802.png">

<!--
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"  valign="center">
<img src="./images/ti_logo.gif">
</td>
<td align="center" valign="center">
<h1>Stellaris<small><sup>&reg;</sup></small> LM3S8962 Evaluation Kit</h1>
</td>
</tr>
</table>
<table width="100%">
<tbody>
<tr>
<td align="left" valign="top" width="25%">
<br>
<ul>
<li> <a href="index.htm">About TI</a>
<br>
<br>
</li>
<li> <a href="family.htm">About the Stellaris Family</a>
<br>
<br>
</li>
<li> <a href="block.htm">Block Diagram</a>
<br>
<br>
</li>
<li> <a href="io_http.htm">I/O Control Demo 1<br>
(HTTP Requests)</a>
<br>
<br>
</li>
<li><a href="io_cgi.ssi">I/O Control Demo 2<br>
(SSI/CGI)<br>
<br>
</a></li>
</ul>
</td>
<td align="left" valign="top" width="75%">
-->

<center>
<h1 align="center" id="NameHeader1"><font color="gray">Smart Home Control Panel</font></h1>
</center>
<h2 align="left"><font color="gray">Light Controls</font></h2>
</center>


<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><font color="gray">Room #</font></td>
<td><font color="gray">Light Status</font></td>
<td

align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="gray">Controls</font></td>
</tr>
<tr></tr>
<tr>
<td><font color="gray">1</font></td>
<td>
<div id="ledstate" align="center"><font color="gray"> - </font></div>
</td>
<td><input id="toggle" value="Turn Light On" onclick="toggle_led()" type="button"></td>
<td><input id="toggle1" value="Turn Light Off" onclick="toggle_led()" type="button"></td>


</tr>
<tr>
<td><font color="gray">2</font></td>
<td>
<div id="ledstate" align="center"><font color="gray"> - </font></div>
</td>
<td><input id="toggle" value="Turn Light On" onclick="toggle_led()" type="button"></td>
<td><input id="toggle1" value="Turn Light Off" onclick="toggle_led()" type="button"></td>


</tr>
</tbody>
</table>
<br>

<h2 align="left"><font color="gray">Electronics Controls</font></h2>
</center>


<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><font color="gray">Room #</font></td>
<td><font color="gray">Outlet Status</font></td>
<td

align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="gray">Controls</font></td>
</tr>
<tr></tr>
<tr>
<td><font color="gray">1 Outlet A</font></td>
<td>
<div id="ledstate" align="center"><font color="gray"> - </font></div>
</td>
<td><input id="toggle" value="Turn Outlet On" onclick="toggle_led()" type="button"></td>
<td><input id="toggle1" value="Turn Outlet Off" onclick="toggle_led()" type="button"></td>
</tr>

<tr>
<td><font color="gray">1 Outlet B</font></td>
<td>
<div id="ledstate" align="center"><font color="gray"> - </font></div>
</td>
<td><input id="toggle" value="Turn Outlet On" onclick="toggle_led()" type="button"></td>
<td><input id="toggle1" value="Turn Outlet Off" onclick="toggle_led()" type="button"></td>
</tr>

<tr>
<td><font color="gray">2 Outlet A</font></td>
<td>
<div id="ledstate" align="center"><font color="gray"> - </font></div>
</td>
<td><input id="toggle" value="Turn Outlet On" onclick="toggle_led()" type="button"></td>
<td><input id="toggle1" value="Turn Outlet Off" onclick="toggle_led()" type="button"></td>
</tr>
<tr>
<td><font color="gray">2 Outlet B</font></td>
<td>
<div id="ledstate" align="center"><font color="gray"> - </font></div>
</td>
<td><input id="toggle" value="Turn Outlet On" onclick="toggle_led()" type="button"></td>
<td><input id="toggle1" value="Turn Outlet Off" onclick="toggle_led()" type="button"></td>
</tr>
</tbody>
</table>
<br>



</tr>
</tbody>
</table>




<!--
<p>
Toggle PWM ON/OFF and report the current state
</p>
<table>
<tbody>
<tr>
<td><input id="pwmonoff" value="PWM ON/OFF" onclick="pwm_onoff()" type="button"></td>
<td>PWM:</td>
<td>
<div id="pwmstate" align="center"> - </div>
</td>
</tr>
</tbody>
</table>
<p>
Set PWM frequency (min 200)
</p>
<table>
<tbody>
<tr>
<td>Current Freq:</td>
<td>
<div id="pwmfreq" align="center"> - </div>
</td>
</tr>
<tr>
<td><input id="pwmfreqset" value="Set Frequency" onclick="pwm_freq_set()" type="button"></td>
<td><input id="pwmfreqtxt" type="text"></td>
</tr>
</tbody>
</table>
<p>
Set PWM Duty Cycle
</p>
<table>
<tbody>
<tr>
<td>Current Duty Cycle:</td>
<td>
<div id="pwmdutycycle" align="center">-
</div>
</td>
</tr>
<tr>
<td><input id="pwmdutycycleset" value="Set Duty Cycle" onclick="pwm_dutycycle_set()" type="button"></td>
<td><input id="pwmdutycycletxt" type="text"></td>
</tr>
</tbody>
</table>
<p></p>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td align="right" valign="center">
<h1><br>
</h1>
</td>
<td align="right" valign="center">
<h3>Copyright &copy; 2009-2011 Texas Instruments Incorporated.  All rights reserved.</h3>
</td>
</tr>
</tbody>
</table>
-->
</body></html>

Here is when i'm thrown into the Fault ISR:

/**
 * @file - stellarisif.c
 * lwIP Ethernet interface for Stellaris Devices
 *
 */

/**
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels <adam@sics.se>
 *
 */

/**
 * Copyright (c) 2008 Texas Instruments Incorporated
 *
 * This file is dervied from the ``ethernetif.c'' skeleton Ethernet network
 * interface driver for lwIP.
 *
 */

#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/sys.h"
#include <lwip/stats.h>
#include <lwip/snmp.h>
#include "netif/etharp.h"
#include "netif/ppp_oe.h"
#include "netif/stellarisif.h"

/**
 * Sanity Check:  This interface driver will NOT work if the following defines
 * are incorrect.
 *
 */
#if (PBUF_LINK_HLEN != 16)
#error "PBUF_LINK_HLEN must be 16 for this interface driver!"
#endif
#if (ETH_PAD_SIZE != 2)
#error "ETH_PAD_SIZE must be 2 for this interface driver!"
#endif
#if (!SYS_LIGHTWEIGHT_PROT)
#error "SYS_LIGHTWEIGHT_PROT must be enabled for this interface driver!"
#endif

/**
 * Number of pbufs supported in low-level tx/rx pbuf queue.
 *
 */
#ifndef STELLARIS_NUM_PBUF_QUEUE
#define STELLARIS_NUM_PBUF_QUEUE    20
#endif

/**
 * Setup processing for PTP (IEEE-1588).
 *
 */
#if LWIP_PTPD
extern void lwIPHostGetTime(u32_t *time_s, u32_t *time_ns);
#endif

/**
 * Stellaris DriverLib Header Files required for this interface driver.
 *
 */
#include "inc/hw_ethernet.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/ethernet.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"

/* Define those to better describe your network interface. */
#define IFNAME0 'l'
#define IFNAME1 'm'

/* Helper struct to hold a queue of pbufs for transmit and receive. */
struct pbufq {
  struct pbuf *pbuf[STELLARIS_NUM_PBUF_QUEUE];
  unsigned long qwrite;
  unsigned long qread;
  unsigned long overflow;
};

/* Helper macros for accessing pbuf queues. */
#define PBUF_QUEUE_EMPTY(q) \
    (((q)->qwrite == (q)->qread) ? true : false)

#define PBUF_QUEUE_FULL(q) \
    ((((((q)->qwrite + 1) % STELLARIS_NUM_PBUF_QUEUE)) == (q)->qread) ? \
    true : false )

/**
 * Helper struct to hold private data used to operate your ethernet interface.
 * Keeping the ethernet address of the MAC in this struct is not necessary
 * as it is already kept in the struct netif.
 * But this is only an example, anyway...
 */
struct stellarisif {
  struct eth_addr *ethaddr;
  /* Add whatever per-interface state that is needed here. */
  struct pbufq txq;
};

/**
 * Global variable for this interface's private data.  Needed to allow
 * the interrupt handlers access to this information outside of the
 * context of the lwIP netif.
 *
 */
static struct stellarisif stellarisif_data;

/**
 * Pop a pbuf packet from a pbuf packet queue
 *
 * @param q is the packet queue from which to pop the pbuf.
 *
 * @return pointer to pbuf packet if available, NULL otherswise.
 */
static struct pbuf *
dequeue_packet(struct pbufq *q)
{
  struct pbuf *pBuf;
  SYS_ARCH_DECL_PROTECT(lev);

  /**
   * This entire function must run within a "critical section" to preserve
   * the integrity of the transmit pbuf queue.
   *
   */
  SYS_ARCH_PROTECT(lev);

  if(PBUF_QUEUE_EMPTY(q)) {
    /* Return a NULL pointer if the queue is empty. */
    pBuf = (struct pbuf *)NULL;
  }
  else {
    /**
     * The queue is not empty so return the next frame from it
     * and adjust the read pointer accordingly.
     *
     */
    pBuf = q->pbuf[q->qread];
    q->qread = ((q->qread + 1) % STELLARIS_NUM_PBUF_QUEUE);
  }

  /* Return to prior interrupt state and return the pbuf pointer. */
  SYS_ARCH_UNPROTECT(lev);
  return(pBuf);
}

/**
 * Push a pbuf packet onto a pbuf packet queue
 *
 * @param p is the pbuf to push onto the packet queue.
 * @param q is the packet queue.
 *
 * @return 1 if successful, 0 if q is full.
 */
static int
enqueue_packet(struct pbuf *p, struct pbufq *q)
{
  SYS_ARCH_DECL_PROTECT(lev);
  int ret;

  /**
   * This entire function must run within a "critical section" to preserve
   * the integrity of the transmit pbuf queue.
   *
   */
  SYS_ARCH_PROTECT(lev);

  if(!PBUF_QUEUE_FULL(q)) {
    /**
     * The queue isn't full so we add the new frame at the current
     * write position and move the write pointer.
     *
     */
    q->pbuf[q->qwrite] = p;
    q->qwrite = ((q->qwrite + 1) % STELLARIS_NUM_PBUF_QUEUE);
    ret = 1;
  }
  else {
    /**
     * The stack is full so we are throwing away this value.  Keep track
     * of the number of times this happens.
     *
     */
    q->overflow++;
    ret = 0;
  }

  /* Return to prior interrupt state and return the pbuf pointer. */
  SYS_ARCH_UNPROTECT(lev);
  return(ret);
}

/**
 * In this function, the hardware should be initialized.
 * Called from stellarisif_init().
 *
 * @param netif the already initialized lwip network interface structure
 *        for this ethernetif
 */
static void
stellarisif_hwinit(struct netif *netif)
{
  u32_t temp;
  //struct stellarisif *stellarisif = netif->state;

  /* set MAC hardware address length */
  netif->hwaddr_len = ETHARP_HWADDR_LEN;

  /* set MAC hardware address */
  EthernetMACAddrGet(ETH_BASE, &(netif->hwaddr[0]));

  /* maximum transfer unit */
  netif->mtu = 1500;

  /* device capabilities */
  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
  netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;

  /* Do whatever else is needed to initialize interface. */
  /* Disable all Ethernet Interrupts. */
  EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER |
     ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX));
  temp = EthernetIntStatus(ETH_BASE, false);
  EthernetIntClear(ETH_BASE, temp);

  /* Initialize the Ethernet Controller. */
  EthernetInitExpClk(ETH_BASE, SysCtlClockGet());

  /*
   * Configure the Ethernet Controller for normal operation.
   * - Enable TX Duplex Mode
   * - Enable TX Padding
   * - Enable TX CRC Generation
   * - Enable RX Multicast Reception
   */
  EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN |ETH_CFG_TX_CRCEN |
    ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN));

  /* Enable the Ethernet Controller transmitter and receiver. */
  EthernetEnable(ETH_BASE);

  /* Enable the Ethernet Interrupt handler. */
  IntEnable(INT_ETH);

  /* Enable Ethernet TX and RX Packet Interrupts. */
  EthernetIntEnable(ETH_BASE, ETH_INT_RX | ETH_INT_TX);
}

/**
 * This function should do the actual transmission of the packet. The packet is
 * contained in the pbuf that is passed to the function. This pbuf might be
 * chained.
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
 * @return ERR_OK if the packet could be sent
 *         an err_t value if the packet couldn't be sent
 * @note This function MUST be called with interrupts disabled or with the
 *       Stellaris Ethernet transmit fifo protected.
 */
static err_t
stellarisif_transmit(struct netif *netif, struct pbuf *p)
{
  int iBuf;
  unsigned char *pucBuf;
  unsigned long *pulBuf;
  struct pbuf *q;
  int iGather;
  unsigned long ulGather;
  unsigned char *pucGather;

  /**
   * Fill in the first two bytes of the payload data (configured as padding
   * with ETH_PAD_SIZE = 2) with the total length of the payload data
   * (minus the Ethernet MAC layer header).
   *
   */
  *((unsigned short *)(p->payload)) = p->tot_len - 16;

  /* Initialize the gather register. */
  iGather = 0;
  pucGather = (unsigned char *)&ulGather;
  ulGather = 0;

  /* Copy data from the pbuf(s) into the TX Fifo. */
  for(q = p; q != NULL; q = q->next) {
    /* Intialize a char pointer and index to the pbuf payload data. */
    pucBuf = (unsigned char *)q->payload;
    iBuf = 0;

    /**
     * If the gather buffer has leftover data from a previous pbuf
     * in the chain, fill it up and write it to the Tx FIFO.
     *
     */
    while((iBuf < q->len) && (iGather != 0)) {
      /* Copy a byte from the pbuf into the gather buffer. */
      pucGather[iGather] = pucBuf[iBuf++];

      /* Increment the gather buffer index modulo 4. */
      iGather = ((iGather + 1) % 4);
    }

    /**
     * If the gather index is 0 and the pbuf index is non-zero,
     * we have a gather buffer to write into the Tx FIFO.
     *
     */
    if((iGather == 0) && (iBuf != 0)) {
      HWREG(ETH_BASE + MAC_O_DATA) = ulGather;
      ulGather = 0;
    }

    /* Initialze a long pointer into the pbuf for 32-bit access. */
    pulBuf = (unsigned long *)&pucBuf[iBuf];

    /**
     * Copy words of pbuf data into the Tx FIFO, but don't go past
     * the end of the pbuf.
     *
     */
    while((iBuf + 4) <= q->len) {
      HWREG(ETH_BASE + MAC_O_DATA) = *pulBuf++;
      iBuf += 4;
    }

    /**
     * Check if leftover data in the pbuf and save it in the gather
     * buffer for the next time.
     *
     */
    while(iBuf < q->len) {
      /* Copy a byte from the pbuf into the gather buffer. */
      pucGather[iGather] = pucBuf[iBuf++];

      /* Increment the gather buffer index modulo 4. */
      iGather = ((iGather + 1) % 4);
    }
  }

  /* Send any leftover data to the FIFO. */
  HWREG(ETH_BASE + MAC_O_DATA) = ulGather;

  /* Wakeup the transmitter. */
  HWREG(ETH_BASE + MAC_O_TR) = MAC_TR_NEWTX;

  /* Dereference the pbuf from the queue. */
  pbuf_free(p);

  LINK_STATS_INC(link.xmit);

  return(ERR_OK);
}

/**
 * This function with either place the packet into the Stellaris transmit fifo,
 * or will place the packet in the interface PBUF Queue for subsequent
 * transmission when the transmitter becomes idle.
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
 * @return ERR_OK if the packet could be sent
 *         an err_t value if the packet couldn't be sent
 *
 */
static err_t
stellarisif_output(struct netif *netif, struct pbuf *p)
{
  struct stellarisif *stellarisif = netif->state;
  SYS_ARCH_DECL_PROTECT(lev);

  /**
   * This entire function must run within a "critical section" to preserve
   * the integrity of the transmit pbuf queue.
   *
   */
  SYS_ARCH_PROTECT(lev);

  /**
   * Bump the reference count on the pbuf to prevent it from being
   * freed till we are done with it.
   *
   */
  pbuf_ref(p);

  /**
   * If the transmitter is idle, and there is nothing on the queue,
   * send the pbuf now.
   *
   */
  if(PBUF_QUEUE_EMPTY(&stellarisif->txq) &&
    ((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0)) {
    stellarisif_transmit(netif, p);
  }

  /* Otherwise place the pbuf on the transmit queue. */
  else {
    /* Add to transmit packet queue */
    if(!enqueue_packet(p, &(stellarisif->txq))) {
      /* if no room on the queue, free the pbuf reference and return error. */
      pbuf_free(p);
      SYS_ARCH_UNPROTECT(lev);
      return (ERR_MEM);
    }
  }

  /* Return to prior interrupt state and return. */
  SYS_ARCH_UNPROTECT(lev);
  return ERR_OK;
}

/**
 * This function will read a single packet from the Stellaris ethernet
 * interface, if available, and return a pointer to a pbuf.  The timestamp
 * of the packet will be placed into the pbuf structure.
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @return pointer to pbuf packet if available, NULL otherswise.
 */
static struct pbuf *
stellarisif_receive(struct netif *netif)
{
  struct pbuf *p, *q;
  u16_t len;
  u32_t temp;
  int i;
  unsigned long *ptr;
#if LWIP_PTPD
  u32_t time_s, time_ns;

  /* Get the current timestamp if PTPD is enabled */
  lwIPHostGetTime(&time_s, &time_ns);
#endif


  /* Check if a packet is available, if not, return NULL packet. */
  if((HWREG(ETH_BASE + MAC_O_NP) & MAC_NP_NPR_M) == 0) {
    return(NULL);
  }

  /**
   * Obtain the size of the packet and put it into the "len" variable.
   * Note:  The length returned in the FIFO length position includes the
   * two bytes for the length + the 4 bytes for the FCS.
   *
   */
  temp = HWREG(ETH_BASE + MAC_O_DATA);
  len = temp & 0xFFFF;

  /* We allocate a pbuf chain of pbufs from the pool. */
  p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);

  /* If a pbuf was allocated, read the packet into the pbuf. */
  if(p != NULL) {
    /* Place the first word into the first pbuf location. */
    *(unsigned long *)p->payload = temp;
    p->payload = (char *)(p->payload) + 4;
    p->len -= 4;

    /* Process all but the last buffer in the pbuf chain. */
    q = p;
    while(q != NULL) {
      /* Setup a byte pointer into the payload section of the pbuf. */
      ptr = q->payload;

      /**
       * Read data from FIFO into the current pbuf
       * (assume pbuf length is modulo 4)
       *
       */
      for(i = 0; i < q->len; i += 4) {
        *ptr++ = HWREG(ETH_BASE + MAC_O_DATA);
      }

      /* Link in the next pbuf in the chain. */
      q = q->next;
    }

    /* Restore the first pbuf parameters to their original values. */
    p->payload = (char *)(p->payload) - 4;
    p->len += 4;

    /* Adjust the link statistics */
    LINK_STATS_INC(link.recv);

#if LWIP_PTPD
    /* Place the timestamp in the PBUF */
    p->time_s = time_s;
    p->time_ns = time_ns;
#endif
  }

  /* If no pbuf available, just drain the RX fifo. */
  else {
    for(i = 4; i < len; i+=4) {
      temp = HWREG(ETH_BASE + MAC_O_DATA);
    }

    /* Adjust the link statistics */
    LINK_STATS_INC(link.memerr);
    LINK_STATS_INC(link.drop);
  }

  return(p);
}

/**
 * Should be called at the beginning of the program to set up the
 * network interface. It calls the function stellarisif_hwinit() to do the
 * actual setup of the hardware.
 *
 * This function should be passed as a parameter to netif_add().
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @return ERR_OK if the loopif is initialized
 *         ERR_MEM if private data couldn't be allocated
 *         any other err_t on error
 */
err_t
stellarisif_init(struct netif *netif)
{
  LWIP_ASSERT("netif != NULL", (netif != NULL));

#if LWIP_NETIF_HOSTNAME
  /* Initialize interface hostname */
  netif->hostname = "lwip";
#endif /* LWIP_NETIF_HOSTNAME */

  /*
   * Initialize the snmp variables and counters inside the struct netif.
   * The last argument should be replaced with your link speed, in units
   * of bits per second.
   */
  NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 1000000);

  netif->state = &stellarisif_data;
  netif->name[0] = IFNAME0;
  netif->name[1] = IFNAME1;
  /* We directly use etharp_output() here to save a function call.
   * You can instead declare your own function an call etharp_output()
   * from it if you have to do some checks before sending (e.g. if link
   * is available...) */
  netif->output = etharp_output;
  netif->linkoutput = stellarisif_output;

  stellarisif_data.ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
  stellarisif_data.txq.qread = stellarisif_data.txq.qwrite = 0;
  stellarisif_data.txq.overflow = 0;

  /* initialize the hardware */
  stellarisif_hwinit(netif);

  return ERR_OK;
}

/**
 * Process tx and rx packets at the low-level interrupt.
 *
 * Should be called from the Stellaris Ethernet Interrupt Handler.  This
 * function will read packets from the Stellaris Ethernet fifo and place them
 * into a pbuf queue.  If the transmitter is idle and there is at least one packet
 * on the transmit queue, it will place it in the transmit fifo and start the
 * transmitter.
 *
 */
void
stellarisif_interrupt(struct netif *netif)
{
  struct stellarisif *stellarisif;
  struct pbuf *p;

  /* setup pointer to the if state data */
  stellarisif = netif->state;

  /**
   * Process the transmit and receive queues as long as there is receive
   * data available
   *
   */
  p = stellarisif_receive(netif);
  while(p != NULL) {
    /* process the packet */
#if NO_SYS
    if(ethernet_input(p, netif)!=ERR_OK) {
#else
    if(tcpip_input(p, netif)!=ERR_OK) {
#endif
      /* drop the packet */
      LWIP_DEBUGF(NETIF_DEBUG, ("stellarisif_input: input error\n"));
      pbuf_free(p);

      /* Adjust the link statistics */
      LINK_STATS_INC(link.memerr);
      LINK_STATS_INC(link.drop);
    }

    /* Check if TX fifo is empty and packet available */
    if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) {
      p = dequeue_packet(&stellarisif->txq);
      if(p != NULL) {
        stellarisif_transmit(netif, p);
      }
    }

    /* Read another packet from the RX fifo */
    p = stellarisif_receive(netif);
  }

  /* One more check of the transmit queue/fifo */
  if((HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX) == 0) {
    p = dequeue_packet(&stellarisif->txq);
    if(p != NULL) {
      stellarisif_transmit(netif, p);
    }
  }
}

#if NETIF_DEBUG
/* Print an IP header by using LWIP_DEBUGF
 * @param p an IP packet, p->payload pointing to the IP header
 */
void
stellarisif_debug_print(struct pbuf *p)
{
  struct eth_hdr *ethhdr = (struct eth_hdr *)p->payload;
  u16_t *plen = (u16_t *)p->payload;

  LWIP_DEBUGF(NETIF_DEBUG, ("ETH header:\n"));
  LWIP_DEBUGF(NETIF_DEBUG, ("Packet Length:%5"U16_F" \n",*plen));
  LWIP_DEBUGF(NETIF_DEBUG, ("Destination: %02"X8_F"-%02"X8_F"-%02"X8_F"-%02"X8_F"-%02"X8_F"-%02"X8_F"\n",
    ethhdr->dest.addr[0],
    ethhdr->dest.addr[1],
    ethhdr->dest.addr[2],
    ethhdr->dest.addr[3],
    ethhdr->dest.addr[4],
    ethhdr->dest.addr[5]));
  LWIP_DEBUGF(NETIF_DEBUG, ("Source: %02"X8_F"-%02"X8_F"-%02"X8_F"-%02"X8_F"-%02"X8_F"-%02"X8_F"\n",
    ethhdr->src.addr[0],
    ethhdr->src.addr[1],
    ethhdr->src.addr[2],
    ethhdr->src.addr[3],
    ethhdr->src.addr[4],
    ethhdr->src.addr[5]));
  LWIP_DEBUGF(NETIF_DEBUG, ("Packet Type:0x%04"U16_F" \n", ethhdr->type));
}
#endif /* NETIF_DEBUG */

Has anyone encountered this or a good way to debug using the FAULT ISR? I'm really stumped.  Thanks!

-Brian




  • Brian,

    Do you know which type of fault you are receiving? What is the value of the FAULTSTAT register in the Cortex?

    You could also try the uart_echo example to make sure that you are not having any problems with the UART.

    Thanks,

    Sean de la Haye

  • Wonder if esteemed US Congress will read this code listing just before/after they "tackle" currently "unread" Obama-care? 

    @Brian - my sainted mother would not delve into this code - even if offered 1000 USD cash!  Someway/somehow you've got to "extract the essence" - present that here...

  • Hey Sean,

    How can I print out the FAULTSTAT Reg? Or should i just look at it directly in memory?  I tried switching to a different uart port (1 instead of 0), but it appears some other piece of the example utilizes this port due to the fact that i keep getting uart interrupts... Do i need to do anything different when configuring uart port 1 instead of 0?

    -Brian

  • And for further clarity, here's what my code does in a nutshell:

    Uses enet_io example to set up hosting website on chip.  uses jQuery "GET" to pass different url's from user end to backend.  Backend code then looks for specific url in file support system.  Upon finding correct url, a parameter that is passed is sent out via uart and stored in memory.

  • I've looked at the fault status and it's been giving me bus fault errors specific to uart1 and can0.... I am not using those peripherals why am i getting errors with them?!?!?!

  • Brain,

    Perhaps there is an incorrect pointer that is accessing unexpected locations.   If you know the addresses that are causing the fault, can you have the debugger to trap those locations?  Is it also possible to step through your code an see where the fault is being generated?

    Thanks,

    Sean