Skip to content

Commit 7b16f64

Browse files
authored
Merge pull request #2962 from fpistm/utils_wrapper
ci(stm32wrapper): add util header file
2 parents b8ca814 + c59ab20 commit 7b16f64

3 files changed

Lines changed: 64 additions & 1 deletion

File tree

CI/update/stm32wrapper.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
)
5858
all_ll_header_file_template = j2_env.get_template(all_ll_h_file)
5959
ll_h_file_template = j2_env.get_template(ll_h_file)
60+
util_h_file_template = j2_env.get_template("stm32yyxx_util_ppp.h")
6061
c_file_template = j2_env.get_template(c_file)
6162
dsp_file_template = Template('#include "../Source/{{ dsp_dir }}/{{ dsp_name }}"\n\n')
6263
stm32_def_build_template = j2_env.get_template(stm32_def_build_file)
@@ -65,6 +66,7 @@
6566
# re
6667
feat_c_regex = re.compile(r"stm32[^_]+_(.*).c$")
6768
feat_h_regex = re.compile(r"stm32[^_]+_(.*).h$")
69+
feat_util_h_regex = re.compile(r"stm32[^_]+_util_(.*).h$")
6870

6971

7072
def checkConfig(arg_core, arg_cmsis):
@@ -188,6 +190,8 @@ def wrap(arg_core, arg_cmsis, log):
188190
ll_h_dict = {}
189191
ll_c_dict = {}
190192
hal_c_dict = {}
193+
util_h_dict = {}
194+
191195
# Search all files for each series
192196
for series in stm32_series:
193197
nx = stm32_dict[series]
@@ -254,6 +258,20 @@ def wrap(arg_core, arg_cmsis, log):
254258
ll_h_dict[feature].append((lower, stm32_dict[series]))
255259
else:
256260
ll_h_dict[feature] = [(lower, stm32_dict[series])]
261+
# Search stm32yyxx_util_.*.h file
262+
filelist = inc.glob(f"stm32{lower}{nx}_util_*.h")
263+
for fp in filelist:
264+
# File name
265+
fn = fp.name
266+
found = feat_util_h_regex.match(fn)
267+
if not found:
268+
continue
269+
feature = found.group(1)
270+
# Add to util_h_dict to generate a header file for it
271+
if feature in util_h_dict:
272+
util_h_dict[feature].append((lower, stm32_dict[series]))
273+
else:
274+
util_h_dict[feature] = [(lower, stm32_dict[series])]
257275

258276
# Generate stm32yyxx_hal_*.c file
259277
for key, value in hal_c_dict.items():
@@ -276,7 +294,11 @@ def wrap(arg_core, arg_cmsis, log):
276294
out_file.write(ll_h_file_template.render(feat=key, serieslist=value))
277295
if log:
278296
print("done")
279-
297+
# Generate stm32yyxx_util_*.h file
298+
for key, value in util_h_dict.items():
299+
filepath = SrcWrapper_path / "inc" / f"stm32yyxx_util_{key}.h"
300+
with open(filepath, "w", newline="\n") as out_file:
301+
out_file.write(util_h_file_template.render(feat=key, serieslist=value))
280302
# Filter all LL header file
281303
all_ll_h_list = sorted(set(all_ll_h_list))
282304
# Generate the all LL header file
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef _STM32YYXX_UTIL_{{feat.upper()}}_H_
2+
#define _STM32YYXX_UTIL_{{feat.upper()}}_H_
3+
/* LL raised several warnings, ignore them */
4+
#pragma GCC diagnostic push
5+
#pragma GCC diagnostic ignored "-Wunused-parameter"
6+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
7+
#ifdef __cplusplus
8+
#pragma GCC diagnostic ignored "-Wregister"
9+
#endif
10+
11+
{% for series, nx in serieslist %}
12+
{% if loop.first %}
13+
#ifdef STM32{{series.upper()}}{{nx}}
14+
{% else %}
15+
#elif STM32{{series.upper()}}{{nx}}
16+
{% endif %}
17+
#include "stm32{{series}}{{nx}}_util_{{feat}}.h"
18+
{% if loop.last %}
19+
#endif
20+
{% endif %}
21+
{% endfor %}
22+
#pragma GCC diagnostic pop
23+
#endif /* _STM32YYXX_UTIL_{{feat.upper()}}_H_ */
24+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef _STM32YYXX_UTIL_I3C_H_
2+
#define _STM32YYXX_UTIL_I3C_H_
3+
/* LL raised several warnings, ignore them */
4+
#pragma GCC diagnostic push
5+
#pragma GCC diagnostic ignored "-Wunused-parameter"
6+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
7+
#ifdef __cplusplus
8+
#pragma GCC diagnostic ignored "-Wregister"
9+
#endif
10+
11+
#ifdef STM32H5xx
12+
#include "stm32h5xx_util_i3c.h"
13+
#elif STM32U3xx
14+
#include "stm32u3xx_util_i3c.h"
15+
#endif
16+
#pragma GCC diagnostic pop
17+
#endif /* _STM32YYXX_UTIL_I3C_H_ */

0 commit comments

Comments
 (0)