示例#1
0
size_t nwxProcess::ProcessIO(size_t nLimit)
{
  size_t nRtn = 0;
  bool bInputClosed = false;
  if(!m_bPaused)
  {
    if(!IsInputOpened())
    {
      if(m_sBuffer.Len())
      {
        m_sBuffer += "\n";
        ProcessLine(m_sBuffer.utf8_str(),m_sBuffer.Len(),false);
        m_sBuffer.Empty();
      }
      bInputClosed = true;
    }
    else 
    {
      while(IsInputAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetInputStream(),m_sBuffer,false);
      }
    }
    if(!IsErrorOpened())
    {
      if(m_sBufferError.Len())
      {
        m_sBufferError += "\n";
        ProcessLine(m_sBufferError.utf8_str(),m_sBufferError.Len(),true);
        m_sBufferError.Empty();
      }
      if(bInputClosed && m_bRunning)
      {
    	  m_bRunning = false;
    	      // we are sometimes not notified when process ends
#ifndef __WXMSW__
    	  // need to clean up zombie because wx sometimes
    	  // fails to do this on the macintosh
    	  int nStatLoc;
    	  pid_t nPID;
    	  nPID = waitpid((pid_t)m_nPID,&nStatLoc,0);
    	  OnTerminate(m_nPID,nStatLoc);
#endif
      }
    }
    else 
    {
      while(IsErrorAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetErrorStream(),m_sBufferError,true);
      }
    }
  }
  return nRtn;
}
示例#2
0
文件: main.c 项目: AleSuky/SkP32v1.1
// *--------------------------------------------------------------------------------*
int main(){
	
    mJTAGPortEnable(0);							// JTAG des-habilitado
	SYSTEMConfigPerformance(GetSystemClock()); 	// Activa pre-cache.-
	
	AD1PCFG = 0xFFFF;
	LED1_OUTPUT();
	LED2_OUTPUT();
	SW1_INPUT();
	SW2_INPUT();
	
	buttonCount = 0;
    buttonPressed = FALSE;
    stringPrinted = TRUE;
	
	USBDeviceInit();	
	while(1){
		#if defined(USB_INTERRUPT)
		if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE)){
			USBDeviceAttach();
		}
		#endif
		#if defined(USB_POLLING)
			// Check bus status and service USB interrupts.
			USBDeviceTasks();
		#endif
		ProcessIO();
	}
}
示例#3
0
int main(void)
#endif
{
    InitializeSystem();

#if defined(USB_INTERRUPT)
    USBDeviceAttach();
#endif

    while(1)
    {
#if defined(USB_POLLING)
        // Check bus status and service USB interrupts.
        USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
        // this function periodically.  This function will take care
        // of processing and responding to SETUP transactions
        // (such as during the enumeration process when you first
        // plug in).  USB hosts require that USB devices should accept
        // and process SETUP packets in a timely fashion.  Therefore,
        // when using polling, this function should be called
        // frequently (such as once about every 100 microseconds) at any
        // time that a SETUP packet might reasonably be expected to
        // be sent by the host to your device.  In most cases, the
        // USBDeviceTasks() function does not take very long to
        // execute (~50 instruction cycles) before it returns.
#endif


        // Application-specific tasks.
        // Application related code may be added here, or in the ProcessIO() function.
        ProcessIO();
    }//end while
}//end main
示例#4
0
文件: main.c 项目: PeterLaiCCIT/regis
int main(void) {
    InitializeSystem();
    initADCDMA();

    
    #if defined(USB_INTERRUPT)
        if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE))
        {
            USBDeviceAttach();
        }
    #endif

    #if defined(USB_POLLING)
            // Check bus status and service USB interrupts.
            USBDeviceTasks();
    #endif
    while(1)
    {
        if (!ADC_DATA_READY)
            continue;
                
        ADC_DATA_READY = 0;
        
        RunFFT();

        putrsUSBUSART((char*)&fftOut[0].real);
        
        ProcessIO();
    }
    return (EXIT_SUCCESS);
}
示例#5
0
文件: main.c 项目: iruka-/ORANGEpico
/******************************************************************************
 * Function:        void main(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Main program entry point.
 *
 * Note:            None
 *****************************************************************************/
