2020-04-14 03:17 AM
Hi!
I'm currently using a Nucleo-L432KC board to move a servo. There's a pin connected to the Servo (PA_8), a pin for a button interrupt (PA_4) and a pin for a LED indicator (PA_6).
The issue arises when I call the following function:
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
timer = 0;
HAL_TIM_Base_Start_IT(&htim2);
__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_1,2);
}
I call it through this line:
HAL_GPIO_EXTI_Callback(GPIO_PIN_4);
Whenever I call the function I get the following error (during build):
../Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_gpio.h:88:36: error: expected declaration specifiers or '...' before '(' token
#define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */
^
../Src/main.c:384:26: note: in expansion of macro 'GPIO_PIN_4'
HAL_GPIO_EXTI_Callback(GPIO_PIN_4);
^~~~~~~~~~
I have tried adding & and * in the parameters and arguments but It increases the amount of errors.
Any help would be highly appreciated!!
Edit: I'm using STM32CubeIDE
2020-04-14 06:02 AM
Hello,
It would be simple to add your callback code to the IRQ Handler.
(default HAL code in stm32l4xx_hal_gpio.c):
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
{
/* EXTI line interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != 0x00u)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
HAL_GPIO_EXTI_Callback(GPIO_Pin);
}
}
I recommend to follow the examples in the STM32CubeL4 firmware package and review the structure of the available projects: STM32Cube_FW_L4_V1.15.0\Projects\NUCLEO-L432KC\Examples\
Best Regards,
Imen
2020-04-14 08:07 AM
>>I have tried adding & and * in the parameters and arguments but It increases the amount of errors.
Probably because that wasn't what the compiler was complaining about in the first instance.
Have the compiler generate pre-processor output so you can see what it is actually trying to compile.
Search sources for other defines, or macro expansions which could be occurring here. Use find-in-files, or grep
Try with better tools.
2024-07-14 09:37 PM
The
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin == GPIO_PIN_4)
{
//You're Funciton
}
}
Not sure if you ever figured out your error. I had a similar error and I think I figured it out, and wanted to update this post. This post popped up at the top of my google search, and I hate not updating posts if I find an answer.
When declaring the function you are not supposed to insert your own GPIO_PIN_4 into the function of Callback. Instead when called by the handler the argument is passed. You then check this value inside the function to determine if that pin is responsible for the IT.