From 28495bb075d707dee14b7a813dbaf4a1813dc1a3 Mon Sep 17 00:00:00 2001 From: Chun-Chieh Li Date: Wed, 12 Feb 2020 13:48:38 +0800 Subject: [PATCH] M2351: Refine gpio_irq_set(...) with inconsistent GPIO_EnableInt(...) implementations No logic change --- targets/TARGET_NUVOTON/TARGET_M2351/gpio_irq_api.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/gpio_irq_api.c b/targets/TARGET_NUVOTON/TARGET_M2351/gpio_irq_api.c index 5a6e2f8c7a..c49b522635 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/gpio_irq_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M2351/gpio_irq_api.c @@ -182,7 +182,13 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) obj->irq_types &= ~irq_type; } - /* Update irq types */ + /* Update irq types: + * + * Implementations of GPIO_EnableInt(...) are inconsistent: disable or not irq type not enabled. + * For consistency, disable GPIO_INT_BOTH_EDGE and then enable OR'ed irq types, GPIO_INT_RISING, + * GPIO_INT_FALLING, or both. + */ + GPIO_DisableInt(gpio_base, pin_index); GPIO_EnableInt(gpio_base, pin_index, obj->irq_types); }