int main(void)
{   
    InitializeSystem();

    #if defined(USB_INTERRUPT)
        USBDeviceAttach();
    #endif

    while(1)
    {
        #if defined(USB_POLLING)
		// Check bus status and service USB interrupts.
        USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
        				  // this function periodically.  This function will take care
        				  // of processing and responding to SETUP transactions 
        				  // (such as during the enumeration process when you first
        				  // plug in).  USB hosts require that USB devices should accept
        				  // and process SETUP packets in a timely fashion.  Therefore,
        				  // when using polling, this function should be called 
        				  // regularly (such as once every 1.8ms or faster** [see 
        				  // inline code comments in usb_device.c for explanation when
        				  // "or faster" applies])  In most cases, the USBDeviceTasks() 
        				  // function does not take very long to execute (ex: <100 
        				  // instruction cycles) before it returns.
        #endif
    				  

		// Application-specific tasks.
		// Application related code may be added here, or in the ProcessIO() function.
        ProcessIO();        
    }//end while
}//end main
示例#6
0
文件: main.c 项目: EEST1/pic18_non_j
void BootMain(void)
#endif
{
    //NOTE: The c018.o file is not included in the linker script for this project.
    //The C initialization code in the c018.c (comes with C18 compiler in the src directory)
    //file is instead modified and included here manually.  This is done so as to provide
    //a more convenient entry method into the bootloader firmware.  Ordinarily the _entry_scn
    //program code section starts at 0x00 and is created by the code of c018.o.  However,
    //the linker will not work if there is more than one section of code trying to occupy 0x00.
    //Therefore, must not use the c018.o code, must instead manually include the useful code
    //here instead.

    //Make sure interrupts are disabled for this code (could still be on,
    //if the application firmware jumped into the bootloader via software methods)
    INTCON = 0x00;  

    //Initialize the C stack pointer, and other compiler managed items as 
    //normally done in the c018.c file (applicable when using C18 compiler)
    #ifndef __XC8__
        _asm
            lfsr 1, _stack
            lfsr 2, _stack
            clrf TBLPTRU, 0
        _endasm
    #endif

    //Clear the stack pointer, in case the user application jumped into 
    //bootloader mode with excessive junk on the call stack
    STKPTR = 0x00;  

    // End of the important parts of the C initializer.  This bootloader firmware does not use
    // any C initialized user variables (idata memory sections).  Therefore, the above is all
    // the initialization that is required.



    //Call other initialization code and (re)enable the USB module
    InitializeSystem();     //Some USB, I/O pins, and other initialization
    
    //Execute main loop
    while(1)
    {
        ClrWdt();
        
        //Need to call USBDeviceTasks() periodically.  This function takes care of
        //processing non-USB application related USB packets (ex: "Chapter 9" 
        //packets associated with USB enumeration)
        USBDeviceTasks();

        BlinkUSBStatus();   //When enabled, blinks LEDs on the board, based on USB bus state
        
        LowVoltageCheck();  //Regularly monitor voltage to make sure it is sufficient
                            //for safe operation at full frequency and for erase/write
                            //operations.       
        
        ProcessIO();        //This is where all the actual bootloader related data transfer/self programming takes
                            //place see ProcessIO() function in the BootPIC[xxxx].c file.
    }//end while    
}    
示例#7
0
void USBtask(void)
{
	USBCheckBusStatus();					// Must	use	polling	method
	USBDriverService();						// Interrupt or	polling	method
	if((usb_device_state ==	CONFIGURED_STATE) && (UCONbits.SUSPND != 1)) {
		ProcessIO();
	}
}
示例#8
0
文件: main.c 项目: ikesato/bt-remocon
int main(void)
#endif
{   
    InitializeSystem();

    while(1) {
        ProcessIO();        
    }
}
/******************************************************************************
 * Function:        void main(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Main program entry point.
 *
 * Note:            None
 *****************************************************************************/
