Beispiel #1
0
/*
 * initialize clock on timer 0.
 */
void Clock_driver_support_initialize_hardware (void)
{
  uint32_t freq =
    1000 / (rtems_configuration_get_microseconds_per_tick () / 1000);

  printk ("[+] clock started\n");
  TIMER_CR (0) = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_64;
  printk ("[#] setting clock to %u hz\n", freq);
  TIMER_DATA (0) = TIMER_FREQ_64 ((uint16_t) freq);
}
void configureTimer() {
	// Initialize timer_ticks
	timer_ticks = 0;

	// Configure timer to trigger an interrupt every 100 ms
    TIMER_CR(0) = TIMER_ENABLE | TIMER_DIV_64 | TIMER_IRQ_REQ;
    TIMER_DATA(0) = TIMER_FREQ_64(10);

	// Associate the ISR (timerISR) to the interrupt line and enable it
    irqSet(IRQ_TIMER0, &timerISR);
    irqEnable(IRQ_TIMER0);
}
Beispiel #3
0
Datei: main.c Projekt: 0xtob/dsmi
void VblankHandler(void)
{
	scanKeys();
	u16 keysdown = keysDown();
	u16 keysup = keysUp();
	u16 keysheld = keysHeld();
	
	touchPosition touch;
	touchRead(&touch);
	
	if(!touch_was_down && keysdown & KEY_TOUCH) {
		touch_was_down = 1;
		
		pm_x0 = touch.px;
		pm_y0 = touch.py;
		
		// Is the pen on the keyboard?
		if(    (touch.px > 8*keyb_xpos) && (touch.py > 8*keyb_ypos)
			&& (touch.px < 8*(keyb_xpos+keyb_width)) && (touch.py < 8*(keyb_ypos+keyb_height)) ) {
			
			// Look up the note in the hit-array
			u8 kbx, kby;
			kbx = touch.px/8 - keyb_xpos;
			kby = touch.py/8 - keyb_ypos;
			
			u8 note = keyb_hit[kby][kbx];
			currnote = note + 12*baseOctave;
			lastnote = note;
			setKeyPal(note);
			
			// Play the note
			play(note);
		}
	} else if(keysup & KEY_TOUCH) {
		touch_was_down = 0;
		resetPals();
		stop(lastnote);
		pitchChange(0);
	} else if(touch_was_down && keysheld & KEY_TOUCH) {
		s16 dx, dy;
		dx = touch.px - pm_x0;
		if(dx<0) dx = 0;
		dy = touch.py - pm_y0;

		pitchChange(-dy);
		pressureChange(dx);
	}
	
	if(keysdown & KEY_X) {
		pitchChange(0);
	}
	
	if(keysdown & KEY_Y) {
		pressureChange(0);
	}
	
	if(keysdown & KEY_RIGHT)
	{
		if(baseOctave < 9)
			baseOctave++;
		
		displayOctave(baseOctave);
		iprintf("base octave %u\n", baseOctave);
	}
	
	if(keysdown & KEY_LEFT)
	{
		if(baseOctave > 0)
			baseOctave--;
		
		displayOctave(baseOctave);
		iprintf("base octave %u\n", baseOctave);
	}
	
	if(keysdown & KEY_UP)
	{
		if(channel < 15)
			channel++;
		
		displayChannel(channel);
		iprintf("using midi channel %u\n", channel);
	}
	
	if(keysdown & KEY_DOWN)
	{
		if(channel > 0)
			channel--;
		
		displayChannel(channel);
		iprintf("using midi channel %u\n", channel);
	}
	
	if(keysdown & KEY_B) {
		//TIMER1_DATA = TIMER_FREQ_64(1000);
		//TIMER1_CR = TIMER_ENABLE | TIMER_DIV_64 | TIMER_IRQ_REQ;
		timerStart(1, ClockDivider_64, TIMER_FREQ_64(1000), Smoke);
		row=0;
		tick=0;
	}
	
}