cancel
Showing results for 
Search instead for 
Did you mean: 

Hello, I have a STM32L073 Nucleo board and SX1261 Lora Radio Board. I am using STM Cube LoRaWAN package to develop a Class A End Node. I want to use GPIO External Interrupt, Any suggestions how to implement?

BSada.1
Associate

msp.c has a callback definition

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  HW_GPIO_IrqHandler(GPIO_Pin);
}

it.c has the following

void EXTI4_15_IRQHandler(void)
{
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_11);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_12);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_15);
}

this is my implementation

void HW_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = { 0 };
  __HAL_RCC_GPIOC_CLK_ENABLE();
  GPIO_InitStruct.Pin = GPIO_PIN_12;
    GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    HAL_GPIO_Init (GPIOC, &GPIO_InitStruct);
    HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);
     HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
}

I want to toggle an led whenever there is an interrupt, where can i implement this call back

2 REPLIES 2
TDK
Guru

This is typically done in HAL_GPIO_EXTI_Callback.

If you feel a post has answered your question, please click "Accept as Solution".
ty.locke
Associate II

You can also use HW_GPIO_SetIrq() from hw_gpio.c. This allows you to pass the int priority as a parameter and calls HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ().