From 245b9238e92383540301d399db0196384e83aede Mon Sep 17 00:00:00 2001 From: Steins7 Date: Sat, 13 May 2023 15:42:59 +0200 Subject: [PATCH] Finish exti's implementation --- drivers/exti.c | 13 ++++++++----- drivers/exti.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/exti.c b/drivers/exti.c index 3556864..4f518e1 100644 --- a/drivers/exti.c +++ b/drivers/exti.c @@ -11,6 +11,7 @@ #include "exti_regs.h" #include "nvic.h" +#include "afio.h" //--local definitions----------------------------------------------------------- @@ -28,7 +29,7 @@ void exti_configure(enum ExtiLine line_mask, enum GpioPort port, { exti_reset(line_mask); -#warning "configure ports mapping" + afio_map_exti(line_mask, port); //configure edge detections if (config_mask & EXTI_CONFIG_RISING_EDGE) { @@ -83,15 +84,17 @@ void exti_reset(enum ExtiLine line_mask) //disable interrupts lines in nvic for (uint8_t i = 0; i < 5; ++i) { if (line_mask & (0x1 << i)) { - nvic_enable(NVIC_IRQ_EXTI0 + i); + nvic_disable(NVIC_IRQ_EXTI0 + i); } } if (line_mask & 0x3e0) { - nvic_enable(NVIC_IRQ_EXTI9_5); + nvic_disable(NVIC_IRQ_EXTI9_5); } if (line_mask & 0x7c00) { - nvic_enable(NVIC_IRQ_EXTI15_10); + nvic_disable(NVIC_IRQ_EXTI15_10); } + + afio_map_exti(0xFFFF, 0x0); } void exti_configure_specific(enum ExtiLineSpecific line_mask, @@ -180,7 +183,7 @@ void exti_reset_peripheral(void) nvic_disable(NVIC_IRQ_RTC_ALARM); nvic_disable(NVIC_IRQ_USB_WAKEUP); -#warning "reset afio lines" + afio_map_exti(0xFFFF, 0x0); } //--local functions------------------------------------------------------------- diff --git a/drivers/exti.h b/drivers/exti.h index f942c20..d2c5089 100644 --- a/drivers/exti.h +++ b/drivers/exti.h @@ -54,8 +54,8 @@ enum ExtiLineSpecific { * regular and specific lines and can be used together on a single line */ enum ExtiConfig { - EXTI_CONFIG_RISING_EDGE, - EXTI_CONFIG_FALLING_EDGE, + EXTI_CONFIG_RISING_EDGE = (0x1 << 0), + EXTI_CONFIG_FALLING_EDGE = (0x1 << 1), }; typedef void (*ExtiCallback)(void);