diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-02 16:54:42 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-02 16:54:42 -0700 |
commit | 64e2e66a5239541b15f43172655cfb3560bec79b (patch) | |
tree | bd671a5f338cb780064e6d3177e2d0416b6de81d /src | |
parent | 8d425ffba84ec6f632e8c0d44105de73242a86a9 (diff) |
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 <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/stm/ao_exti_stm.c | 11 |
1 files 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 |