Te pongo el .h y el .c
* Author Date Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* E. Wood 4/26/08 Copied from MainDemo.c
********************************************************************/
#ifndef _MAINNESTOR_H
#define _MAINNESTOR_H
#define BAUD_RATE (19200) // bps
#if !defined(THIS_IS_STACK_APPLICATION)
extern BYTE AN0String[8];
#endif
void DoUARTConfig(void);
#if defined(EEPROM_CS_TRIS) || defined(SPIFLASH_CS_TRIS)
void SaveAppConfig(const APP_CONFIG *AppConfig);
#else
#define SaveAppConfig(a)
#endif
void SMTPDemo(void);
void PingDemo(void);
void SNMPTrapDemo(void);
void SNMPV2TrapDemo(void);
void GenericTCPClient(void);
void GenericTCPServer(void);
void BerkeleyTCPClientDemo(void);
void BerkeleyTCPServerDemo(void);
void BerkeleyUDPClientDemo(void);
// Define a header structure for validating the AppConfig data structure in EEPROM/Flash
typedef struct
{
unsigned short wConfigurationLength; // Number of bytes saved in EEPROM/Flash (sizeof(APP_CONFIG))
unsigned short wOriginalChecksum; // Checksum of the original AppConfig defaults as loaded from ROM (to detect when to wipe the EEPROM/Flash record of AppConfig due to a stack change, such as when switching from Ethernet to Wi-Fi)
unsigned short wCurrentChecksum; // Checksum of the current EEPROM/Flash data. This protects against using corrupt values if power failure occurs while writing them and helps detect coding errors in which some other task writes to the EEPROM in the AppConfig area.
} NVM_VALIDATION_STRUCT;
// An actual function defined in MainDemo.c for displaying the current IP
// address on the UART and/or LCD.
void DisplayIPValue(IP_ADDR IPVal);
#endif // _MAINNESTOR_H
* ---- -----------------------------------------
* 1.0 Initial release
* V5.36 ---- STACK_USE_MPFS support has been removed
********************************************************************/
/*
* This macro uniquely defines this file as the main entry point.
* There should only be one such definition in the entire project,
* and this file must define the AppConfig variable as described below.
*/
#define THIS_IS_STACK_APPLICATION
#define ENC28J60
// Include all headers for any enabled TCPIP Stack functions
#include "TCPIP Stack/TCPIP.h"
// Include functions specific to this stack application
#include "MainNestor.h"
#if defined(STACK_USE_ZEROCONF_LINK_LOCAL)
#include "TCPIP Stack/ZeroconfLinkLocal.h"
#endif
#if defined(STACK_USE_ZEROCONF_MDNS_SD)
#include "TCPIP Stack/ZeroconfMulticastDNS.h"
#endif
#ifdef USE_USB_INTERFACE
#include "USB/usb.h"
#include "USB/usb_host_msd.h"
#include "USB/usb_host_msd_scsi.h"
#endif
// Declare AppConfig structure and some other supporting stack variables
APP_CONFIG AppConfig;
BYTE AN0String[8];
// Private helper functions.
// These may or may not be present in all applications.
//static void InitAppConfig(void);
static void InitializeBoard(void);
//static void ProcessIO(void);
void main(void){
static DWORD t = 0;
static DWORD dwLastIP = 0;
// Initialize application specific hardware
InitializeBoard();
// Initialize stack-related hardware components that may be
// required by the UART configuration routines
TickInit();
#if defined(STACK_USE_MPFS) || defined(STACK_USE_MPFS2)
MPFSInit();
#endif
// Initialize Stack and application related NV variables into AppConfig.
// InitAppConfig();
// Initialize core stack layers (MAC, ARP, TCP, UDP) and
// application modules (HTTP, SNMP, etc.)
StackInit();
// Initialize any application-specific modules or functions/
// For this demo application, this only includes the
// UART 2 TCP Bridge
#if defined(STACK_USE_UART2TCP_BRIDGE)
UART2TCPBridgeInit();
#endif
// Now that all items are initialized, begin the co-operative
// multitasking loop. This infinite loop will continuously
// execute all stack-related tasks, as well as your own
// application's functions. Custom functions should be added
// at the end of this loop.
// Note that this is a "co-operative mult-tasking" mechanism
// where every task performs its tasks (whether all in one shot
// or part of it) and returns so that other tasks can do their
// job.
// If a task needs very long time to do its job, it must be broken
// down into smaller pieces so that other tasks can have CPU time.
while(1){
// This task performs normal stack task including checking
// for incoming packet, type of packet and calling
// appropriate stack entity to process it.
StackTask();
// This tasks invokes each of the core stack application tasks
StackApplications();
// Process application specific tasks here.
// For this demo app, this will include the Generic TCP
// client and servers, and the SNMP, Ping, and SNMP Trap
// demos. Following that, we will process any IO from
// the inputs on the board itself.
// Any custom modules or processing you need to do should
// go here.
#if defined(STACK_USE_GENERIC_TCP_CLIENT_EXAMPLE)
GenericTCPClient();
#endif
#if defined(STACK_USE_GENERIC_TCP_SERVER_EXAMPLE)
GenericTCPServer();
#endif
#if defined(STACK_USE_SMTP_CLIENT)
SMTPDemo();
#endif
#if defined(STACK_USE_ICMP_CLIENT)
PingDemo();
#endif
#if defined(STACK_USE_SNMP_SERVER) && !defined(SNMP_TRAP_DISABLED)
SNMPTrapDemo();
if(gSendTrapFlag)
SNMPSendTrap();
#endif
#if defined(STACK_USE_BERKELEY_API)
BerkeleyTCPClientDemo();
BerkeleyTCPServerDemo();
BerkeleyUDPClientDemo();
#endif
// If the local IP address has changed (ex: due to DHCP lease change)
// write the new IP address to the LCD display, UART, and Announce
// service
/* if(dwLastIP != AppConfig.MyIPAddr.Val)
{
dwLastIP = AppConfig.MyIPAddr.Val;
#if defined(STACK_USE_UART)
putrsUART((ROM char*)"\r\nNew IP Address: ");
#endif
DisplayIPValue(AppConfig.MyIPAddr);
#if defined(STACK_USE_UART)
putrsUART((ROM char*)"\r\n");
#endif
#if defined(STACK_USE_ANNOUNCE)
AnnounceIP();
#endif
}*/
}
}
static void InitializeBoard(void){
// LEDs
LedV = 0;
LedR = 1;
// Enable 4x/5x/96MHz PLL on PIC18F87J10, PIC18F97J60, PIC18F87J50, etc.
// OSCTUNE = 0x40;
// Set up analog features of PORTA
// ADCON0 = 0x01; // ADON, Channel 0
// ADCON1 = 0x0E; // Vdd/Vss is +/-REF, AN0 is analog
// ADCON2 = 0xBE; // Right justify, 20TAD ACQ time, Fosc/64 (~21.0kHz)
// Enable internal PORTB pull-ups
INTCON2bits.RBPU = 0;
// Configure USART
TXSTA = 0x20;
RCSTA = 0x90;
// See if we can use the high baud rate setting
#if (((GetPeripheralClock()+2*BAUD_RATE)/BAUD_RATE/4 - 1) <= 255)
SPBRG = (GetPeripheralClock()+2*BAUD_RATE)/BAUD_RATE/4 - 1;
TXSTAbits.BRGH = 1;
#else // Use the low baud rate setting
SPBRG = (GetPeripheralClock()+8*BAUD_RATE)/BAUD_RATE/16 - 1;
#endif
// Enable Interrupts
RCONbits.IPEN = 1; // Enable interrupt priorities
INTCONbits.GIEH = 1;
INTCONbits.GIEL = 1;
/* ADCON0bits.ADCAL = 1;
ADCON0bits.GO = 1;
while(ADCON0bits.GO);
ADCON0bits.ADCAL = 0;
*/
#if defined(SPIRAM_CS_TRIS)
SPIRAMInit();
#endif
#if defined(EEPROM_CS_TRIS)
XEEInit();
#endif
#if defined(SPIFLASH_CS_TRIS)
SPIFlashInit();
#endif
y las rutas:
en Out Put directory
pues a la carpeta donde quiero que salgan los archivos compilados, esa carpeta está dentro del proyecto.
en Intermediary directory:
en una carpeta llamada Objets creada dentro de la carpeta de mi proyecto
en Includer search path:
pues al includer donde estan todos los .h de mi proyecto dentro de la carpeta de mi proyecto
a la carpeta .h del compilador
y a una carpeta llamada include/tdpip que esta en mi proyecto
en Library search path:
en la carpeta tcpip stack dentro de mi proyecto
y a la carpeta lib del compilador c18
en Linker-script
esa a la carpeta lk de compilador
ósera lo que he creado es una copia de la carpeta del stack de microchip pero con los archivos de los stack tcp/ip en otro lugar y he redirigido las rutas, creo que eso está bien peroooo no soy ningún experto mas bien lo contrario.