From 64e2e66a5239541b15f43172655cfb3560bec79b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 2 Jun 2012 16:54:42 -0700 Subject: [PATCH] altos: Fix broken EXTI edge mode selections. Clear pending exti on enable Make sure the edge mode registers are set according to the requested mode. Clear any pending interrupt when enabling to avoid spurious isr call Signed-off-by: Keith Packard --- src/stm/ao_exti_stm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/stm/ao_exti_stm.c b/src/stm/ao_exti_stm.c index 2108e8b5..0fa24188 100644 --- a/src/stm/ao_exti_stm.c +++ b/src/stm/ao_exti_stm.c @@ -75,11 +75,14 @@ ao_exti_setup (struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback /* Set interrupt mask and rising/falling mode */ stm_exti.imr &= ~mask; - stm_exti.rtsr |= mask; if (mode & AO_EXTI_MODE_RISING) stm_exti.rtsr |= mask; + else + stm_exti.rtsr &= ~mask; if (mode & AO_EXTI_MODE_FALLING) stm_exti.ftsr |= mask; + else + stm_exti.ftsr &= ~mask; if (pin <= 4) irq = STM_ISR_EXTI0_POS + pin; @@ -93,12 +96,16 @@ ao_exti_setup (struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback void ao_exti_enable(struct stm_gpio *gpio, uint8_t pin) { + uint32_t mask = (1 << pin); + stm_exti.pr = mask; stm_exti.imr |= (1 << pin); } void ao_exti_disable(struct stm_gpio *gpio, uint8_t pin) { - stm_exti.imr &= ~(1 << pin); + uint32_t mask = (1 << pin); + stm_exti.imr &= ~mask; + stm_exti.pr = mask; } void -- 2.30.2