void main(void)
{
    InitializeSystem();
    while(1)
    {
        USBTasks();         // USB Tasks
        ProcessIO();        // See user\user.c & .h
    }//end while
}//end main
示例#10
0
文件: main.c 项目: primiano/lgtm-hid
void main(void) {
  InitializeSystem();

  // If the switch is pressed on boot, enter system config mode.
  g_config_mode = (sw == 0);

  while (1) {
    USBDeviceTasks();
    ProcessIO();
  }
}
示例#11
0
int main(void)
{
    struct BadgeState *game_state;
    char sample_i = 0, sample_val = 0;

    InitializeSystem();

    #if defined(USB_INTERRUPT)
        USBDeviceAttach();
    #endif

    #if defined(GAME_MODE)
        game_state = Init_Game();
    #endif
    while(1)
    {
        if((play_count & 0x0fff) && play_count & 0x8000)
        {
            //LATBbits.LATB2 = 1;
            //LATBbits.LATB3 = 1;

            getNextSample( &sample_i, &sample_val);
            LATAbits.LATA9 = sample_val;
            play_count++;
        }
        else
            play_count = play_count & 0x8000;

        #if defined(USB_POLLING)
		// Check bus status and service USB interrupts.
        USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
        				  // this function periodically.  This function will take care
        				  // of processing and responding to SETUP transactions 
        				  // (such as during the enumeration process when you first
        				  // plug in).  USB hosts require that USB devices should accept
        				  // and process SETUP packets in a timely fashion.  Therefore,
        				  // when using polling, this function should be called 
        				  // regularly (such as once every 1.8ms or faster** [see 
        				  // inline code comments in usb_device.c for explanation when
        				  // "or faster" applies])  In most cases, the USBDeviceTasks() 
        				  // function does not take very long to execute (ex: <100 
        				  // instruction cycles) before it returns.
        #endif
    				  

		// Application-specific tasks.
		// Application related code may be added here, or in the ProcessIO() function.
        ProcessIO();
    #if defined(GAME_MODE)
         Run_Game(&game_state);
        //welcome(game_state);
    #endif
    }//end while
}//end main
示例#12
0
bool_t emvStopRequestReceived()
{
    ProcessIO();

    if (emvStopRequestReceivedFlag)
    {
        emvStopRequestReceivedFlag = FALSE;
        return TRUE;
    }
	
    return FALSE;
}
示例#13
0
int main(void)
#endif
{
    InitializeSystem();

    USBDeviceInit();

    while(1)
    {
        USBDeviceTasks(); 
        ProcessIO();        
    }
}
示例#14
0
/**
 * Main function
 * Main program entry point.
 *
 */
void main(void)
{
    InitializeSystem();

    tickInit();

    while(1)
    {
        USBTasks();
        BlinkUSBStatus();
        if (!((usb_device_state < CONFIGURED_STATE)||(UCONbits.SUSPND==1)))
           ProcessIO();  // See user\user.c & .h
    }
}
示例#15
0
/********************************************************************
 *	メイン処理
 ********************************************************************
 */
void USBmonit(void)
{
	uchar buf[PACKET_SIZE];

	int rc=0;
	s_linecoding = 0;
	Init_Monitor();
	while(1) {
		rc = USBgetpacket(buf,PACKET_SIZE);
		if( (rc<0) || (buf[0] != MONIT_SOF) ) return;
		memcpy(PacketFromPC.raw,buf+1,PACKET_SIZE-1);
		ProcessIO();
	}
}
示例#16
0
文件: main.c 项目: fjferrer/openSoC
/**
 * main(void) - Main entry point of the firmware
 *
 * This is the main entrance of the firmware and it creates the mail loop.
 **/
