Skip to content

Commit d77faa4

Browse files
committed
cpu/stm32: simplify handling of generated IRQ header
- rename `irqs/<CPU_FAM>/irqs.h` to `irqs/<CPU_FAM>/stm32_irqs.h` to reduce chance of a name conflict (`irqs.h` might not be unique) - add `irqs/<CPU_FAM>` to the include paths - add the `#include "stm32{f0,f1,f2,f3,f4,f7,l0,...}xx.h"` to the generated `stm32_irqs.h` ==> Now we can just go for `#include "stm32_irqs.h` and drop a lot of preprocessor conditionals
1 parent 2bd24b6 commit d77faa4

File tree

3 files changed

+8
-53
lines changed

3 files changed

+8
-53
lines changed

cpu/stm32/Makefile.include

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ ifeq (,$(filter STM32MP157Cxx STM32F030x4,$(CPU_LINE)))
113113
# package so they are hardcoded in RIOTs codebase.
114114
# For other lines, the IRQs are automatically generated once from the whole
115115
# list of CMSIS headers available in a given family
116-
STM32IRQS_INCLUDE_FILE = $(RIOTCPU)/stm32/include/irqs/$(CPU_FAM)/irqs.h
116+
STM32IRQS_INCLUDE_FILE = $(RIOTCPU)/stm32/include/irqs/$(CPU_FAM)/stm32_irqs.h
117117
BUILDDEPS += $(STM32IRQS_INCLUDE_FILE)
118+
INCLUDES += -I$(RIOTCPU)/stm32/include/irqs/$(CPU_FAM)
118119
endif
119120

120121
# The IRQ header for a given family requires the family headers to be fetched

cpu/stm32/dist/irqs/gen_irqs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"RIOTBASE", os.path.abspath(os.path.join(CURRENT_DIR, "../../../..")))
1919
STM32_INCLUDE_DIR = os.path.join(RIOTBASE, "cpu/stm32/include")
2020
STM32_IRQS_DIR = os.path.join(
21-
RIOTBASE, STM32_INCLUDE_DIR, "irqs/{}/irqs.h")
21+
RIOTBASE, STM32_INCLUDE_DIR, "irqs/{}/stm32_irqs.h")
2222

2323
IRQS_FORMAT = """
2424
/*
@@ -31,6 +31,8 @@
3131
#ifndef IRQS_{cpu_fam}_H
3232
#define IRQS_{cpu_fam}_H
3333
34+
#include "{cpu_fam_include}"
35+
3436
#ifdef __cplusplus
3537
extern "C" {{
3638
#endif
@@ -122,6 +124,7 @@ def generate_irqs(context):
122124
irqs_content = IRQS_FORMAT.format(
123125
cpu_fam=context["cpu_fam"].upper(),
124126
irq_lines="\n".join(irq_lines),
127+
cpu_fam_include="stm32{}xx.h".format(context["cpu_fam"])
125128
)
126129
dest_file = os.path.join(STM32_IRQS_DIR.format(context["cpu_fam"]))
127130

cpu/stm32/include/cpu_conf.h

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,8 @@
2424
#include "vendor/stm32f030x4.h"
2525
#elif defined(CPU_LINE_STM32MP157Cxx)
2626
#include "vendor/stm32mp157cxx_cm4.h"
27-
#elif CPU_FAM_STM32F0
28-
#include "stm32f0xx.h"
29-
#include "irqs/f0/irqs.h"
30-
#elif CPU_FAM_STM32F1
31-
#include "stm32f1xx.h"
32-
#include "irqs/f1/irqs.h"
33-
#elif CPU_FAM_STM32F2
34-
#include "stm32f2xx.h"
35-
#include "irqs/f2/irqs.h"
36-
#elif CPU_FAM_STM32F3
37-
#include "stm32f3xx.h"
38-
#include "irqs/f3/irqs.h"
39-
#elif CPU_FAM_STM32F4
40-
#include "stm32f4xx.h"
41-
#include "irqs/f4/irqs.h"
42-
#elif CPU_FAM_STM32F7
43-
#include "stm32f7xx.h"
44-
#include "irqs/f7/irqs.h"
45-
#elif CPU_FAM_STM32G0
46-
#include "stm32g0xx.h"
47-
#include "irqs/g0/irqs.h"
48-
#elif CPU_FAM_STM32C0
49-
#include "stm32c0xx.h"
50-
#include "irqs/c0/irqs.h"
51-
#elif CPU_FAM_STM32G4
52-
#include "stm32g4xx.h"
53-
#include "irqs/g4/irqs.h"
54-
#elif CPU_FAM_STM32L0
55-
#include "stm32l0xx.h"
56-
#include "irqs/l0/irqs.h"
57-
#elif CPU_FAM_STM32L1
58-
#include "stm32l1xx.h"
59-
#include "irqs/l1/irqs.h"
60-
#elif CPU_FAM_STM32L4
61-
#include "stm32l4xx.h"
62-
#include "irqs/l4/irqs.h"
63-
#elif CPU_FAM_STM32L5
64-
#include "stm32l5xx.h"
65-
#include "irqs/l5/irqs.h"
66-
#elif CPU_FAM_STM32U5
67-
#include "stm32u5xx.h"
68-
#include "irqs/u5/irqs.h"
69-
#define NUM_HEAPS 3
70-
#elif CPU_FAM_STM32WB
71-
#include "stm32wbxx.h"
72-
#include "irqs/wb/irqs.h"
73-
#elif CPU_FAM_STM32WL
74-
#include "stm32wlxx.h"
75-
#include "irqs/wl/irqs.h"
7627
#else
77-
#error Not supported CPU family
28+
#include "stm32_irqs.h"
7829
#endif
7930

8031
/* add unused backup RAM as extra heap */
@@ -101,7 +52,7 @@ extern "C" {
10152
* @{
10253
*/
10354
#define CPU_DEFAULT_IRQ_PRIO (1U)
104-
/* STM32MP1 family has no flah */
55+
/* STM32MP1 family has no flash */
10556
#if !defined(CPU_FAM_STM32MP1)
10657
#define CPU_FLASH_BASE FLASH_BASE
10758
#endif

0 commit comments

Comments
 (0)