Embedded TCP/IP stack
4.1.0
|
Add FNET Stack to an existing project
The FNET Stack is self-sufficient. It does not require any external software libraries. That is why adding the FNET TCP/IP stack to an existing project is a simple task.
To add the FNET TCP/IP stack code to your project, follow the steps below:
- Start IDE.
- Open your existing project or create a new one.
- Add the whole fnet\fnet_stack directory to the project.
- Add path to the "/fnet_stack" directory in your project settings for C/C++ Compiler ans Assembler.
- Anywhere in your project-directory structure, create the FNET user-configuration file fnet_user_config.h and add it to the project. As a reference you can use any fnet_user_config.h file from existing demo applications.
- Edit your fnet_user_config.h file to change default FNET parameters. See FNET Configuration Parameters chapter for different configuration options available.
- Be sure that the FNET_CFG_COMP_compiler_type and the FNET_CFG_CPU_processor_type configuration parameters corresponds to your compiler and platform.
- Add initialization sequence of FNET TCP/IP stack into your application code (see the Stack Initialization API chapter). For example in your main function: #include "fnet.h" /* FNET API *//* main entry point*/int main(void){static fnet_uint8_t stack_heap[FAPP_CFG_HEAP_SIZE];struct fnet_init_params init_params;/* Init UART *//* Enable interrupts *//* Input parameters for FNET stack initialization */init_params.netheap_ptr = stack_heap;init_params.netheap_size = sizeof(stack_heap);/* FNET Initialization */{fnet_printf("TCP/IP stack initialization is done.\n");/* You may use FNET stack API *//* Initialize networking interfaces using fnet_netif_init(). */}else{fnet_printf("Error:TCP/IP stack initialization is failed.\n");}for(;;){}}
- Now you should be able to start using the FNET TCP/IP stack and services. See FNET Stack API and FNET Service API chapters for a detailed description of the programmer's interface.
Also it's highly recommended to look at providedfnet_demos
examples, especially theshell
demo. You may use them as a reference.
- Note
- It is important to enable hardware interrupts in your project, because the FNET TCP/IP stack uses Ethernet module and Timer module interrupts for its own activity.
- Usually a vector table is placed in RAM. The FNET software has its own interrupt dispatcher which registers own interrupt service routine into the vector table automatically during the stack initialization (the vector table must be pointed by FNET_CFG_CPU_VECTOR_TABLE parameter).
If an application uses a vector table that is placed only in ROM, the FNET interrupt service routinefnet_cpu_isr()
must be pre-installed, for the Timer Event and for the FEC Receive Frame interrupts, into the ROM vector table (pointed by FNET_CFG_CPU_VECTOR_TABLE parameter). For example, you may correct your standardexception.c
file (part of CodeWarrior project stationary):.../* CF have 255 vector + SP_INIT in the vector table (256 entries)*/__declspec(vectortable) vectorTableEntryType _vect[256] = { /* Interrupt vector table */(vectorTableEntryType)__SP_AFTER_RESET, /* 0 (0x000) Initial supervisor SP */_startup, /* 1 (0x004) Initial PC */asm_exception_handler, /* 2 (0x008) Access Error */asm_exception_handler, /* 3 (0x00C) Address Error */asm_exception_handler, /* 4 (0x010) Illegal Instruction */asm_exception_handler, /* 5 (0x014) Reserved */asm_exception_handler, /* 6 (0x018) Reserved */asm_exception_handler, /* 7 (0x01C) Reserved */asm_exception_handler, /* 8 (0x020) Privilege Violation */...asm_exception_handler, /* 81 (0x144) Device-specific interrupts */asm_exception_handler, /* 82 (0x148) Device-specific interrupts */asm_exception_handler, /* 83 (0x14C) Device-specific interrupts */asm_exception_handler, /* 84 (0x150) Device-specific interrupts */asm_exception_handler, /* 85 (0x154) Device-specific interrupts */fnet_cpu_isr, /**** 86 (0x158) Timer 3 capture/reference event ****/asm_exception_handler, /* 87 (0x15C) Device-specific interrupts */asm_exception_handler, /* 88 (0x160) Device-specific interrupts */asm_exception_handler, /* 89 (0x164) Device-specific interrupts */asm_exception_handler, /* 90 (0x168) Device-specific interrupts */fnet_cpu_isr, /**** 91 (0x16C) FEC Receive frame interrupt ****/asm_exception_handler, /* 92 (0x170) Device-specific interrupts */asm_exception_handler, /* 93 (0x174) Device-specific interrupts */asm_exception_handler, /* 94 (0x178) Device-specific interrupts */asm_exception_handler, /* 95 (0x17C) Device-specific interrupts */... - If you are using CodeWarrior compiler for ColdFire platforms be sure that "Code Model" and "Data Model", in Processor settings, are set to "Far(32-bit)".
- Be sure that FNET_CFG_CPU_VECTOR_TABLE is set to correct value.
- Add the "fnet_stack" directory path to Search Paths of C and Assembler compiler.
- It is important to enable hardware interrupts in your project, because the FNET TCP/IP stack uses Ethernet module and Timer module interrupts for its own activity.
© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net