Просмотр исходного кода

Adds missing CMakeLists and CMake Toolchain file

CapXilinx 12 лет назад
Родитель
Сommit
d263433d94

+ 303 - 0
CMakeCache.txt

@@ -0,0 +1,303 @@
+# This is the CMakeCache file.
+# For build in directory: /cygdrive/c/workspace/opener
+# It was generated by CMake: /usr/bin/cmake.exe
+# You can edit this file to change values found and used by cmake.
+# If you do not want to change any of the values, simply exit the editor.
+# If you do want to change a value, simply edit, save, and exit the editor.
+# The syntax for the file is as follows:
+# KEY:TYPE=VALUE
+# KEY is the name of a variable in the cache.
+# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
+# VALUE is the current value for the KEY.
+
+########################
+# EXTERNAL cache entries
+########################
+
+//Dependencies for target
+CIP_LIB_DEPENDS:STATIC=
+
+//Path to a program.
+CMAKE_AR:FILEPATH=/usr/bin/ar.exe
+
+//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
+// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
+CMAKE_BUILD_TYPE:STRING=
+
+//Enable/Disable color output during build.
+CMAKE_COLOR_MAKEFILE:BOOL=ON
+
+//C compiler.
+CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc.exe
+
+//Flags used by the compiler during all build types.
+CMAKE_C_FLAGS:STRING=
+
+//Flags used by the compiler during debug builds.
+CMAKE_C_FLAGS_DEBUG:STRING=-g
+
+//Flags used by the compiler during release minsize builds.
+CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
+
+//Flags used by the compiler during release builds (/MD /Ob1 /Oi
+// /Ot /Oy /Gs will produce slightly less optimized but smaller
+// files).
+CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
+
+//Flags used by the compiler during Release with Debug Info builds.
+CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g
+
+//Flags used by the linker.
+CMAKE_EXE_LINKER_FLAGS:STRING='-Wl,--enable-auto-import '
+
+//Flags used by the linker during debug builds.
+CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
+
+//Flags used by the linker during release minsize builds.
+CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
+
+//Flags used by the linker during release builds.
+CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
+
+//Flags used by the linker during Release with Debug Info builds.
+CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
+
+//Enable/Disable output of compile commands during generation.
+CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
+
+//Install path prefix, prepended onto install directories.
+CMAKE_INSTALL_PREFIX:PATH=/usr/local
+
+//Path to a program.
+CMAKE_LINKER:FILEPATH=/usr/bin/ld.exe
+
+//Path to a program.
+CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make.exe
+
+//Flags used by the linker during the creation of modules.
+CMAKE_MODULE_LINKER_FLAGS:STRING=' '
+
+//Flags used by the linker during debug builds.
+CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
+
+//Flags used by the linker during release minsize builds.
+CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
+
+//Flags used by the linker during release builds.
+CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
+
+//Flags used by the linker during Release with Debug Info builds.
+CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
+
+//Path to a program.
+CMAKE_NM:FILEPATH=/usr/bin/nm.exe
+
+//Path to a program.
+CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy.exe
+
+//Path to a program.
+CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump.exe
+
+//Value Computed by CMake
+CMAKE_PROJECT_NAME:STATIC=OpENer
+
+//Path to a program.
+CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib.exe
+
+//RC compiler.
+CMAKE_RC_COMPILER:FILEPATH=/usr/bin/windres.exe
+
+//Flags for Fortran compiler.
+CMAKE_RC_FLAGS:STRING=' '
+
+//Flags used by the linker during the creation of dll's.
+CMAKE_SHARED_LINKER_FLAGS:STRING=' '
+
+//Flags used by the linker during debug builds.
+CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
+
+//Flags used by the linker during release minsize builds.
+CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
+
+//Flags used by the linker during release builds.
+CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
+
+//Flags used by the linker during Release with Debug Info builds.
+CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
+
+//If set, runtime paths are not added when installing shared libraries,
+// but are added when building.
+CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
+
+//If set, runtime paths are not added when using shared libraries.
+CMAKE_SKIP_RPATH:BOOL=NO
+
+//Path to a program.
+CMAKE_STRIP:FILEPATH=/usr/bin/strip.exe
+
+//If true, cmake will use relative paths in makefiles and projects.
+CMAKE_USE_RELATIVE_PATHS:BOOL=OFF
+
+//If this value is on, makefiles will be generated without the
+// .SILENT directive, and all commands will be echoed to the console
+// during the make.  This is useful for debugging only. With Visual
+// Studio IDE projects all commands are done without /nologo.
+CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
+
+//Dependencies for target
+ENET_ENCAP_LIB_DEPENDS:STATIC=
+
+//Dependencies for target
+LM3S8962PLATFORM_LIB_DEPENDS:STATIC=
+
+//Contrib folder of the used LM3S0862 board
+LM3S8962_CONTRIB_DIR:PATH=
+
+//Value Computed by CMake
+OpENer_BINARY_DIR:STATIC=/cygdrive/c/workspace/opener
+
+//Path to a file.
+OpENer_BUILDSUPPORT_DIR:PATH=/cygdrive/c/workspace/opener/source/buildsupport
+
+//Platform OpENer will be built for
+OpENer_PLATFORM:STRING=LM3S8962
+
+//Value Computed by CMake
+OpENer_SOURCE_DIR:STATIC=/cygdrive/c/workspace/opener/source
+
+//Enable tests to be built
+OpENer_TESTS:BOOL=OFF
+
+//Activate OpENer traces
+OpENer_TRACES:BOOL=OFF
+
+//Dependencies for target
+Utils_LIB_DEPENDS:STATIC=
+
+
+########################
+# INTERNAL cache entries
+########################
+
+//ADVANCED property for variable: CMAKE_AR
+CMAKE_AR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_BUILD_TOOL
+CMAKE_BUILD_TOOL-ADVANCED:INTERNAL=1
+//What is the target build tool cmake is generating for.
+CMAKE_BUILD_TOOL:INTERNAL=/usr/bin/make.exe
+//This is the directory where this CMakeCache.txt was created
+CMAKE_CACHEFILE_DIR:INTERNAL=/cygdrive/c/workspace/opener
+//Major version of cmake used to create the current loaded cache
+CMAKE_CACHE_MAJOR_VERSION:INTERNAL=2
+//Minor version of cmake used to create the current loaded cache
+CMAKE_CACHE_MINOR_VERSION:INTERNAL=8
+//Patch version of cmake used to create the current loaded cache
+CMAKE_CACHE_PATCH_VERSION:INTERNAL=9
+//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
+CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
+//Path to CMake executable.
+CMAKE_COMMAND:INTERNAL=/usr/bin/cmake.exe
+//Path to cpack program executable.
+CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack.exe
+//Path to ctest program executable.
+CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest.exe
+//ADVANCED property for variable: CMAKE_C_COMPILER
+CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
+CMAKE_C_COMPILER_WORKS:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS
+CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
+CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
+CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
+CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
+CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//Result of TRY_COMPILE
+CMAKE_DETERMINE_C_ABI_COMPILED:INTERNAL=TRUE
+//Path to cache edit program executable.
+CMAKE_EDIT_COMMAND:INTERNAL=/usr/bin/ccmake.exe
+//Executable file format
+CMAKE_EXECUTABLE_FORMAT:INTERNAL=Unknown
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
+CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
+CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
+CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
+CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
+CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
+CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
+//Name of generator.
+CMAKE_GENERATOR:INTERNAL=Unix Makefiles
+//Start directory with the top level CMakeLists.txt file for this
+// project
+CMAKE_HOME_DIRECTORY:INTERNAL=/cygdrive/c/workspace/opener/source
+//ADVANCED property for variable: CMAKE_LINKER
+CMAKE_LINKER-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
+CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
+CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
+CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
+CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
+CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
+CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_NM
+CMAKE_NM-ADVANCED:INTERNAL=1
+//number of local generators
+CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=9
+//ADVANCED property for variable: CMAKE_OBJCOPY
+CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_OBJDUMP
+CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RANLIB
+CMAKE_RANLIB-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RC_COMPILER
+CMAKE_RC_COMPILER-ADVANCED:INTERNAL=1
+CMAKE_RC_COMPILER_WORKS:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RC_FLAGS
+CMAKE_RC_FLAGS-ADVANCED:INTERNAL=1
+//Path to CMake installation.
+CMAKE_ROOT:INTERNAL=/usr/share/cmake-2.8.9
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
+CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
+CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
+CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
+CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
+CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SKIP_RPATH
+CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_STRIP
+CMAKE_STRIP-ADVANCED:INTERNAL=1
+//uname command
+CMAKE_UNAME:INTERNAL=/usr/bin/uname.exe
+//ADVANCED property for variable: CMAKE_USE_RELATIVE_PATHS
+CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
+CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
+//Have function rand
+HAVE_RAND:INTERNAL=1
+//Have function srand
+HAVE_SRAND:INTERNAL=1
+//STRING
+OpENer_ADD_CIP_OBJECTS:INTERNAL=
+//MODIFIED property for variable: OpENer_PLATFORM
+OpENer_PLATFORM-MODIFIED:INTERNAL=ON
+//STRINGS property for variable: OpENer_PLATFORM
+OpENer_PLATFORM-STRINGS:INTERNAL=POSIX;WIN32;LM3S8962
+

