Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: STM32L452_Nucleo_ticker
Fork of mbed-dev by
Diff: targets/TARGET_STM/gpio_irq_api.c
- Revision:
- 170:19eb464bc2be
- Parent:
- 160:d5399cc887bb
diff -r e3b6fe271b81 -r 19eb464bc2be targets/TARGET_STM/gpio_irq_api.c
--- a/targets/TARGET_STM/gpio_irq_api.c Wed Jul 19 17:31:21 2017 +0100
+++ b/targets/TARGET_STM/gpio_irq_api.c Thu Aug 03 13:13:39 2017 +0100
@@ -90,8 +90,9 @@
if (__HAL_GPIO_EXTI_GET_FLAG(pin) != RESET) {
__HAL_GPIO_EXTI_CLEAR_FLAG(pin);
- if (gpio_channel->channel_ids[gpio_idx] == 0)
+ if (gpio_channel->channel_ids[gpio_idx] == 0) {
continue;
+ }
// Check which edge has generated the irq
if ((gpio->IDR & pin) == 0) {
@@ -99,9 +100,11 @@
} else {
irq_handler(gpio_channel->channel_ids[gpio_idx], IRQ_RISE);
}
+ return;
}
}
}
+ error("Unexpected Spurious interrupt, index %d\r\n", irq_index);
}
@@ -254,18 +257,23 @@
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
{
+ /* Enable / Disable Edge triggered interrupt and store event */
if (event == IRQ_RISE) {
if (enable) {
LL_EXTI_EnableRisingTrig_0_31(1 << STM_PIN(obj->pin));
+ obj->event |= IRQ_RISE;
} else {
LL_EXTI_DisableRisingTrig_0_31(1 << STM_PIN(obj->pin));
+ obj->event &= ~IRQ_RISE;
}
}
if (event == IRQ_FALL) {
if (enable) {
LL_EXTI_EnableFallingTrig_0_31(1 << STM_PIN(obj->pin));
+ obj->event |= IRQ_FALL;
} else {
LL_EXTI_DisableFallingTrig_0_31(1 << STM_PIN(obj->pin));
+ obj->event &= ~IRQ_FALL;
}
}
}
@@ -284,14 +292,23 @@
LL_EXTI_EnableIT_0_31(1 << pin_index);
+ /* Restore previous edge interrupt configuration if applicable */
+ if (obj->event & IRQ_RISE) {
+ LL_EXTI_EnableRisingTrig_0_31(1 << STM_PIN(obj->pin));
+ }
+ if (obj->event & IRQ_FALL) {
+ LL_EXTI_EnableFallingTrig_0_31(1 << STM_PIN(obj->pin));
+ }
+
NVIC_EnableIRQ(obj->irq_n);
}
void gpio_irq_disable(gpio_irq_t *obj)
{
/* Clear EXTI line configuration */
+ LL_EXTI_DisableRisingTrig_0_31(1 << STM_PIN(obj->pin));
+ LL_EXTI_DisableFallingTrig_0_31(1 << STM_PIN(obj->pin));
LL_EXTI_DisableIT_0_31(1 << STM_PIN(obj->pin));
NVIC_DisableIRQ(obj->irq_n);
NVIC_ClearPendingIRQ(obj->irq_n);
- obj->event = EDGE_NONE;
}