void main(void)
{
  /**
   * Inits the PIC
   **/
  UserInit();
  /**
   * Inits the USB
   *
   * Full-speed mode and sets pull-up internal resistances of PORTB
   * Starts the USB DEATACHED, no wake ups, and no configured.
   * Configuring the USB is the job of the host.
   **/
  UCFG = 0x14;
  deviceState = DETACHED;
  remoteWakeup = 0x00;
  currentConfiguration = 0x00;
  
  adval = 'b';

  ADCON0=0x00;
  ADCON0bits.CHS0=0;   //Select ADC Channel
  ADCON0bits.CHS1=1;   //Select ADC Channel
  ADCON0bits.CHS2=1;   //Select ADC Channel
  ADCON0bits.CHS3=0;   //Select ADC Channel
  
  while (1) {
    /** 
     * Make sure the USB is available 
     **/
    EnableUSBModule();
    /**
     * As soon as we get out of test mode (UTEYE)
     * we process USB transactions
     **/
    if (UCFGbits.UTEYE != 1)
      ProcessUSBTransactions();
    
    /**
     * Now we can make our work
     **/
    ProcessIO();
    
    //adval=ADCRead(7);   //Read Channel 7
    //delay(100);

    //status();
    
  }
}
示例#17
0
// Main function
void main(void)
{
    InitialiseSystem();

	// We are up and running, show 'ready' status in LED0
	//LED0 = ON;

    while(1)
    {
		// Check bus status and service USB interrupts.
        USBDeviceTasks();

		// Application-specific tasks.
        ProcessIO();
    }
}
示例#18
0
void main(void)
{
	InitializeSystem();

	#if defined(USB_INTERRUPT)
		USBDeviceAttach();
	#endif

	while(1)
	{
		#if defined(USB_POLLING)
			USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
		#endif
		ProcessIO();
	}//end while
}//end main
示例#19
0
int main(void)
{   
    InitializeSystem();

    while(1)
    {
        #if defined(USB_INTERRUPT)
            //if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE))
            //{
                USBDeviceAttach();              
            //}
        #endif

        /*if(USBDeviceState < CONFIGURED_STATE) {
            if(!I2CState.Slave)
                InitI2CSlave();
            }
        else if(!I2CState.Master)
            InitI2CMaster();*/

        #if defined(USB_POLLING)
    // Check bus status and service USB interrupts.
        USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
                          // this function periodically.  This function will take care
                          // of processing and responding to SETUP transactions 
                          // (such as during the enumeration process when you first
                          // plug in).  USB hosts require that USB devices should accept
                          // and process SETUP packets in a timely fashion.  Therefore,
                          // when using polling, this function should be called 
                          // regularly (such as once every 1.8ms or faster** [see 
                          // inline code comments in usb_device.c for explanation when
                          // "or faster" applies])  In most cases, the USBDeviceTasks() 
                          // function does not take very long to execute (ex: <100 
                          // instruction cycles) before it returns.
        #endif
        
        if(TMR0IF)
            WorkTick();

        if(Status.State == 'P'){
            AsicPushWork();
        }
                      
        ProcessIO();  
              
    }//end while
}//end main
示例#20
0
void main( void )
{
    InitializeSystem();

    #if defined( USB_INTERRUPT )
    USBDeviceAttach();
    #endif

    while ( 1 )
    {
        #if defined( USB_POLLING )
        // Check bus status and service USB interrupts.
        USBDeviceTasks(); // Call every 100us or so (takes ~50 instruction cycles before it returns).
        #endif

        ProcessIO();
    }
}
示例#21
0
文件: main.c 项目: PedroDiogo/POV
/******************************************************************************
 * Function:        void main(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Main program entry point.
 *
 * Note:            None
 *****************************************************************************/
void main(void)
{   
    InitializeSystem();

    #if defined(USB_INTERRUPT)
        USBDeviceAttach();
    #endif

    while(1)
    {
        #if defined(USB_POLLING)
            USBDeviceTasks();
        #endif
       	// Application-specific tasks.
		// Application related code may be added here, or in the ProcessIO() function.
        ProcessIO();
    }//end while
}//end main
示例#22
0
int main(void)
#endif
{   
    InitializeSystem();

    #if defined(USB_INTERRUPT)
        USBDeviceAttach();
    #endif

    while(1)
    {
        #if defined(USB_POLLING)
		// Check bus status and service USB interrupts.
        USBDeviceTasks(); 
        #endif
		// Application specific code is added in ProcessIO()
        ProcessIO();        
    }//end while
}//end main
示例#23
0
文件: main.c 项目: z9u2k/remote
int main(void)
#endif
{   
    InitializeSystem();

    while(1) {
        #if defined(USB_INTERRUPT)
            if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE)) {
                USBDeviceAttach();
            }
        #endif

        #if defined(USB_POLLING)
        USBDeviceTasks();
        #endif

        ProcessIO();
    }
}
示例#24
0
文件: main.c 项目: gnrr/pic_usb_vol
/******************************************************************************
 * Function:        void Main(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        Main program entry point.
 *
 * Note:            None
 *****************************************************************************/