+ 76 - 0
source/buildsupport/Toolchain/Toolchain-EABI-ARM-Generic.cmake.txt

@@ -0,0 +1,76 @@
+INCLUDE(CMakeForceCompiler)
+
+# Embedded System - No OS
+SET(CMAKE_SYSTEM_NAME Generic)
+# Specifiy CPU
+set(CMAKE_SYSTEM_PROCESSOR cortex-m3)
+
+# specify the cross compiler
+CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
+CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)
+
+# Find the target environment prefix..
+# First see where gcc is keeping libc.a
+execute_process(
+  COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.a
+  OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# Strip the filename off
+get_filename_component(CMAKE_INSTALL_PREFIX
+  "${CMAKE_INSTALL_PREFIX}" PATH
+)
+# Then find the canonical path to the directory one up from there
+get_filename_component(CMAKE_INSTALL_PREFIX
+  "${CMAKE_INSTALL_PREFIX}/.." REALPATH
+)
+set(CMAKE_INSTALL_PREFIX  ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH
+    "Install path prefix, prepended onto install directories.")
+
+message(STATUS "Cross-compiling with the gcc-arm-embedded toolchain")
+message(STATUS "Toolchain prefix: ${CMAKE_INSTALL_PREFIX}")
+
+set(CMAKE_FIND_ROOT_PATH  ${CMAKE_INSTALL_PREFIX})
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+set(CMAKE_C_FLAGS
+  "${CMAKE_C_FLAGS}"
+  "-fno-common"
+  "-Wstrict-prototypes -ffunction-sections -fdata-sections"
+)
+
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4")
+
+  set(CMAKE_C_FLAGS
+    "${CMAKE_C_FLAGS}"
+    "-mcpu=cortex-m4 -march=armv7e-m -mthumb"
+    "-mfloat-abi=hard -mfpu=fpv4-sp-d16"
+    "-ffunction-sections -fdata-sections"
+  )
+
+elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m3")
+
+  set(CMAKE_C_FLAGS
+    "${CMAKE_C_FLAGS}"
+    "-mcpu=cortex-m3 -march=armv7-m -mthumb"
+    "-msoft-float"
+    "-ffunction-sections -fdata-sections"
+  )
+
+else ()
+  message(WARNING
+    "Processor not recognised in toolchain file, "
+    "compiler flags not configured."
+  )
+endif ()
+
+# When we break up long strings in CMake we get semicolon
+# separated lists, undo this here...
+string(REGEX REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "")
+
+set(BUILD_SHARED_LIBS OFF)

+ 1 - 1
source/src/ports/LM3S8962/CMakeLists.txt

@@ -1,4 +1,4 @@
-add_subdirectory(sample_application)
+#add_subdirectory(sample_application)
 
 set( PLATFORM_SPEC_SRC networkhandler.c basiccip.c)
 

+ 506 - 0
source/src/ports/LM3S8962/main.c

@@ -0,0 +1,506 @@
+// Scraps of this module were pulled from the following demo program:
+
+//*****************************************************************************
+//
+// enet_lwip.c - Sample WebServer Application using lwIP.
+//
+// Copyright (c) 2007-2008 Luminary Micro, Inc.  All rights reserved.
+// Software License Agreement
+//
+// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
+// exclusively on LMI's microcontroller products.
+//
+// The software is owned by LMI and/or its suppliers, and is protected under
+// applicable copyright laws.  All rights are reserved.  You may not combine
+// this software with "viral" open-source software in order to form a larger
+// program.  Any use in violation of the foregoing restrictions may subject
+// the user to criminal sanctions under applicable laws, as well as to civil
+// liability for the breach of the terms and conditions of this license.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS".  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.
+// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 3618 of the EK-LM3S6965 Rev C Firmware Package.
+//
+//*****************************************************************************
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "hw_ints.h"
+#include "hw_memmap.h"
+#include "hw_nvic.h"
+#include "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 "lwiplib.h"
+
+#include "local.h"
+#include "flashmgr.h"
+#include "networkhandler.h"
+#include <opener_api.h>
+#include "cipcommon.h"
+#include "random.h"
+#include <trace.h>
+#include "../../cip_energy/ElEnergyData.h"
+#include "eminterface.h"
+
+int callocsize = CALLOCSIZE;
+char callocmem[CALLOCSIZE];
+
+//define here instead of ptpd.h
+volatile unsigned long g_ulSystemTimeSeconds;
+volatile unsigned long g_ulSystemTimeNanoSeconds;
+
+// cast an int as a struct_inaddr (check the "inet_ntoa" man page -- it wants a struct_inaddr passed by value, not an int)
+// static IP-Address?
+//#define useStaticIP 1
+#define useStaticIP 0
+
+struct parm
+{
+  int useStatic; // 1 use static IP address, 0 use DHCP
+  unsigned long ip; // my ip address
+  unsigned long nm; // net mask
+  unsigned long gw; // gateway ip address
+};
+
+
+//*****************************************************************************
+//
+// Defines for setting up the system clock.
+//
+//*****************************************************************************
+#define SYSTICKHZ               100
+#define SYSTICKMS               (1000 / SYSTICKHZ)
+#define SYSTICKUS               (1000000 / SYSTICKHZ)
+#define SYSTICKNS               (1000000000 / SYSTICKHZ)
+
+
+//*****************************************************************************
+//
+// Interrupt priority definitions.  The top 3 bits of these values are
+// significant with lower values indicating higher priority interrupts.
+//
+//*****************************************************************************
+#define SYSTICK_INT_PRIORITY    0xF0
+#define ETHERNET_INT_PRIORITY   0xC2
+
+//*****************************************************************************
+//
+// The error routine that is called if the driver library encounters an error.
+//
+//*****************************************************************************
+#ifdef DEBUG
+void
+__error__(char *pcFilename, unsigned long ulLine)
+  {
+  }
+#endif
+
+void DisplayIPAddress(unsigned long ipaddr, unsigned long ulCol,
+                 unsigned long ulRow);
+void DisplayOdo(EIP_INT64 pa_nValue, unsigned long pa_nRow);
+
+
+void DisplayRealVal(double pa_fValue, const char *pcPrefix, const char *pcPostfix, unsigned long pa_nRow, unsigned long pa_nCol);
+
+
+// change my IP address etc.
+void
+setCIPaddress(unsigned long addr, // my IP address, in network order
+    unsigned long mask, // netmask, in network order
+    unsigned long gw) // gateway, in network order
+{
+  struct in_addr inAddr;
+  inAddr.s_addr = addr;
+  char acIPAddr[16];
+  strncpy(acIPAddr, inet_ntoa(inAddr), 16);
+  inAddr.s_addr = mask;
+  char acNetMask[16];
+  strncpy(acNetMask, inet_ntoa(inAddr), 16);
+  inAddr.s_addr = gw;
+  char acGW[16];
+  strncpy(acGW, inet_ntoa(inAddr), 16);
+
+  configureNetworkInterface(acIPAddr, acNetMask, acGW);
+  configureDomainName("test");
+  configureHostName("karl");
+}
+
+// this gets called every 100 usec by the lwip timer handler
+void
+lwIPHostTimerHandler(void)
+{
+  static unsigned long ulLastIPAddress = 0;
+  unsigned long ulIPAddress;
+  unsigned long ulNetmask;
+  unsigned long ulGateway;
+
+  ulIPAddress = lwIPLocalIPAddrGet();
+
+  if (ulLastIPAddress != ulIPAddress)
+    {
+      ulLastIPAddress = ulIPAddress;
+      ulNetmask = lwIPLocalNetMaskGet();
+      ulGateway = lwIPLocalGWAddrGet();
+      setCIPaddress(ulIPAddress, ulNetmask, ulGateway);
+      DisplayIPAddress((ulIPAddress), 36, 8);
+    }
+}
+
+int
+main(void)
+{
+  int i;
+  unsigned long ulUser0, ulUser1;
+  unsigned char pucMACArray[8];
+
+  unsigned long ip, nm, gw;
+  int valid;
+
+  struct parm parm;
+  struct parm *p;
+  unsigned long *pl;
+
+  IntPriorityGroupingSet(4);
+
+  //
+  // Set the clocking to run directly from the crystal.
+  //
+  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN
+                  | SYSCTL_XTAL_8MHZ);
+
+  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_GPIOE);
+  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
+  GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_DIR_MODE_HW);
+  GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3,
+                  GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
+
+  //
+  // Configure the GPIOs used to read the state of the on-board push buttons.
+  //
+  GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2
+                  | GPIO_PIN_3);
+  GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2
+                  | GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
+  GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
+  GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,
+                  GPIO_PIN_TYPE_STD_WPU);
+
+  // configure the user LED output
+  GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
+  GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);
+
+
+
+  //
+  // Configure SysTick for a 100 Hz (10 ms) interrupt.
+  //
+  SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
+  SysTickEnable();
+  SysTickIntEnable();
+
+  //
+  // Initialize ADC
+  //
+  EMInterfaceInit();
+  //
+  // Enable processor interrupts.
+  //
+  IntMasterEnable();
+
+
+
+  //
+  // 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.
+      //
+
+      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);
+
+  //////////////////////////////////////////////////////////
+  // YOU MUST SET THESE TO VALID VALUES FOR YOUR LOCATION //
+  //////////////////////////////////////////////////////////
+  configureMACAddress(pucMACArray);
+
+  //
+  // Initialze the lwIP library
+  //
+
+
+  pl = parmFind();
+  p = (struct parm *) (pl + 1);
+
+  if (useStaticIP)
+    {
+      OPENER_TRACE_INFO("using static IP address\n");
+
+      ip = 0x8083BAC9; //128.130.200.201
+//      ip = 0x8083BACB; //128.130.200.203
+      nm = 0xFFFFFF00;
+      gw = 0x8083BA01;
+      valid = 7;
+      lwIPInit(pucMACArray, ip, nm, gw, IPADDR_USE_STATIC);
+    }
+  else
+    {
+      //
+      // Initialze the lwIP library, using DHCP.
+      //
+      OPENER_TRACE_INFO("using DHCP\n");
+      valid = 0; //0
+      lwIPInit(pucMACArray, 0, 0, 0, IPADDR_USE_DHCP);
+    }
+
+
+  // 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.
+    //
+    //
+    // Initialize the OLED display.
+    //
+    RIT128x96x4Init(1000000);
+    RIT128x96x4StringDraw("OpENer w/ CIP-Energy", 4, 0, 15);
+    RIT128x96x4StringDraw("-----------------------", 0, 14, 15);
+    RIT128x96x4StringDraw("IP:   ", 0, 8, 15);
+    DisplayIPAddress(htonl(ip), 36, 8);
+
+    RIT128x96x4StringDraw("  TWh GWh MWh kWh  Wh  ", 0, 20, 15);
+
+    RIT128x96x4StringDraw("factor 1000 applies    ", 0, 54, 10);
+    RIT128x96x4StringDraw("to metered values     ", 0, 62, 10);
+    //change time-interval value for call of updateElMeasuringAndMeteringData
+    //in SysTickIntHandler-method to show/provide correct values (see line 370)
+
+  IntPrioritySet(INT_ETH, ETHERNET_INT_PRIORITY);
+  IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
+
+  /*for a real device the serial number should be unique per device */
+  setDeviceSerialNumber(123456789);
+
+  /* Setup the CIP Layer */
+  CIP_Init(365);
+  IntMasterDisable();
+  CIP_BaseEnergy_Init();
+  CIP_ElEnergy_Init();
+
+  IntMasterEnable();
+  Start_NetworkHandler();
+
+  // this is a simple command interpreter which reads from serial port 0
+  // it is used to set a static IP address
+  while (1)
+    {
+
+    }
+}
+
+/* implement missing functions rand and srand */
+int _EXFUN(rand,(_VOID))
+{
+  return RandomNumber();
+}
+
+_VOID   _EXFUN(srand,(unsigned __seed))
+{
+  RandomAddEntropy(__seed);
+  RandomSeed();
+}
+
+
+
+//*****************************************************************************
+//
+// The interrupt handler for the SysTick interrupt.
+// Entry here directly from the interrupt vector
+// This interrupt occurs once every 10 milliseconds
+//*****************************************************************************
+void SysTickIntHandler(void) {
+
+  //
+  // Update internal time and set PPS output, if needed.
+  //
+  g_ulSystemTimeNanoSeconds += SYSTICKNS;
+  if(g_ulSystemTimeNanoSeconds >= 1000000000) //1 second interval
+      {
+          //GPIOPinWrite(PPS_GPIO_BASE, PPS_GPIO_PIN, PPS_GPIO_PIN); ???
+          g_ulSystemTimeNanoSeconds -= 1000000000;
+          g_ulSystemTimeSeconds += 1;
+
+          //TODO: set interval back to 1 second
+          updateElMeasuringAndMeteringData(1000.0, EMInterfaceGetVoltage(), EMInterfaceGetCurrent());
+
+          RIT128x96x4StringDraw("N", 0, 28, 15);
+          DisplayOdo(g_nBE_TotalEnergyValue, 28);
+
+          RIT128x96x4StringDraw("C", 0, 36, 15);
+          DisplayOdo(g_nBE_ConsumedEnergyValue, 36);
+
+          RIT128x96x4StringDraw("P", 0, 44, 15);
+          DisplayOdo(g_nBE_ProducedEnergyValue, 44);
+
+          DisplayRealVal(g_astEE_ObjInstanceAttribs[eELEL1Current].m_nAttribValue.m_fReal, "I:", "A", 74, 0);
+          DisplayRealVal(g_astEE_ObjInstanceAttribs[eELEL1toNVoltage].m_nAttribValue.m_fReal, "U:", "V", 74, 66);
+
+          DisplayRealVal(g_astEE_ObjInstanceAttribs[eELELineFrequency].m_nAttribValue.m_fReal, "f:", "Hz", 82, 0);
+          DisplayRealVal(g_astEE_ObjInstanceAttribs[eELEL1RealPower].m_nAttribValue.m_fReal, "P:", "W", 82, 66);
+
+      }
+
+
+  //
+  // Call the lwIP timer handler.
+  //
+  lwIPTimer(SYSTICKMS);
+}
+
+
+//*****************************************************************************
+//
+// 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.
+    //
+    sprintf(pucBuf, "%d.%d.%d.%d", pucTemp[0], pucTemp[1], pucTemp[2],
+             pucTemp[3]);
+
+    //
+    // Display the string.
+    //
+    RIT128x96x4StringDraw(pucBuf, ulCol, ulRow, 15);
+}
+
+
+//*****************************************************************************
+//
+// Display a 5 digit odometer
+//
+//*****************************************************************************
+void
+DisplayOdo(EIP_INT64 pa_nValue, unsigned long pa_nRow) {
+  char pucBuf[23];
+  char pucSign[2];
+  UINT16 odoMeter[5] = {0,0,0,0,0};
+  int i = 0;
+
+
+  if (0 > pa_nValue) {
+    pa_nValue = pa_nValue * (-1);
+    sprintf(pucSign,"-");
+  } else {
+    sprintf(pucSign," ");
+  }
+  RIT128x96x4StringDraw(pucSign, 6, pa_nRow, 15);
+
+
+  for (i=0; i<5;++i) {
+      odoMeter[i] = pa_nValue % 1000;
+      pa_nValue /= 1000;
+  }
+
+  sprintf(pucBuf, "%03d,%03d,%03d,%03d,%03d", odoMeter[4], odoMeter[3],
+      odoMeter[2], odoMeter[1], odoMeter[0]);
+
+  RIT128x96x4StringDraw(pucBuf, 12, pa_nRow, 15);
+
+}
+
+
+//*****************************************************************************
+//
+// Split double value at decimal-point and provide integer values
+// for both values. the value after the decimal point is limited to 3 digits
+//
+//*****************************************************************************
+void
+splitDecimal(double pa_fValue, char* pa_pSign, int* pa_pFull, int* pa_pMilli){
+  if (0 <= pa_fValue) {
+      *pa_pSign = ' ';
+      *pa_pFull = floor(pa_fValue);
+      *pa_pMilli = floor(fmod(pa_fValue, 1.0)*1000);
+  } else {
+      *pa_pSign = '-';
+      *pa_pFull = floor(-1.0 * pa_fValue);
+      *pa_pMilli = floor(fmod(pa_fValue * (-1.0), 1.0)*1000);
+  }
+}
+
+
+
+//*****************************************************************************
+//
+// Print the given double-value, preceeded by pre-fix and followed by post-fix
+// at given position of OLED-display
+//
+//*****************************************************************************
+void
+DisplayRealVal(double pa_fValue, const char *pcPrefix, const char *pcPostfix, unsigned long pa_nRow, unsigned long pa_nCol) {
+  char pucBuf[23];
+
+  int Val;
+  int milliVal;
+  char sign;
+
+  splitDecimal(pa_fValue, &sign, &Val, &milliVal);
+//TODO: minor bug: values between -1 and 0 have incorrect sign at output (there is no integer value with -0)
+  sprintf(pucBuf, "%s%c%2d.%03d%s", pcPrefix, sign, Val, milliVal, pcPostfix);
+  RIT128x96x4StringDraw(pucBuf, pa_nCol, pa_nRow, 15);
+}
+