aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/stm32/exti.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/stm32/exti.c b/lib/stm32/exti.c
index cdc2347..de037e7 100644
--- a/lib/stm32/exti.c
+++ b/lib/stm32/exti.c
@@ -129,12 +129,17 @@ void exti_select_source(u32 exti, u32 gpioport)
}
/* Ensure that only valid EXTI lines are used. */
- if (exti < EXTI4)
- AFIO_EXTICR1 &= ~(bits << shift);
- else if (exti < EXTI8)
- AFIO_EXTICR2 &= ~(bits << shift);
- else if (exti < EXTI12)
- AFIO_EXTICR3 &= ~(bits << shift);
- else if (exti < EXTI16)
- AFIO_EXTICR4 &= ~(bits << shift);
+ if (exti < EXTI4) {
+ AFIO_EXTICR1 &= ~(0x000F << shift);
+ AFIO_EXTICR1 |= (~bits << shift);
+ } else if (exti < EXTI8) {
+ AFIO_EXTICR2 &= ~(0x000F << shift);
+ AFIO_EXTICR2 |= (~bits << shift);
+ } else if (exti < EXTI12) {
+ AFIO_EXTICR3 &= ~(0x000F << shift);
+ AFIO_EXTICR3 |= (~bits << shift);
+ } else if (exti < EXTI16) {
+ AFIO_EXTICR4 &= ~(0x000F << shift);
+ AFIO_EXTICR4 |= (~bits << shift);
+ }
}