lpcware

How identify the pin interrupted on GPIO Grouped Handler?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Witte on Thu Sep 11 07:57:05 MST 2014
Hey there,

I'm using the GPIO Grouped Handler to watch 2 pins in "Or Mode". But when the interrupt occurs, I don't know which of the two pins set the interrupt. How can I know that?

I'm using a LPC4337 and the GPIO Group 1 Interrupt;

Follow my simple code (Main_CoreM0):


#define TEST_BUTTON_PORT            0
#define TEST_BUTTON_BIT             7
#define TEST_BUTTON_PIN_PORT        2
#define TEST_BUTTON_PIN_BIT         7
#define TEST_BUTTON_MODE_FUNC       SCU_MODE_FUNC0
#define TEST_BUTTON2_PORT            5
#define TEST_BUTTON2_BIT             2
#define TEST_BUTTON2_PIN_PORT        2
#define TEST_BUTTON2_PIN_BIT         2
#define TEST_BUTTON2_MODE_FUNC       SCU_MODE_FUNC4

void GINT1_IRQHandler(void)
{
Chip_GPIOGP_ClearIntStatus(LPC_GPIOGROUP, 1);
Board_LED_Toggle(0);
}

int main()
{
  Chip_SCU_PinMuxSet(TEST_BUTTON_PIN_PORT, TEST_BUTTON_PIN_BIT,
                                     (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | TEST_BUTTON_MODE_FUNC) );
  Chip_SCU_PinMuxSet(TEST_BUTTON2_PIN_PORT, TEST_BUTTON2_PIN_BIT,
                                     (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | TEST_BUTTON2_MODE_FUNC) );

  Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, TEST_BUTTON_PORT, TEST_BUTTON_BIT);
  Chip_GPIOGP_SelectLowLevel(LPC_GPIOGROUP, 1, TEST_BUTTON_PORT, 1 << TEST_BUTTON_BIT);
  Chip_GPIOGP_EnableGroupPins(LPC_GPIOGROUP, 1, TEST_BUTTON_PORT, 1 << TEST_BUTTON_BIT);
 
  Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, TEST_BUTTON2_PORT, TEST_BUTTON2_BIT);
  Chip_GPIOGP_SelectLowLevel(LPC_GPIOGROUP, 1, TEST_BUTTON2_PORT, 1 << TEST_BUTTON2_BIT);
  Chip_GPIOGP_EnableGroupPins(LPC_GPIOGROUP, 1, TEST_BUTTON2_PORT, 1 << TEST_BUTTON2_BIT);
 
  Chip_GPIOGP_SelectOrMode(LPC_GPIOGROUP, 1);
  Chip_GPIOGP_SelectEdgeMode(LPC_GPIOGROUP, 1);

  /* Enable Group GPIO interrupt 0 */
  NVIC_EnableIRQ(GINT1_IRQn);

  while(1)
  {
    __no_operation();
  }
}


Thanks!

Outcomes