Пример #1
0
void greenAndRed(void){
	greenDirection = 1;
	interval = 2800;
	level = 0;
	extTIrqHandler = gnrTIrqHandler;
	extKIrqHandler = gnrKIrqHandler;
	lcdSetCursor(0,0);
	lcdPixelsDraw(240*320, BACKGROUND_COLOUR);
	lcdSetBackgroundColour(BACKGROUND_COLOUR);
	lcdSetFontColour(BRICK_COLOUR);
	lcdPrint(10,10, "LEVEL 0");
	objectDraw(&brick, 50, 152);
	objectDraw(&flier, 150, 10);
	greenCounter = 0;
	redCounter = 0;
	timerSetMatch(interval);

	while(1){
		
		irqDisableSec();
		lcdSetFontColour(BRICK_COLOUR);
		lcdDrawChar(10, 246, (char)(greenCounter+48));
		lcdSetFontColour(63, 0, 0);
		lcdDrawChar(10, 294, (char)(redCounter+48));
		irqEnableSec();
		waitCycles(0x6fffff);	
		lcdFillWindow(10, 26, 246, 310, BACKGROUND_COLOUR);
		waitCycles(0x6fffff);	
	}	


}
Пример #2
0
void
gpio::setPullUpDown( uint8_t pin, PullMode mode ) {

	// Get the GPIO controller registers
	volatile uint32_t	&reg_pullupdown	= *( m_gpio + GPPUD0 ),
						&reg_clock		= *( m_gpio + GPPUDCLK0 + ( pin / 32 ) );

	// Enable/disable pull-up/down control on the GPIO pin
	// 00 = Disable pull-up/down
	// 01 = Enable pull-down control
	// 10 = Enable pull-up control
	// 11 = Reserved
	reg_pullupdown = (uint32_t) mode;

	// Set clock con pin
    waitCycles( 150 );
	reg_clock = 1 << ( pin % 32 );
    waitCycles( 150 );

	// Restore the registers
	reg_clock = 0;
	reg_pullupdown = 0;
}
Пример #3
0
void kIrqHandler()
{
	unsigned int tmp;
	int a, x;
	for (a = 1; a <= 4; a++) {
		/*
		 * only one line from 1-4 should be high
		 * at one moment                                
		 */

		for (x = 1; x <= 4; x++) {
			if (x != a) {
				setGpioFunct(pinToGpio[x], GPINPUT);
			}
		}
		setGpioFunct(pinToGpio[a], GPOUTPUT);
		setPin(pinToGpio[a]);

		waitCycles(30);
		/*
		 * for every output line going high, check
		 * which input line goes high; store in kBuffer 
		 */
		for (x = 5; x <= 8; x++) {
			if (getPinLevel(pinToGpio[x]) == 1) {
				kBuffer = (4 * (a - 1)) + (x - 5);
				//      very sorry - it's
				//      probably the best way
				goto exit;
			}
		}
		clearPin(pinToGpio[a]);
	}

 exit:	for (x = 1; x <= 4; x++) {
		setGpioFunct(pinToGpio[x], GPOUTPUT);
		setPin(pinToGpio[x]);
	}

	if(extKIrqHandler!=0) extKIrqHandler();
	return;
}