예제 #1
0
void tlc5940_init(void)
{
	//enable clocks to GPIO block
	LPC_SYSCON->SYSAHBCLKCTRL |= (1UL <<  6);

	INIT_GPIO(SCLK_PORT, SCLK);
	INIT_GPIO(XLAT_PORT, XLAT);
	INIT_GPIO(SIN_PORT, SIN);
	//INIT_GPIO(GSCLK_PORT, GSCLK);
	//INIT_GPIO(DCPRG_PORT, DCPRG);
	//INIT_GPIO(VPRG_PORT, VPRG);
	INIT_GPIO(BLANK_PORT, BLANK);

	CLEARBIT(SCLK_PORT, SCLK);
	CLEARBIT(XLAT_PORT, XLAT);
	CLEARBIT(SIN_PORT, SIN); 
	//CLEARBIT(GSCLK_PORT, GSCLK); 
	//CLEARBIT(DCPRG_PORT, DCPRG);
	//SETBIT(VPRG_PORT, VPRG);
	SETBIT(BLANK_PORT, BLANK);

	/* Init IOCON - Nothing works without this... */
	LPC_SYSCON->SYSAHBCLKCTRL |= (1 <<  16);

	/* TMR16B1 -- GSCLK Generator */	
//	LPC_SYSCON->SYSAHBCLKCTRL |=  (1<<8);             	// Enable Clock for TMR1
//	LPC_IOCON->PIO1_9 |= (1<<0);
//	LPC_TMR16B1->MR0 = 118;					//Fire Interrupt each .02 second (20 ms or 50 Hz)
//	LPC_TMR16B1->PR = 1;							  	
//	LPC_TMR16B1->EMR |= (3<<4);							//Toggle on MR0
//	LPC_TMR16B1->MCR |= (1<<1);							//Reset on MR0	  
//  	LPC_TMR16B1->TCR |= (1<<0);                        	// GO
	

	/* TMR16B0 -- Interrupt timer */	
	LPC_SYSCON->SYSAHBCLKCTRL |=  (1<<7);             	// Enable Clock for TMR0
	//LPC_IOCON->PIO1_9 |= (1<<0);
	LPC_TMR16B0->MR2 = 20000;							//Fire Interrupt each .02 second (20 ms or 50 Hz)
	LPC_TMR16B0->PR = 48;							  	
	LPC_TMR16B0->MCR |= (1<<6);							//Interrupt on MR2
	LPC_TMR16B0->MCR |= (1<<7);							//Reset on MR2
	NVIC_EnableIRQ(TIMER_16_0_IRQn);         			//enable interrupt 	  
  	LPC_TMR16B0->TCR |= (1<<0);                        	// GO	

	/* GS CLK */
	LPC_SYSCON->CLKOUTDIV = 59;
	LPC_SYSCON->CLKOUTCLKSEL = 0;
	LPC_SYSCON->CLKOUTUEN = 0;
	LPC_SYSCON->CLKOUTUEN = 1;

	LPC_IOCON->PIO0_1 |= (1<<0);
}
예제 #2
0
파일: main.c 프로젝트: EFraim/trans-vpn
void initGPIO()
{
  // Use slow/fast I/O registers and 
  INIT_GPIO();
  
  // Enable out direction for LEDs
  IODIR |= (KEEP_ALIVE_LED | EP2_IN_LED | EP2_OUT_LED | EP1_IN_LED | ABORT_LED | USB_LED | ADMIN_LED);
  
  // Turn off all LEDs
  IOPIN |= (KEEP_ALIVE_LED | EP2_IN_LED | EP2_OUT_LED | EP1_IN_LED | ABORT_LED | USB_LED | ADMIN_LED);
}
예제 #3
0
파일: Device.c 프로젝트: ghostro/fmstick
/*-------------------------------------------------------------------
main(): This main is for device including the audio/hid/dfu
-------------------------------------------------------------------*/
void main()
{
	INIT_GPIO();
	TxPoweredUp = FALSE;
	FePoweredUp = FALSE;
#ifdef _DEBUG_RESET_ 
    FalseReset = 0;
#endif

    // Give the XRAM time to powered up as the MCU of the emulator is faster
#ifdef _EMULATOR_
    delay(80);	
    GLOBCTL = GLOBCTL_INIT;
	delay(100);
#else
    GLOBCTL = GLOBCTL_INIT;
#endif

    // ROM code using PDATA starting at 0xFA00
	P2 = 0xFA;
	RomRecord.state  = ROM_APP_RUNNING;

	devInit();
	
	// using ROM DFU handler
	devRomFunction(ROM_INIT_DFU_STATE);
			
   	// using ROM USB engine
	USBENGINE_EP0_SIZE = DEV_MAX_EP0_PKT;
	devRomFunction(ROM_ENG_USB_INIT);

	// wait till codec inited (USB Host must select device configuration)
	while (AppDevice.configSetting == 0 && asq_delayed < 20000) {
		devCheckReset();
		asq_delayed++;
	}

//#define NO_ANALOG
#ifdef NO_ANALOG
	if(asq_delayed == 20000)
		AppDeviceAnalogMode=TRUE;
#else
	while (AppDevice.configSetting == 0)
		devCheckReset();
#endif

usb_pc_answered:
	asq_delayed=0;
	// Take Codec (Si471x) out of reset
	si47xxReset();
    // Turn on status LED
    //USBLed = LED_ON;
	/* start transmitter, if eeprom says yes */
	if(configCheckStartupNeeded()) {
		if(!si47xxPowerUp() || !si47xxFMTX_hardware_cfg() || !configSetStartupConfig()) {
			si47xxReset();
		} else {
			/* if we started stand-alone (out-of PC), just loop here infinetily */
			while(AppDeviceAnalogMode) {
				READ_ASQ_STATUS();
				if(AppDevice.configSetting == 0) {
					devCheckReset();
				} else {
					//we have answer from PC (usb devce connected...)
					AppDeviceAnalogMode=FALSE;
					goto usb_pc_answered;
				}
			}
		}
	}

	AppResetFlag = FALSE;
	AppSuspendFlag = FALSE;
	SpkEnOut = 0;

	while(1) {
        // For DFU mode
		if (RomRecord.state == ROM_DFU_MODE) {
			// Setup for reenumeration
        	// as device in DFU mode
			USBCTL = 0;
			USBFADR = 0;
			PARAMS_DFU_SETUP(DFU_TARGET_EEPROM, 0);
	        // this is for testing DFU_TARGET_OTHER	
		    // DevTestDfuDataPtr = (unsigned char xdata *)0x6000;
			devRomFunction(ROM_RUN_DFU_MODE);
		}
		devCheckReset();
		devUpdateCodec();
#if 1
		// Handle SUSPENSE/RESUME
		if ((AppSuspendFlag == TRUE) && (AppResetFlag == FALSE)) {
        	devSleepModeOn();
#ifndef _EMULATOR_
			PCON = 0x09;
#endif
   	  		while (AppSuspendFlag == TRUE);
      	 	devSleepModeOff();		
			// Delay a bit (approx. 5 ms) to account for button debounce 
	        // if it was used to do a remote wake up. 
    		delay(20);
       	} else {
			HID_ACCESS(); //get HID report from PC & write to SI4711
			READ_ASQ_STATUS();
		}
#else
	HID_ACCESS(); //get HID report from PC & write to SI4711
#endif
	}
	return;

	// Just a dummy code to force the compiler to keep 
	// DevFunctionEntryParser() in the final codes
	DevFunctionEntryParser(0, 0);

}