Skip to content

Commit

Permalink
Fix #145: added interrupt function for C
Browse files Browse the repository at this point in the history
  • Loading branch information
dhineshkumarmcci committed Jan 20, 2021
1 parent f8c1f7d commit a7f99e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cores/arduino/stm32/interrupt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,24 @@ void stm32_interrupt_disable(GPIO_TypeDef *port, uint16_t pin)
HAL_NVIC_DisableIRQ(gpio_irq_conf[id].irqnb);
}

#ifdef __cplusplus
extern "C"
#endif

/**
* @brief This function enable the interruption on the selected port/pin from the C code
* @param port : one of the gpio port
* @param pin : one of the gpio pin
**@param callback : callback to call when the interrupt falls
* @param mode : one of the supported interrupt mode defined in stm32_hal_gpio
* @retval None
*/
void stm32_interrupt_enable_forC(GPIO_TypeDef *port, uint16_t pin, void (*callback)(void), uint32_t mode)
{
std::function<void(void)> _c = callback;
stm32_interrupt_enable(port,pin,_c,mode);
}

/**
* @brief This function his called by the HAL if the IRQ is valid
* @param GPIO_Pin : one of the gpio pin
Expand Down
5 changes: 5 additions & 0 deletions cores/arduino/stm32/interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, callback_function_
void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, void (*callback)(void), uint32_t mode);
void stm32_interrupt_disable(GPIO_TypeDef *port, uint16_t pin);

#ifdef __cplusplus
extern "C"
#endif
void stm32_interrupt_enable_forC(GPIO_TypeDef *port, uint16_t pin, void (*callback)(void), uint32_t mode);

#endif /* __INTERRUPT_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 comments on commit a7f99e1

Please sign in to comment.