cancel
Showing results for 
Search instead for 
Did you mean: 

How to initialize STM32WB Interrupt manually without using CUBEMX ?

Deepak.Aagri
Associate III

Hello ST,

I am using BLE_MeshLightingProvisioner Project, PB 12 and PB 14 used for external interrupt purpose.

Please find the following modification

=============main.c================

static void MX_GPIO_Init(void)

{

 GPIO_InitTypeDef GPIO_InitStruct = {0};

 /* GPIO Ports Clock Enable */

   // __HAL_RCC_GPIOC_CLK_ENABLE();

  __HAL_RCC_GPIOB_CLK_ENABLE();

 // __HAL_RCC_GPIOA_CLK_ENABLE();

 /*Configure GPIO pins : Key_Pin Door_Pin */

 GPIO_InitStruct.Pin = Key_Pin|Door_Pin;

 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;

 GPIO_InitStruct.Pull = GPIO_PULLUP;//GPIO_NOPULL;

 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 /* EXTI interrupt init*/

 HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0x0F, 0);

 HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);

}

====================================================

=============stm32wbxx_it.c===========================

void EXTI15_10_IRQHandler(void)

{

 /* USER CODE BEGIN EXTI9_5_IRQn 0 */

 /* USER CODE END EXTI9_5_IRQn 0 */

 HAL_GPIO_EXTI_IRQHandler(Key_Pin);

 HAL_GPIO_EXTI_IRQHandler(Door_Pin);

 /* USER CODE BEGIN EXTI9_5_IRQn 1 */

 /* USER CODE END EXTI9_5_IRQn 1 */

}

#ifdef SAVE_MODEL_STATE_POWER_FAILURE_DETECTION    //Not Enable

/**

 * @brief This function handles External line

 *     interrupt request.

 * @param None

 * @retval None

 */

void POWEROFF_EXTI_IRQHandler(void)

{

 HAL_GPIO_EXTI_IRQHandler(POWEROFF_PIN);

}

#endif

=========================================================

===========stm32wbxx_it.h==================================

//void POWEROFF_EXTI_IRQHandler(void); //comment due to EXTI15_10_IRQHandler

void EXTI15_10_IRQHandler(void);

===========================================================

=======================build setting ==========================

0693W00000JOi6MQAT.png 

=======================app_entry.c=========================

void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )

{

 switch (GPIO_Pin)

 {

#ifdef SAVE_MODEL_STATE_POWER_FAILURE_DETECTION

  case POWEROFF_PIN:

   {

    PowerOnOff_flag = 1;

   }

   break;

#endif

  case BUTTON_SW1_PIN:

   {

    UTIL_SEQ_SetTask( 1<<CFG_TASK_MESH_SW1_REQ_ID, CFG_SCH_PRIO_0);

   }

   break;

  case BUTTON_SW2_PIN:

   {

    UTIL_SEQ_SetTask( 1<<CFG_TASK_MESH_SW2_REQ_ID, CFG_SCH_PRIO_0);

   }

   break;

  case Key_Pin:

{

UTIL_SEQ_SetTask( 1<<CFG_TASK_MESH_BOLT_KEY_REQ_ID, CFG_SCH_PRIO_0);

}

 break;

#endif

  default:

   break;

 }

 return;

}

/*------------------------------------Issue------------------------------------------------*/

It is responding to below read condition:

if(HAL_GPIO_ReadPin(Door_Port,Door_Pin)== GPIO_PIN_RESET)  {}else{}

but Callback function not responding to associated external interrupt..

Let me know if i missed anything to initialize the GPIO pin interrupt...

Best regards

Deepak Aagri

1 REPLY 1
Remy ISSALYS
ST Employee

Hello,

Initialization and configuration of GPIO and external interrupt seems to be good. GPIO_MODE_IT_RISING_FALLING corresponds to external interrupt mode with rising/falling edge trigger detection, so callback function will be call only when pin state changes.

Best Regards