Community
cancel
Showing results for 
Search instead for 
Did you mean: 
SAliv
Beginner
1,025 Views

Which GPIO pin caused interrupt?

Hello everybody,

I'm playing with D2000 MCU and got an issue that need your help, I'm trying to connect buttons to GPIO pins, when one button is pressed, an interrupt is triggered, but how can I know which pin caused the interrupt?

static void gpio_example_callback(void *data, uint32_t status)

{

// How can I know which pin caused the interrupt here?

}

void main()

{

cfg.int_en = BIT(PIN_1) | BIT(PIN_2) | BIT(PIN_3);

cfg.int_type = BIT(PIN_1) | BIT(PIN_2) | BIT(PIN_3);

...

cfg.callback = gpio_callback;

cfg.callback_data = NULL;

QM_IR_UNMASK_INT(QM_IRQ_GPIO_0_INT);

QM_IRQ_REQUEST(QM_IRQ_GPIO_0_INT, qm_gpio_0_isr);

qm_gpio_set_config(QM_GPIO_0, &cfg);

...

}

Thank you very much.

0 Kudos
4 Replies
CK_Intel
Moderator
96 Views

Hello,

Thank you for reaching out to Intel® Quark™ Microcontrollers Forum.

We will look into this issue and get back to you shortly.

Regards

Intel Customer Support

SAliv
Beginner
96 Views

Thank you ctan94x_intel, do you have any clue?

CK_Intel
Moderator
96 Views

Hi,

I will update you once i heard the feedback from my engineering team.

Regards

CK

Intel Customer Support

AZimi
New Contributor II
96 Views

Hi!

In the simplest way you can read a pin state in the interrupt routine:

qm_gpio_read_pin(QM_GPIO_0, PINID);

Also your interrupt callback function has an argument:

uint32_t status

Try to read this variable in the callback function for check the required triggered pin

Reply