Espanol
AddThis Social Bookmark Button

TCP/IP stack for FLEX

This software implements a TCP/IP stack demo usable with FLEX boards. It enables communications with the board over an ethernet cable, using a variety of protocols. Here are some of the protocols included in the demo: DHCP (Dynamic Host Configuration Protocol), FTP (File Transfer Protocol), HTTP (Hypertext Transfer Protocol), SMTP (Simple Mail Transfer Protocol), SNMP (Simple Network Management Protocol), Secure NTP (Network Time Protocol), Telnet.
The demo was produced adapting the Microchip Technology Inc. TCP/IP Stack (version 4.18) and the related application notes.
This is the list of hardware components needed to use the demo:
* FLEX board (light or full)
* FLEX Multics daugtherboard
* FLEX Ethernet plug-in module
* FLEX RS232 plug-in module (optional)

//
// PIC18 Interrupt Service Routines
// 
// NOTE: Several PICs, including the PIC18F4620 revision A3 have a RETFIE FAST/MOVFF bug
// The interruptlow keyword is used to work around the bug when using C18
#if defined(__18CXX)

#if defined(HI_TECH_C)
void interrupt low_priority LowISR(void)
#else
#pragma interruptlow LowISR
void LowISR(void)
#endif
{
    TickUpdate();
}

#if defined(HI_TECH_C)
void interrupt HighISR(void)
#else
#pragma interruptlow HighISR
void HighISR(void)
#endif
{
    #if defined(STACK_USE_UART2TCP_BRIDGE)
	UART2TCPBridgeISR();
	#endif
}

#if !defined(HI_TECH_C)
#pragma code lowVector=0x18
void LowVector(void){_asm goto LowISR _endasm}
#pragma code highVector=0x8
void HighVector(void){_asm goto HighISR _endasm}
#pragma code // Return to default code section
#endif

#elif defined(__C30__)
//	void _ISR _AddressError(void)
//	{
//	    Nop();
//	    Nop();
//	    Nop();
//	}

#endif	// End of PIC18 ISRs

//
// Main application entry point.
//
#ifdef __C30__ 
int main(void)
#else
void main(void)
#endif
{
    static TICK t = 0;
	BYTE i;

    // Initialize any application specific hardware.
    InitializeBoard();

#ifdef USE_LCD
	// Initialize and display the stack version on the LCD
	LCDInit();
	for(i = 0; i < 100; i++)
		DelayMs(1);
	strcpypgm2ram((char*)LCDText, "TCPStack " VERSION "  "
								  "                ");
	LCDUpdate();
#endif

    // Initialize all stack related components.
    // Following steps must be performed for all applications using
    // the Microchip TCP/IP Stack.
    TickInit();

#if defined(STACK_USE_MPFS) || defined(STACK_USE_MPFS2)
    // Initialize Microchip File System module
    MPFSInit();
#endif

    // Initialize Stack and application related NV variables into AppConfig.
    InitAppConfig();

    // Initiates board setup process if button is depressed 
	// on startup
	// --- Changed for Flex board ---
	// --- Set to 1 to enable config menù on UART ---
    //if(BUTTON0_IO == 0u)
    if (0)
    {
		#if defined(MPFS_USE_EEPROM) && (defined(STACK_USE_MPFS) || defined(STACK_USE_MPFS2))
		// Invalidate the EEPROM contents if BUTTON0 is held down for more than 4 seconds
		TICK StartTime = TickGet();

		while(BUTTON0_IO == 0u)
		{
			if(TickGet() - StartTime > 4*TICK_SECOND)
			{
			    XEEBeginWrite(0x0000);
			    XEEWrite(0xFF);
			    XEEEndWrite();
				#if defined(STACK_USE_UART)
				putrsUART("\r\n\r\nBUTTON0 held for more than 4 seconds.  EEPROM contents erased.\r\n\r\n");
				#endif
				LED0_TRIS = 0;
				LED1_TRIS = 0;
				LED2_TRIS = 0;
				LED3_TRIS = 0;
				LED0_IO = 1;
				LED1_IO = 1;
				LED2_IO = 1;
				LED3_IO = 1;
				while((LONG)(TickGet() - StartTime) <= (LONG)(9*TICK_SECOND/2));
				Reset();
				break;
			}
		}
		#endif

		#if defined(STACK_USE_UART)
        SetConfig();
		#endif
    }

For more informations click here.