Skip to main content
Explorer II
December 8, 2022
Solved

Two questions about HAL_GPIO_EXTI_IRQHandler

  • December 8, 2022
  • 3 replies
  • 2701 views

1- Using cubre-mx I enabled two IRQ lines, each generate its own ISR

void EXTI0_IRQHandler(void)

{

HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);

}

and

void EXTI15_10_IRQHandler(void)

{

HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);

}

Why HAL joint together both IRQ handlers in one function, isn't better to use two separate functions ?

2 - Later why use the name callback, this name should be reserved for functions used as parameter on functions?

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    Presumably the latter one is supposed to be calling with GPIO_PIN10 thru 15

    HAL is a monster, it is going to qualify the source, call your callback, and clear the source.

    They have one gate keeper function.

    If you want efficiency do your work in the IRQHandler directly.

    3 replies

    Graduate II
    December 8, 2022

    Presumably the latter one is supposed to be calling with GPIO_PIN10 thru 15

    HAL is a monster, it is going to qualify the source, call your callback, and clear the source.

    They have one gate keeper function.

    If you want efficiency do your work in the IRQHandler directly.

    dhsAuthor
    Explorer II
    January 2, 2023

    By default, do you start a new project using HAL or avoid it from the very bebining ?

    Super User
    December 9, 2022

    EXTI0_IRQHandler and EXTI15_10_IRQHandler are tied to interrupts in the core. No way to merge those.

    > isn't better to use two separate functions ?

    Hard to make sweeping generalizations like that. The most common practice is that a single function is better as it reduces code duplication.

    > Later why use the name callback

    It needs to know which pin to check EXTI flags for.

    Visitor II
    December 10, 2022

    Well HAL code didn't understand the reason to have split EXTI interrupt vectors in the chip, simply said....