Esempio n. 1
0
/**
 * 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();
    
  }
}
Esempio n. 2
0
void init_CDC()
{
	INTCON=0;
	INTCON2=0xC0;
	UCON=0;
	UCFG=0;
	UEP0=0;UEP1=0;UEP2=0;UEP3=0;UEP4=0;UEP5=0;
	UEP6=0;UEP7=0;UEP8=0;UEP9=0;UEP10=0;UEP11=0;
	UEP12=0;UEP13=0;UEP14=0;UEP15=0;
	// and wait 5 seconds
	Delayms(2000);
	// Initialize USB for CDC
	UCFG = 0x14; 				// Enable pullup resistors; full speed mode
	deviceState = DETACHED;
	remoteWakeup = 0x00;
	currentConfiguration = 0x00;
	// And enable USB module
	while(deviceState != CONFIGURED)
	{
	  EnableUSBModule();
	  ProcessUSBTransactions();
	}
}