diff --git a/targets/TARGET_STM/gpio_irq_api.c b/targets/TARGET_STM/gpio_irq_api.c index e44373dc0d..0d5167c565 100644 --- a/targets/TARGET_STM/gpio_irq_api.c +++ b/targets/TARGET_STM/gpio_irq_api.c @@ -53,6 +53,7 @@ typedef struct gpio_channel { } gpio_channel_t; static gpio_irq_handler irq_handler; +static uint16_t irq_channel_used = 0x00; static gpio_channel_t channels[CHANNEL_NUM] = { #ifdef EXTI_IRQ0_NUM_LINES @@ -331,6 +332,14 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32 uint32_t pin_index = STM_PIN(pin); irq_index = pin_lines_desc[pin_index].irq_index; + if (irq_channel_used & (1<channel_gpio[gpio_idx] = 0; gpio_channel->channel_pin[gpio_idx] = 0; + irq_channel_used &= ~(1<<(STM_PIN(obj->pin))); + core_util_critical_section_exit(); }