From bf6269e12b2124412e640d4ee4697357bf6ea821 Mon Sep 17 00:00:00 2001
From: Kaspar Schleiser <kaspar@schleiser.de>
Date: Sat, 28 Oct 2017 17:48:01 +0200
Subject: [PATCH] cpu: stm32: reorganize Makefile.features

---
 cpu/stm32_common/Makefile.features |  7 +++++++
 cpu/stm32f0/Makefile.features      |  5 +++++
 cpu/stm32f1/Makefile.features      |  3 +++
 cpu/stm32f2/Makefile.features      |  3 +++
 cpu/stm32f3/Makefile.features      |  1 +
 cpu/stm32f4/Makefile.features      | 13 +++++++++++++
 cpu/stm32f7/Makefile.features      |  2 ++
 cpu/stm32l0/Makefile.features      |  5 +++++
 cpu/stm32l1/Makefile.features      |  1 +
 cpu/stm32l4/Makefile.features      |  3 +++
 10 files changed, 43 insertions(+)
 create mode 100644 cpu/stm32_common/Makefile.features
 create mode 100644 cpu/stm32f0/Makefile.features
 create mode 100644 cpu/stm32f3/Makefile.features
 create mode 100644 cpu/stm32f7/Makefile.features
 create mode 100644 cpu/stm32l0/Makefile.features
 create mode 100644 cpu/stm32l1/Makefile.features
 create mode 100644 cpu/stm32l4/Makefile.features

diff --git a/cpu/stm32_common/Makefile.features b/cpu/stm32_common/Makefile.features
new file mode 100644
index 0000000000..a78a126bbb
--- /dev/null
+++ b/cpu/stm32_common/Makefile.features
@@ -0,0 +1,7 @@
+FEATURES_PROVIDED += periph_cpuid
+
+ifneq (,$(filter $(BOARDS_WITHOUT_HWRNG),$(BOARD)))
+  FEATURES_PROVIDED := $(filter-out periph_hwrng,$(FEATURES_PROVIDED))
+endif
+
+-include $(RIOTCPU)/cortexm_common/Makefile.features
diff --git a/cpu/stm32f0/Makefile.features b/cpu/stm32f0/Makefile.features
new file mode 100644
index 0000000000..fb630f4c25
--- /dev/null
+++ b/cpu/stm32f0/Makefile.features
@@ -0,0 +1,5 @@
+ifeq (,$(filter nucleo32-f031,$(BOARD)))
+  FEATURES_PROVIDED += periph_flashpage
+endif
+
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32f1/Makefile.features b/cpu/stm32f1/Makefile.features
index 7a418ea511..651254b37b 100644
--- a/cpu/stm32f1/Makefile.features
+++ b/cpu/stm32f1/Makefile.features
@@ -1 +1,4 @@
+FEATURES_PROVIDED += periph_flashpage
 FEATURES_PROVIDED += periph_pm
+
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32f2/Makefile.features b/cpu/stm32f2/Makefile.features
index 7a418ea511..c6412dd78e 100644
--- a/cpu/stm32f2/Makefile.features
+++ b/cpu/stm32f2/Makefile.features
@@ -1 +1,4 @@
+FEATURES_PROVIDED += periph_hwrng
 FEATURES_PROVIDED += periph_pm
+
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32f3/Makefile.features b/cpu/stm32f3/Makefile.features
new file mode 100644
index 0000000000..8edd0b2772
--- /dev/null
+++ b/cpu/stm32f3/Makefile.features
@@ -0,0 +1 @@
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32f4/Makefile.features b/cpu/stm32f4/Makefile.features
index 7a418ea511..a7a5abd1a3 100644
--- a/cpu/stm32f4/Makefile.features
+++ b/cpu/stm32f4/Makefile.features
@@ -1 +1,14 @@
+FEATURES_PROVIDED += periph_hwrng
 FEATURES_PROVIDED += periph_pm
+
+# the granularity of provided feature definition for STMs is currently by CPU
+# sub-family (e.g., stm32f[1234]).  Unfortunately, only some of e.g., the
+# stm32f4 have an RNG peripheral.  As during evaluation of the features , no
+# CPU variable is available, we need to filter by board.
+#
+BOARDS_WITHOUT_HWRNG += nucleo-f401
+BOARDS_WITHOUT_HWRNG += nucleo-f411
+BOARDS_WITHOUT_HWRNG += nucleo-f446
+BOARDS_WITHOUT_HWRNG += nucleo144-f446
+
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32f7/Makefile.features b/cpu/stm32f7/Makefile.features
new file mode 100644
index 0000000000..2d4e44ccb5
--- /dev/null
+++ b/cpu/stm32f7/Makefile.features
@@ -0,0 +1,2 @@
+FEATURES_PROVIDED += periph_hwrng
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32l0/Makefile.features b/cpu/stm32l0/Makefile.features
new file mode 100644
index 0000000000..494f8c194a
--- /dev/null
+++ b/cpu/stm32l0/Makefile.features
@@ -0,0 +1,5 @@
+FEATURES_PROVIDED += periph_hwrng
+
+BOARDS_WITHOUT_HWRNG += nucleo32-l031
+
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32l1/Makefile.features b/cpu/stm32l1/Makefile.features
new file mode 100644
index 0000000000..8edd0b2772
--- /dev/null
+++ b/cpu/stm32l1/Makefile.features
@@ -0,0 +1 @@
+-include $(RIOTCPU)/stm32_common/Makefile.features
diff --git a/cpu/stm32l4/Makefile.features b/cpu/stm32l4/Makefile.features
new file mode 100644
index 0000000000..c51e0186eb
--- /dev/null
+++ b/cpu/stm32l4/Makefile.features
@@ -0,0 +1,3 @@
+FEATURES_PROVIDED += periph_hwrng
+
+-include $(RIOTCPU)/stm32_common/Makefile.features
-- 
GitLab