From ace717ee27926d9e018e3762b61a2a4aefa44f7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= <joakim.nohlgard@eistec.se>
Date: Sun, 26 Aug 2018 09:22:50 +0200
Subject: [PATCH] drivers: Add dep on periph_gpio_irq in drivers using GPIO IRQ

---
 drivers/Makefile.dep          | 36 ++++++++++++++++++++++++++---------
 drivers/include/periph/gpio.h |  3 +++
 drivers/lis3dh/lis3dh.c       |  1 -
 tests/buttons/Makefile        |  1 +
 tests/driver_lis3dh/Makefile  |  1 +
 tests/periph_gpio/Makefile    |  1 +
 6 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep
index 556c471d22..a499944fa1 100644
--- a/drivers/Makefile.dep
+++ b/drivers/Makefile.dep
@@ -1,13 +1,13 @@
 # driver dependencies (in alphabetical order)
 
 ifneq (,$(filter adc%1c,$(USEMODULE)))
-  FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_i2c
   USEMODULE += adcxx1c
 endif
 
 ifneq (,$(filter ads101%,$(USEMODULE)))
-  FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_i2c
   USEMODULE += ads101x
   USEMODULE += xtimer
@@ -45,6 +45,7 @@ ifneq (,$(filter at86rf2%,$(USEMODULE)))
   USEMODULE += ieee802154
   USEMODULE += netdev_ieee802154
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
 endif
 
@@ -52,6 +53,7 @@ ifneq (,$(filter ata8520e,$(USEMODULE)))
   USEMODULE += xtimer
   USEMODULE += fmt
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
 endif
 
@@ -82,6 +84,8 @@ ifneq (,$(filter cc110x,$(USEMODULE)))
   ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
     USEMODULE += gnrc_cc110x
   endif
+  FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
 endif
 
@@ -92,6 +96,7 @@ ifneq (,$(filter cc2420,$(USEMODULE)))
   USEMODULE += ieee802154
   USEMODULE += netdev_ieee802154
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
 endif
 
@@ -116,6 +121,7 @@ endif
 
 ifneq (,$(filter enc28j60,$(USEMODULE)))
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
   USEMODULE += netdev_eth
   USEMODULE += xtimer
@@ -123,7 +129,7 @@ ifneq (,$(filter enc28j60,$(USEMODULE)))
 endif
 
 ifneq (,$(filter encx24j600,$(USEMODULE)))
-  FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
   USEMODULE += netdev_eth
   USEMODULE += xtimer
@@ -160,11 +166,6 @@ ifneq (,$(filter hdc1000,$(USEMODULE)))
   FEATURES_REQUIRED += periph_i2c
 endif
 
-ifneq (,$(filter pulse_counter,$(USEMODULE)))
-  USEMODULE += xtimer
-  FEATURES_REQUIRED += periph_gpio
-endif
-
 ifneq (,$(filter hih6130,$(USEMODULE)))
   USEMODULE += xtimer
   FEATURES_REQUIRED += periph_i2c
@@ -190,6 +191,7 @@ ifneq (,$(filter isl29020,$(USEMODULE)))
 endif
 
 ifneq (,$(filter isl29125,$(USEMODULE)))
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_i2c
 endif
 
@@ -205,6 +207,7 @@ ifneq (,$(filter kw2xrf,$(USEMODULE)))
   USEMODULE += core_thread_flags
   FEATURES_REQUIRED += periph_spi
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
 endif
 
 ifneq (,$(filter l3g4200d,$(USEMODULE)))
@@ -213,7 +216,7 @@ endif
 
 ifneq (,$(filter lc709203f,$(USEMODULE)))
   FEATURES_REQUIRED += periph_i2c
-  FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
 endif
 
 ifneq (,$(filter lis2dh12%,$(USEMODULE)))
@@ -281,6 +284,7 @@ ifneq (,$(filter mrf24j40,$(USEMODULE)))
   USEMODULE += ieee802154
   USEMODULE += netdev_ieee802154
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
 endif
 
@@ -307,6 +311,7 @@ endif
 
 ifneq (,$(filter nrf24l01p,$(USEMODULE)))
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
   USEMODULE += xtimer
 endif
@@ -325,7 +330,18 @@ endif
 
 ifneq (,$(filter pir,$(USEMODULE)))
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
+  USEMODULE += xtimer
+endif
+
+ifneq (,$(filter pn532,$(USEMODULE)))
+  FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
+endif
+
+ifneq (,$(filter pulse_counter,$(USEMODULE)))
   USEMODULE += xtimer
+  FEATURES_REQUIRED += periph_gpio_irq
 endif
 
 ifneq (,$(filter rgbled,$(USEMODULE)))
@@ -395,6 +411,7 @@ endif
 
 ifneq (,$(filter sx127%,$(USEMODULE)))
   FEATURES_REQUIRED += periph_gpio
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
   USEMODULE += iolist
   USEMODULE += xtimer
@@ -423,6 +440,7 @@ ifneq (,$(filter veml6070,$(USEMODULE)))
 endif
 
 ifneq (,$(filter w5100,$(USEMODULE)))
+  FEATURES_REQUIRED += periph_gpio_irq
   FEATURES_REQUIRED += periph_spi
   USEMODULE += netdev_eth
   USEMODULE += luid
diff --git a/drivers/include/periph/gpio.h b/drivers/include/periph/gpio.h
index 46c03ebc8f..253daa58c6 100644
--- a/drivers/include/periph/gpio.h
+++ b/drivers/include/periph/gpio.h
@@ -148,6 +148,7 @@ typedef struct {
  */
 int gpio_init(gpio_t pin, gpio_mode_t mode);
 
+#ifdef MODULE_PERIPH_GPIO_IRQ
 /**
  * @brief   Initialize a GPIO pin for external interrupt usage
  *
@@ -168,6 +169,8 @@ int gpio_init(gpio_t pin, gpio_mode_t mode);
 int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
                   gpio_cb_t cb, void *arg);
 
+#endif /* MODULE_PERIPH_GPIO_IRQ */
+
 /**
  * @brief   Enable pin interrupt if configured as interrupt source
  *
diff --git a/drivers/lis3dh/lis3dh.c b/drivers/lis3dh/lis3dh.c
index d376b4ae84..3a3538322f 100644
--- a/drivers/lis3dh/lis3dh.c
+++ b/drivers/lis3dh/lis3dh.c
@@ -20,7 +20,6 @@
 
 #include <stddef.h>
 #include <stdint.h>
-#include "periph/gpio.h"
 #include "periph/spi.h"
 #include "lis3dh.h"
 
diff --git a/tests/buttons/Makefile b/tests/buttons/Makefile
index d81df6d3c9..60c6acb35b 100644
--- a/tests/buttons/Makefile
+++ b/tests/buttons/Makefile
@@ -1,5 +1,6 @@
 include ../Makefile.tests_common
 
+FEATURES_REQUIRED += periph_gpio_irq
 USEMODULE += xtimer
 
 TEST_ON_CI_WHITELIST += all
diff --git a/tests/driver_lis3dh/Makefile b/tests/driver_lis3dh/Makefile
index d306856b67..9012607615 100644
--- a/tests/driver_lis3dh/Makefile
+++ b/tests/driver_lis3dh/Makefile
@@ -1,5 +1,6 @@
 include ../Makefile.tests_common
 
+FEATURES_REQUIRED += periph_gpio_irq
 USEMODULE += lis3dh
 USEMODULE += xtimer
 
diff --git a/tests/periph_gpio/Makefile b/tests/periph_gpio/Makefile
index 9d84fb1540..0f7a94789c 100644
--- a/tests/periph_gpio/Makefile
+++ b/tests/periph_gpio/Makefile
@@ -1,6 +1,7 @@
 include ../Makefile.tests_common
 
 FEATURES_REQUIRED = periph_gpio
+FEATURES_REQUIRED = periph_gpio_irq
 
 USEMODULE += shell
 USEMODULE += benchmark
-- 
GitLab