Example #1
0
// *--------------------------------------------------------------------------------*
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();
	}
}
Example #2
0
// *--------------------------------------------------------------------------------*
int main(){
	UINT16 Count=0;
	
    mJTAGPortEnable(0);							// JTAG des-habilitado
	SYSTEMConfigPerformance(GetSystemClock()); 	// Activa pre-cache.-
	
	LED1_OUTPUT();
	LED2_OUTPUT();
	INTEnableSystemMultiVectoredInt();
	deviceAttached = FALSE;
    //Initialize the stack
    USBInitialize(0);
    
	while(1){
		//USB stack process function
        USBTasks();
		if(++Count==0){
			LED1_TOGGLE();
		}
        //if thumbdrive is plugged in
        if(USBHostMSDSCSIMediaDetect()){
            deviceAttached = TRUE;
            LED1_OFF();
            //now a device is attached
            //See if the device is attached and in the right format
            if(FSInit()){
                //Opening a file in mode "w" will create the file if it doesn't
                //  exist.  If the file does exist it will delete the old file
                //  and create a new one that is blank.
                myFile = FSfopen("test.txt","w");

                //Write some data to the new file.
                FSfwrite("This is a test.",1,15,myFile);                

                //Always make sure to close the file so that the data gets
                //  written to the drive.
                FSfclose(myFile);

                //Just sit here until the device is removed.
                while(deviceAttached == TRUE){
                    USBTasks();
                    if(++Count==0){
						LED2_TOGGLE();
					}
                }
                LED2_OFF();
            }
        }
	}
}
Example #3
0
int main(void)
{
  unsigned char i;
  unsigned char ChkSum;
  //POWER ON indication: LED blink 3 times
  LED2_OUTPUT();
  LED2_OFF();
  MODULE_OFF(); //for reset
  for(i=0;i<3;i++){
    Delay_ms(200);
    LED2_ON();
    Delay_ms(200);
    LED2_OFF();
  }
  LED2_OFF();
  MODULE_ON(); //for reset
  Delay_ms(200);

  //Initialize command port
  RFXX_PORT_INIT();
  //Initialize RF12 chip
  RF12_INIT();
  //Init FIFO
  RFXX_WRT_CMD(0xCA81);
  while(1){
    //Enable FIFO
    RFXX_WRT_CMD(0xCA83);
    ChkSum=0;
    //Receive payload data
    for(i=0;i<16;i++){
      ChkSum+=RF12_RECV();
    }
    //Receive Check sum
    i=RF12_RECV();
    //Disable FIFO
    RFXX_WRT_CMD(0xCA81);
    //Package chkeck
    if(ChkSum==i){
      LED2_ON();
      Delay_ms(200);
      LED2_OFF();
    }
  }
}
Example #4
0
// *--------------------------------------------------------------------------------*
int main(){
	UINT8 k=0;
	UINT16 Conversion;
	
    mJTAGPortEnable(0);							// JTAG des-habilitado
	SYSTEMConfigPerformance(GetSystemClock()); 	// Activa pre-cache.-
	
	LED1_OUTPUT();
	LED2_OUTPUT();
	LED3_OUTPUT();
	LED4_OUTPUT();
	SW1_INPUT();
	SW2_INPUT();
	
	PORTSetPinsDigitalOut(IOPORT_D, BIT_1);		// Backlight del TFT
	mPORTDSetBits(BIT_1);
	vLCDTFTInit();
	vLCDTFTFillScreen(ColorWhite);
	vADC_Init();
	while(1){
		if(SW1_STATUS()==0){
			vLCDTFTRectangle(0,0,200,319,1,Colores[k]);
			if(++k==6){k=0;}
			DelayMs(250);
		}
		if(SW2_STATUS()==0){
			LED2_TOGGLE();
			LED4_TOGGLE();
			DelayMs(250);
		}
		Conversion=ADC_Conversion();
		vLCDTFTRectangle(201,0,239,319,1,ColorWhite);
		// 1023 -> 0; 0 -> 239
		vLCDTFTRectangle(202,((-0.31183*Conversion)+319.0),238,319,1,ColorRed);
		DelayMs(50);
	}
}