49
49
#include " stm32_def.h"
50
50
#include " interrupt.h"
51
51
52
- #ifdef __cplusplus
53
- extern "C" {
54
- #endif
55
52
/* *
56
53
* @}
57
54
*/
62
59
63
60
/* As we can have only one interrupt/pin id, don't need to get the port info*/
64
61
typedef struct {
65
- uint32_t irqnb ;
66
- void ( * callback )( void );
62
+ IRQn_Type irqnb;
63
+ std::function< void ( void )> callback ;
67
64
uint32_t mode;
68
65
}gpio_irq_conf_str;
69
66
@@ -156,16 +153,7 @@ uint8_t get_pin_id(uint16_t pin)
156
153
157
154
return id;
158
155
}
159
- /**
160
- * @brief This function enable the interruption on the selected port/pin
161
- * @param port : one of the gpio port
162
- * @param pin : one of the gpio pin
163
- **@param callback : callback to call when the interrupt falls
164
- * @param mode : one of the supported interrupt mode defined in stm32_hal_gpio
165
- * @retval None
166
- */
167
- void stm32_interrupt_enable (GPIO_TypeDef * port , uint16_t pin , void (* callback )(void ), uint32_t mode )
168
- {
156
+ void stm32_interrupt_enable (GPIO_TypeDef *port, uint16_t pin, callback_function_t callback, uint32_t mode){
169
157
GPIO_InitTypeDef GPIO_InitStruct;
170
158
uint8_t id = get_pin_id (pin);
171
159
@@ -227,6 +215,21 @@ void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, void (*callback)(v
227
215
HAL_NVIC_EnableIRQ (gpio_irq_conf[id].irqnb );
228
216
}
229
217
218
+ /* *
219
+ * @brief This function enable the interruption on the selected port/pin
220
+ * @param port : one of the gpio port
221
+ * @param pin : one of the gpio pin
222
+ **@param callback : callback to call when the interrupt falls
223
+ * @param mode : one of the supported interrupt mode defined in stm32_hal_gpio
224
+ * @retval None
225
+ */
226
+ void stm32_interrupt_enable (GPIO_TypeDef *port, uint16_t pin, void (*callback)(void ), uint32_t mode)
227
+ {
228
+ std::function<void (void )> _c = callback;
229
+ stm32_interrupt_enable (port,pin,_c,mode);
230
+
231
+ }
232
+
230
233
/* *
231
234
* @brief This function disable the interruption on the selected port/pin
232
235
* @param port : one of the gpio port
@@ -263,6 +266,10 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
263
266
}
264
267
265
268
#if defined (STM32F0xx) || defined (STM32L0xx)
269
+ #ifdef __cplusplus
270
+ extern " C" {
271
+ #endif
272
+
266
273
/* *
267
274
* @brief This function handles external line 0 to 1 interrupt request.
268
275
* @param None
@@ -302,7 +309,13 @@ void EXTI4_15_IRQHandler(void)
302
309
HAL_GPIO_EXTI_IRQHandler (pin);
303
310
}
304
311
}
312
+ #ifdef __cplusplus
313
+ }
314
+ #endif
305
315
#else
316
+ #ifdef __cplusplus
317
+ extern " C" {
318
+ #endif
306
319
/* *
307
320
* @brief This function handles external line 0 interrupt request.
308
321
* @param None
@@ -379,6 +392,10 @@ void EXTI15_10_IRQHandler(void)
379
392
HAL_GPIO_EXTI_IRQHandler (pin);
380
393
}
381
394
}
395
+
396
+ #ifdef __cplusplus
397
+ }
398
+ #endif
382
399
#endif
383
400
/* *
384
401
* @}
@@ -391,8 +408,4 @@ void EXTI15_10_IRQHandler(void)
391
408
/* *
392
409
* @}
393
410
*/
394
- #ifdef __cplusplus
395
- }
396
- #endif
397
-
398
411
/* *********************** (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments