From a77c3b367a5579d6ca63e3098d3afd6ce77d7e72 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Sat, 3 Feb 2024 10:08:27 +0100 Subject: [PATCH] arch/nrf{52|53}/gpiote.c: fix event reconfiguration for a given pin if a given pinset is already used, we need to update it, not add another event --- arch/arm/src/nrf52/nrf52_gpiote.c | 12 ++++++++---- arch/arm/src/nrf53/nrf53_gpiote.c | 12 +++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/arm/src/nrf52/nrf52_gpiote.c b/arch/arm/src/nrf52/nrf52_gpiote.c index f2bf33855ab..5aead39e929 100644 --- a/arch/arm/src/nrf52/nrf52_gpiote.c +++ b/arch/arm/src/nrf52/nrf52_gpiote.c @@ -53,8 +53,9 @@ struct nrf52_gpiote_callback_s { - xcpt_t callback; - void *arg; + xcpt_t callback; + void *arg; + uint32_t pinset; }; /**************************************************************************** @@ -462,12 +463,15 @@ int nrf52_gpiote_set_event(uint32_t pinset, flags = enter_critical_section(); - /* Get free channel */ + /* Get free channel or channel already used by pinset */ for (i = 0; i < GPIOTE_CHANNELS; i++) { - if (g_gpiote_ch_callbacks[i].callback == NULL) + if (g_gpiote_ch_callbacks[i].callback == NULL || + g_gpiote_ch_callbacks[i].pinset == pinset) { + g_gpiote_ch_callbacks[i].pinset = pinset; + /* Configure channel */ nrf52_gpiote_set_ch_event(pinset, i, diff --git a/arch/arm/src/nrf53/nrf53_gpiote.c b/arch/arm/src/nrf53/nrf53_gpiote.c index 4b79c7f3f5a..9db5c6cea04 100644 --- a/arch/arm/src/nrf53/nrf53_gpiote.c +++ b/arch/arm/src/nrf53/nrf53_gpiote.c @@ -59,8 +59,9 @@ struct nrf53_gpiote_callback_s { - xcpt_t callback; - void *arg; + xcpt_t callback; + void *arg; + uint32_t pinset; }; /**************************************************************************** @@ -501,13 +502,14 @@ int nrf53_gpiote_set_event(uint32_t pinset, flags = enter_critical_section(); - /* Get free channel */ + /* Get free channel or channel already used by pinset */ for (i = 0; i < GPIOTE_CHANNELS; i++) { - if (g_gpiote_ch_callbacks[i].callback == NULL) + if (g_gpiote_ch_callbacks[i].callback == NULL || + g_gpiote_ch_callbacks[i].pinset == pinset) { - /* Configure channel */ + g_gpiote_ch_callbacks[i].pinset = pinset; nrf53_gpiote_set_ch_event(pinset, i, risingedge, fallingedge,