2017-01-03 05:11 PM
Does HAL library has any function that can check for the interrupt status on any given EXT line? For example,
I have configured:
HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);Now when an interrupt occurs, is there a HAL function to check whether EXTI0 or EXTI1 had caused the interrupt?
Thanks.
Solved! Go to Solution.
2017-01-03 07:00 PM
If you are using the Interrupt callback function defined in the HAL reference manual, it passes the interrupt pin number to you in your callback function. You just need to compare the passed parameter to determine the source of the interrupt.
2017-01-03 07:00 PM
If you are using the Interrupt callback function defined in the HAL reference manual, it passes the interrupt pin number to you in your callback function. You just need to compare the passed parameter to determine the source of the interrupt.
2017-01-04 08:40 AM
OK, I see.
Here is the sequence I think should do what I want:
void EXTI0_1_IRQHandler(void)
{ HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);}void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
{ /* EXTI line interrupt detected */ if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET) { __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin); HAL_GPIO_EXTI_Callback(GPIO_Pin); }}The user then implements the call back function:
HAL_GPIO_EXTI_Callback(GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_0) { ....}
if (GPIO_Pin == GPIO_PIN_1) { ....}
}
2017-01-04 09:09 AM
HAL provides a callback that you can use:
This routine is called when the HAL interrupt handler is called (the code you are looking at in the *_it.c file). If you write your own routine like this:
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
if(GPIO_Pin == GPIO_PIN_0){
do stuff;
}
else if (GPIO_Pin == GPIO_PIN_1){
do other stuff;
}
it will do what you want. This is in the GPIO section of the HAL reference manual. I took the one from the F0 family but they are pretty much all the same.
You do not need to touch the interrupt code in the *_it.c file. It will do what you want.