Skip to main content
Senior
Dec 8, 2022 8:23 PM UTC
Solved

Two questions about HAL_GPIO_EXTI_IRQHandler

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.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Dec 8, 2022 10:08 PM UTC

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.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

4 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Dec 8, 2022 10:08 PM UTC

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.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
dhsAuthor
Senior
Jan 2, 2023 8:48 PM UTC

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

Daniel H Sagarra
TDK
Dec 9, 2022 6:18 PM UTC

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."
S.Ma
Principal
Dec 10, 2022 4:03 AM UTC

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