Hello !
I've been working on 4 leds in STM32 - school project.
Project was simple : Everytime I click the button, the light switches. For example 1st diode is on the rest are off, when I click the button the 2nd diode is on and the rest are off.
I knew from tutorials how to do it. But I was mixed with Interrupts in STM32. I am also learning how to code in C from basics so this also might be the problem.
The thing is I've set the Button into External interrupt mode.
But I don't understand the functions ....
1)

Don't mind the rest of the code I don't know why it didn't color it in green. Only the code inside the red rectangle is the actual code inside of this function.
I don't know why I had to use HAL_GPIO_EXIT_Callback in main function. Because I didn't know where was this interrupt function and it was in a different file.
2)

(This photo below nr.3, is from a video of how it looked like when I went inside of HAL_GPIO_EXTI_IRQHandler)
3)

When I saw HAL_GPIO_EXTI_IRQHandler I thought I could write a code (red rectangle code) inside of HAL_GPIO_EXTI_IRQHandler like in picture nr.2, but my teacher said to not do it and get inside HAL_GPIO_EXTI_IRQHandler (he showed me how) and copy HAL_GPIO_EXIT_Callback, put it in main function and then write a code inside HAL_GPIO_EXIT_Callback.
Why ? Couldn't I write the code in his original place which was HAL_GPIO_EXIT_Callback? But instead I had to copy it into the main program ?
I am very new to it in C language so maybe that's why but I don't know where to find the source why it works like that. What I found is how to use the function from different files :

So it looks pretty much the same there is only one difference. Here in the example from the picture above getSum has a function not inside of main but only in new file but in HAL_GPIO_EXIT_Callback the function is also in main and in different file HAL_GPIO_EXIT_Callback is empty and not used. Why ? Why do I have to copy HAL_GPIO_EXIT_Callback and not write code in HAL_GPIO_EXTI_IRQHandler ?
Or is it somehow also related to functions callback like here ? (but I only found javascript example and not C) :

But that's wierd can someone help me resolve this confusion ? Because I didn't have time to ask why but I want to know.
I've been working on 4 leds in STM32 - school project.
Project was simple : Everytime I click the button, the light switches. For example 1st diode is on the rest are off, when I click the button the 2nd diode is on and the rest are off.
I knew from tutorials how to do it. But I was mixed with Interrupts in STM32. I am also learning how to code in C from basics so this also might be the problem.
The thing is I've set the Button into External interrupt mode.
But I don't understand the functions ....
1)

Don't mind the rest of the code I don't know why it didn't color it in green. Only the code inside the red rectangle is the actual code inside of this function.
I don't know why I had to use HAL_GPIO_EXIT_Callback in main function. Because I didn't know where was this interrupt function and it was in a different file.
2)

(This photo below nr.3, is from a video of how it looked like when I went inside of HAL_GPIO_EXTI_IRQHandler)
3)

When I saw HAL_GPIO_EXTI_IRQHandler I thought I could write a code (red rectangle code) inside of HAL_GPIO_EXTI_IRQHandler like in picture nr.2, but my teacher said to not do it and get inside HAL_GPIO_EXTI_IRQHandler (he showed me how) and copy HAL_GPIO_EXIT_Callback, put it in main function and then write a code inside HAL_GPIO_EXIT_Callback.
Why ? Couldn't I write the code in his original place which was HAL_GPIO_EXIT_Callback? But instead I had to copy it into the main program ?
I am very new to it in C language so maybe that's why but I don't know where to find the source why it works like that. What I found is how to use the function from different files :

So it looks pretty much the same there is only one difference. Here in the example from the picture above getSum has a function not inside of main but only in new file but in HAL_GPIO_EXIT_Callback the function is also in main and in different file HAL_GPIO_EXIT_Callback is empty and not used. Why ? Why do I have to copy HAL_GPIO_EXIT_Callback and not write code in HAL_GPIO_EXTI_IRQHandler ?
Or is it somehow also related to functions callback like here ? (but I only found javascript example and not C) :

But that's wierd can someone help me resolve this confusion ? Because I didn't have time to ask why but I want to know.
Last edited:












