0

I wonder how to make IRQ handler, which can react differently on pushing each button.

I'm thinking to do that in this way:

void EXTI9_5_IRQHandler(){
    if (EXTI_GetITStatus(EXTI_Line_5)){
        doThis();
    } else if (EXTI_GetITStatus(EXTI_Line_6)) {
        doThat();
    }
}

I don't know how to connect multiple buttons to one interrupt, and this is my worst problem :(

Kris_1313
  • 79
  • 9

1 Answers1

0

That is the principle. I am not too familiar with std peripherals, but I am wondering if EXTI_GetFlagStatus would be better in your case. Also don't forget to clear the interrupt flag.

Your code should look like:

void EXTI9_5_IRQHandler(){
    if (EXTI_GetITStatus(EXTI_Line_5)){
        EXTI_ClearFlag(EXTI_Line_5);
        doThis();
    } else if (EXTI_GetITStatus(EXTI_Line_6)) {
        EXTI_ClearFlag(EXTI_Line_6);
        doThat();
    }
}
Guillaume Michel
  • 1,189
  • 8
  • 14