void Main(void)
{   
	//NOTE: The c018.o file is not included in the linker script for this project.
	//The C initialization code in the c018.c (comes with C18 compiler in the src directory)
	//file is instead modified and included here manually.  This is done so as to provide
	//a more convenient entry method into the bootloader firmware.  Ordinarily the _entry_scn
	//program code section starts at 0x00 and is created by the code of c018.o.  However,
	//the linker will not work if there is more than one section of code trying to occupy 0x00.
	//Therefore, must not use the c018.o code, must instead manually include the useful code
	//here instead.

    // Initialize the C stack pointer, and other compiler managed items as normally done in the c018.c file.
	_asm
    lfsr 1, _stack
    lfsr 2, _stack
    clrf TBLPTRU, 0 
	_endasm
	// End of the important parts of the C initializer.  This bootloader firmware does not use
	// any C initialized user variables (idata memory sections).  Therefore, the above is all
	// the initialization that is required.


    InitializeSystem();		//Some USB, I/O pins, and other initialization

    while(1)
    {
		ClrWdt();		
	    USBTasks();		        // Need to call USBTasks() periodically
	    						// it handles SETUP packets needed for enumeration

		BlinkUSBStatus();		//Blink the LEDs based on current USB state
		
	    if((usb_device_state == CONFIGURED_STATE) && (UCONbits.SUSPND != 1))
	    {
 	       ProcessIO();   // This is where all the actual bootloader related data transfer/self programming takes place
 	    }				  // see ProcessIO() function in the Boot87J50Family.c file.
    }//end while    
    
    
    
}//end main
示例#25
0
/**
 * main:
 **/
void
main(void)
{
	uint16_t runcode_start = 0xffff;

	/* stack overflow / underflow */
	if (STKPTRbits.STKFUL || STKPTRbits.STKUNF)
		CHugFatalError(CH_ERROR_OVERFLOW_STACK);

	/* the watchdog saved us from our doom */
	if (!RCONbits.NOT_TO)
		CHugFatalError(CH_ERROR_WATCHDOG);

	/*
	 * Boot into the flashed program if all of these are true:
	 *  1. we didn't do soft-reset
	 *  2. the flashed program exists
	 *  3. the flash success is 0x01
	 */
	ReadFlash(CH_EEPROM_ADDR_RUNCODE, 2,
		  (unsigned char *) &runcode_start);
	ReadFlash(CH_EEPROM_ADDR_FLASH_SUCCESS, 1,
		  (unsigned char *) &flash_success);
	if (RCONbits.NOT_RI &&
	    runcode_start != 0xffff &&
	    flash_success == 0x01)
		CHugBootFlash();

	InitializeSystem();

	while(1) {

		/* clear watchdog */
		ClrWdt();

		/* check bus status and service USB interrupts */
		USBDeviceTasks();

		ProcessIO();
	}
}
示例#26
0
// Main function
void main(void)
{
    InitialiseSystem();

	// We are up and running, show 'ready' status in LED0
	LED0 = OFF;
	on = 0;
	
//	for (int i=0;i<8;i++) {
//		info[i] = 0;
//	}	

    while(1)
    {
		// Check bus status and service USB interrupts.
        USBDeviceTasks();

		// Application-specific tasks.
        ProcessIO();        
    }
}
示例#27
0
int main(void)
#endif
{   
    unsigned int i=0;
    InitializeSystem();
    for(i=0;i<SAMPLE_SIZE;i++)ADC_sample[i]=0;
    while(1)
    {
        #if defined(USB_INTERRUPT)
            if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE))
            {
                USBDeviceAttach();
            }
        #endif

   				  

		// Application-specific tasks.
		// Application related code may be added here, or in the ProcessIO() function.
    //ReadADC();
    ProcessIO();
    }//end while
}//end main
示例#28
0
/*
 * Main entry point.
 */
