GP32 Buttons/joypad Isr?


The Start and Select buttons are connected to ExtInt pins, so you could get interrupts when they are pressed and/or released. The other buttons and the joystick are not connected to interrupt pins, so you have to poll them.

You could write a timer-driven function to read the button states and turn these into 'Pressed' and 'Released' events, if you want to :)
 
does it looks correct?
Code:
__irq static void  timer4_isr( void )
{
	int i;
	int keys=gp_ButtonResult();
	for(i=0; i<10;i++)
  uKeys[i]=((0x1<<i)&keys)? 1: 0;
	//clear bit?
}

void InstallKbdHandler( void )
{
  ClearKeys();
  rCLKCON |= 0x40; //enable pwmtimer
  rTCFG0 = 0xFF00; //8bit prescale = 255 --> 16.1133 KHz for PCLK=66MHz
  rTCFG1 = 0x30000; //4bit divider = 1/16
  
  rTCNTB4 = 322; //~20ms
  rTCON = 0x6 << 20; //auto reload + maunal update
  ARMDisableInterrupt();
  swi_install_irq(BIT_TIMER4,timer4_isr);
  ARMEnableInterrupt();
  rTCON = 0x5 << 20; //start + auto-reload
}
 
Back
Top