void main(void)
{
    static TICK t = 0;
    BYTE c, i;
    WORD w;
    BYTE buf[10];
    
    /*
     * Initialize any application specific hardware.
     */
    InitializeBoard();

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

    /*
     * Initialize MPFS file system.
     */
    MPFSInit();

    //Intialize HTTP Execution unit
    htpexecInit();

    //Initialze serial port
    serInit();

    /*
     * Initialize Stack and application related NV variables.
     */
    appcfgInit();
    appcfgUSART();  //Configure the USART
#ifdef SER_USE_INTERRUPT    //Interrupt enabled serial ports have to be enabled
    serEnable();
#endif
    appcfgCpuIO();  // Configure the CPU's I/O port pins
    appcfgADC();    // Configure ADC unit
    appcfgPWM();	// Configure PWM unit

    //Clear Screen
    serPutRomString(AnsiEscClearScreen);

    /*
     * Wait a couple of seconds for user input.
	 * - If something is detected, start config.
	 * - If nothing detected, start main program.
     */
	serPutRomString(PressKeyForConfig);

	for (i = 60; i > 0; --i)	//Delay for 50mS x 60 = 3 sec
	{
		if ((i % 8) == 0) serPutByte('.');
		if (serIsGetReady())
		{
	        SetConfig();
			break;
		}
		DelayMs(50);
	}
	serPutByte('\r');
	serPutByte('\n');

    StackInit();

#if defined(STACK_USE_HTTP_SERVER)
    HTTPInit();
#endif

#if defined(STACK_USE_FTP_SERVER) && defined(MPFS_USE_EEPROM)
    FTPInit();
#endif


#if defined(STACK_USE_DHCP) || defined(STACK_USE_IP_GLEANING)
    if (!AppConfig.Flags.bIsDHCPEnabled )
    {
        /*
         * Force IP address display update.
         */
        myDHCPBindCount = 1;
#if defined(STACK_USE_DHCP)
        DHCPDisable();
#endif
    }
#endif

#if defined( STACK_USE_VSCP )
	vscp2_udpinit();	// init VSCP subsystem
#endif

    /*
     * Once all items are initialized, go into infinite loop and let
     * stack items execute their tasks.
     * If application needs to perform its own task, it should be
     * done at the end of while 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 broken
     * down into smaller pieces so that other tasks can have CPU time.
     */
    while ( 1 )
    {
        /*
         * Blink SYSTEM LED every second.
         */
        if ( TickGetDiff( TickGet(), t ) >= TICK_SECOND/2 )
        {
            t = TickGet();
            LATB6 ^= 1;
        }

        //Perform routine tasks
        MACTask();

        /*
         * This task performs normal stack task including checking
         * for incoming packet, type of packet and calling
         * appropriate stack entity to process it.
         */
        StackTask();

#if defined(STACK_USE_HTTP_SERVER)
        /*
         * This is a TCP application.  It listens to TCP port 80
         * with one or more sockets and responds to remote requests.
         */
        HTTPServer();
#endif

#if defined(STACK_USE_FTP_SERVER) && defined(MPFS_USE_EEPROM)
        FTPServer();
#endif

        /*
         * In future, as new TCP/IP applications are written, it
         * will be added here as new tasks.
         */

         /*
          * Add your application speicifc tasks here.
          */
        ProcessIO();
       /* 
        XEEBeginRead( EEPROM_CONTROL, 0x0530 );
        while ( 1 ) {
	        c = XEERead();
        	c = 1;
        }
        //c = XEERead();
        XEEEndRead();
        */
#if defined( STACK_USE_VSCP )
		vscp2_Task();
#endif        
        

        /*
         * For DHCP information, display how many times we have renewed the IP
         * configuration since last reset.
         */
        if ( DHCPBindCount != myDHCPBindCount )
        {
            DisplayIPValue(&AppConfig.MyIPAddr, TRUE);
            myDHCPBindCount = DHCPBindCount;
        }
    }
}
示例#29
0
//função principal
void main(void)
{
    static TICK t = 0;

    //inicializa todas as configuraçoes de hardware
    InitializeBoard();

    #if defined(USE_LCD)
    //inicializa configs do LCD se acaso estiver habilitado
    LCDInit();
    DelayMs(100);
    strcpypgm2ram((char*)LCDText, "APP TCPIP");
    LCDUpdate();
    #endif

    //inicializa um tick de tempo usado para TICK,SPI,UAT
    TickInit();

    //inicializa MPSF para upload de paginas web se acaso estiver habilitado
    #if defined(STACK_USE_MPFS) || defined(STACK_USE_MPFS2)
    MPFSInit();
    #endif

    //inicializa variaveis da aplicação AppConfig (IP, MASCARA, GATWAY, ETC)
    InitAppConfig();

    //inicializa a layer da pilha TCPIP (MAC, ARP, TCP, UDP)
    //e tambem as aplicaçoes habilitadas (HTTP, SNMP, SOCKET, ETC)
    StackInit();

    //inicializa UART 2 TCP Bridge
    #if defined(STACK_USE_UART2TCP_BRIDGE)
    UART2TCPBridgeInit();
    #endif

    //laço principal (nunca use delays, apenas maquinas de estado)
    //todos os processos devem estar executando paralelamente
    while(1)
    {
        //pisca o led para informar a pilha rodando
        if(TickGet() - t >= TICK_SECOND/2ul)
        {
            t = TickGet();
            LED0_IO ^= 1;
        }

        //processa coisas relacionadas ao hardware, leitura de pinos,etc.
        ProcessIO();

        //chama tarefas da pilha TCPIP
        StackTask();

        //chama tarefas das aplicaçoes habilitadas
        StackApplications();

        //exemplo de aplicação Cliente Socket
        #if defined(STACK_USE_TCP_CLIENT)
        ClientSocketTCP();
        #endif

        //exemplo de aplicação Servidor Socket
        #if defined(STACK_USE_TCP_SERVER)
        ServerSocketTCP();
        #endif
    }
}
示例#30
0
void main (void)
{
 unsigned int pll_startup_counter = 1600;
	//Init ports
	//1=in, 0=output
	unsigned char adc_nr=0;	

     OSCTUNEbits.PLLEN = 1;  //Enable the PLL and wait 2+ms until the PLL locks before enabling USB module
      while(pll_startup_counter--);

	TRISA	= 0b0;	// all out
	TRISB	= 0b00100000;	// 
	TRISC	= 0b0;   // 
	
//	RPINR6 = 0;

	OpenTimer0  (TIMER_INT_ON & T0_SOURCE_INT & T0_16BIT & T0_PS_1_1);
	WriteTimer0 (TIMER_START_SEC);
	INTCONbits.GIE = 1;

	LED = 1;

	CS_1 = 1;
	CS_2 = 1;
	CS_3 = 1;
	CS_4 = 1;
	CS_5 = 1;
	CS_6 = 1;
	CS_7 = 1;
	CS_8 = 1;
	CS_9 = 1;

	CS_1 = 0;
	CS_2 = 0;
	CS_3 = 0;
	CS_4 = 0;
	CS_5 = 0;
	CS_6 = 0;
	CS_7 = 0;
	CS_8 = 0;
	CS_9 = 0;


	OpenSPI(SPI_FOSC_16, MODE_00, SMPMID);

	while(adc_nr < 4){

		spi_transfer(adc_nr, 0xFFFF);
		spi_transfer(adc_nr, ( WRITE_REG | (0<<10) ));
//		spi_transfer(adc_nr, AUTOMATIC_SEQUENCE);
//		spi_transfer(adc_nr, AUTOMATIC_SEQUENCE);

		adc_nr++;
	}
	adc_nr=0;

	USB_Out_Buffer[0]=59;
	USB_Out_Buffer[1]=1;
	USB_Out_Buffer[2]=0;
	USB_Out_Buffer[3]=0;
	USB_Out_Buffer[4]=0;
	USB_Out_Buffer[5]=0;

	 USBDeviceInit();	


	while(1){
	//mainloop
		   USBDeviceTasks(); 
			if(transmit){

				ProcessIO();

				transmit =1;
			}		
	}

}