Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 41 additions & 37 deletions CI/update/stm32wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,17 @@
)
all_ll_header_file_template = j2_env.get_template(all_ll_h_file)
ll_h_file_template = j2_env.get_template(ll_h_file)
util_h_file_template = j2_env.get_template("stm32yyxx_util_ppp.h")
utils_h_file_template = j2_env.get_template("stm32yyxx_utils_ppp.h")
c_file_template = j2_env.get_template(c_file)
dsp_file_template = Template('#include "../Source/{{ dsp_dir }}/{{ dsp_name }}"\n\n')
stm32_def_build_template = j2_env.get_template(stm32_def_build_file)
startup_stm32yyxx_template = j2_env.get_template(startup_stm32yyxx_file)
system_stm32_template = j2_env.get_template(system_stm32_file)

# re
feat_c_regex = re.compile(r"stm32[^_]+_(.*).c$")
feat_c_regex = re.compile(r"stm32[^_]*_(.*).c$")
feat_h_regex = re.compile(r"stm32[^_]+_(.*).h$")
feat_util_h_regex = re.compile(r"stm32[^_]+_util_(.*).h$")
feat_utils_h_regex = re.compile(r"stm32_utils_(.*).h$")
feat_utils_h_regex = re.compile(r"stm32[^_]*_utils?_(.*).h$")


def checkConfig(arg_core, arg_cmsis):
Expand Down Expand Up @@ -225,7 +224,7 @@ def wrap(arg_core, arg_cmsis, log):
ll_h_dict = {}
ll_c_dict = {}
hal_c_dict = {}
util_h_dict = {}
utils_h_dict = {}

# Search all files for each series
for series in stm32_series:
Expand All @@ -238,9 +237,10 @@ def wrap(arg_core, arg_cmsis, log):
print(f"Generating for {series}...")
lower = series.lower()

# Search stm32yyxx_[hal|ll]*.c file
filelist = src.glob(f"**/stm32{lower}{nx}_*.c")
# Search stm32yyxx_[hal|ll|utils?]*.c or stm32_utils?_*.c file
filelist = src.glob("**/stm32*.c")
for fp in filelist:
is_series_in_fn = fp.name.startswith(f"stm32{lower}{nx}_")
legacy = fp.parent.name == "Legacy"
# File name
fn = fp.name
Expand All @@ -258,26 +258,37 @@ def wrap(arg_core, arg_cmsis, log):
current_list = ll_c_dict.pop(feat)
if current_list[-1][0] == lower:
current_list.pop()
current_list.append((lower, legacy, stm32_dict[series]))
current_list.append(
(lower, legacy, stm32_dict[series], is_series_in_fn)
)
ll_c_dict[feat] = current_list
else:
ll_c_dict[feat].append((lower, legacy, stm32_dict[series]))
ll_c_dict[feat].append(
(lower, legacy, stm32_dict[series], is_series_in_fn)
)
else:
ll_c_dict[feat] = [(lower, legacy, stm32_dict[series])]
ll_c_dict[feat] = [
(lower, legacy, stm32_dict[series], is_series_in_fn)
]
else:
if feat in hal_c_dict:
if legacy:
# Change legacy value if exists
current_list = hal_c_dict.pop(feat)
if current_list[-1][0] == lower:
current_list.pop()
current_list.append((lower, legacy, stm32_dict[series]))
current_list.append(
(lower, legacy, stm32_dict[series], is_series_in_fn)
)
hal_c_dict[feat] = current_list
else:
hal_c_dict[feat].append((lower, legacy, stm32_dict[series]))
hal_c_dict[feat].append(
(lower, legacy, stm32_dict[series], is_series_in_fn)
)
else:
hal_c_dict[feat] = [(lower, legacy, stm32_dict[series])]

hal_c_dict[feat] = [
(lower, legacy, stm32_dict[series], is_series_in_fn)
]
# Search stm32yyxx_ll_*.h file
filelist = inc.glob(f"stm32{lower}{nx}_ll_*.h")
for fp in filelist:
Expand All @@ -294,33 +305,26 @@ def wrap(arg_core, arg_cmsis, log):
else:
ll_h_dict[feature] = [(lower, stm32_dict[series])]
# Search stm32yyxx_util_.*.h file
filelist = inc.glob(f"stm32{lower}{nx}_util_*.h")
for fp in filelist:
# File name
fn = fp.name
found = feat_util_h_regex.match(fn)
if not found:
continue
feature = found.group(1)
# Add to util_h_dict to generate a header file for it
if feature in util_h_dict:
util_h_dict[feature].append((lower, stm32_dict[series], False))
else:
util_h_dict[feature] = [(lower, stm32_dict[series], False)]
# Search stm32yyxx_util_.*.h file
filelist = inc.glob(f"stm32_utils_*.h")
filelist = list(inc.glob("stm32*_util_*.h"))
filelist += list(inc.glob("stm32*_utils_*.h"))
for fp in filelist:
# File name
fn = fp.name
found = feat_utils_h_regex.match(fn)
is_series_in_fn = fp.name.startswith(f"stm32{lower}{nx}_")
if not found:
continue
feature = found.group(1)
# Add to util_h_dict to generate a header file for it
if feature in util_h_dict:
util_h_dict[feature].append((lower, stm32_dict[series], True))
utils = "_utils_" in fn
# Add to utils_h_dict to generate a header file for it
if feature in utils_h_dict:
utils_h_dict[feature].append(
(lower, stm32_dict[series], is_series_in_fn, utils)
)
else:
util_h_dict[feature] = [(lower, stm32_dict[series], True)]
utils_h_dict[feature] = [
(lower, stm32_dict[series], is_series_in_fn, utils)
]

# Generate stm32yyxx_hal_*.c file
for key, value in hal_c_dict.items():
Expand All @@ -343,11 +347,11 @@ def wrap(arg_core, arg_cmsis, log):
out_file.write(ll_h_file_template.render(feat=key, serieslist=value))
if log:
print("done")
# Generate stm32yyxx_util_*.h file
for key, value in util_h_dict.items():
filepath = SrcWrapper_path / "inc" / f"stm32yyxx_util_{key}.h"
# Generate stm32yyxx_utils_*.h file
for key, value in utils_h_dict.items():
filepath = SrcWrapper_path / "inc" / f"stm32yyxx_utils_{key}.h"
with open(filepath, "w", newline="\n") as out_file:
out_file.write(util_h_file_template.render(feat=key, serieslist=value))
out_file.write(utils_h_file_template.render(feat=key, serieslist=value))
# Filter all LL header file
all_ll_h_list = sorted(set(all_ll_h_list))
# Generate the all LL header file
Expand Down
6 changes: 5 additions & 1 deletion CI/update/templates/stm32yyxx_feat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

{% for series, legacy, nx in serieslist %}
{% for series, legacy, nx, is_series_in_fn in serieslist %}
{% if loop.first %}
#ifdef STM32{{series.upper()}}{{nx}}
{% else %}
Expand All @@ -11,7 +11,11 @@
{% if legacy %}
#include "Legacy/stm32{{series}}{{nx}}_{{feat}}.c"
{% endif %}
{% if is_series_in_fn %}
#include "stm32{{series}}{{nx}}_{{feat}}.c"
{% else %}
#include "stm32_{{feat}}.c"
{% endif %}
{% if loop.last %}
#endif
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _STM32YYXX_UTIL_{{feat.upper()}}_H_
#define _STM32YYXX_UTIL_{{feat.upper()}}_H_
#ifndef _STM32YYXX_UTILS_{{feat.upper()}}_H_
#define _STM32YYXX_UTILS_{{feat.upper()}}_H_
/* LL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
Expand All @@ -8,21 +8,21 @@
#pragma GCC diagnostic ignored "-Wregister"
#endif

{% for series, nx, halv2 in serieslist %}
{% for series, nx, is_series_in_fn, utils in serieslist %}
{% if loop.first %}
#ifdef STM32{{series.upper()}}{{nx}}
{% else %}
#elif STM32{{series.upper()}}{{nx}}
{% endif %}
{% if halv2 %}
#include "stm32_utils_{{feat}}.h"
{% if is_series_in_fn %}
#include "stm32{{series}}{{nx}}_{{'utils' if utils else 'util'}}_{{feat}}.h"
{% else %}
#include "stm32{{series}}{{nx}}_util_{{feat}}.h"
#include "stm32_{{'utils' if utils else 'util'}}_{{feat}}.h"
{% endif %}
{% if loop.last %}
#endif
{% endif %}
{% endfor %}
#pragma GCC diagnostic pop
#endif /* _STM32YYXX_UTIL_{{feat.upper()}}_H_ */
#endif /* _STM32YYXX_UTILS_{{feat.upper()}}_H_ */

2 changes: 1 addition & 1 deletion libraries/I3C/src/I3C.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#if defined(USE_HALV2_DRIVER)
#warning "I3C library is not yet compatible with HALv2 driver."
#else
#include "stm32yyxx_util_i3c.h"
#include "stm32yyxx_utils_i3c.h"

// ============================================================================
// Descriptors, configuration structures, and enums
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _STM32YYXX_UTIL_FDCAN_H_
#define _STM32YYXX_UTIL_FDCAN_H_
#ifndef _STM32YYXX_UTILS_FDCAN_H_
#define _STM32YYXX_UTILS_FDCAN_H_
/* LL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
Expand All @@ -12,4 +12,4 @@
#include "stm32_utils_fdcan.h"
#endif
#pragma GCC diagnostic pop
#endif /* _STM32YYXX_UTIL_FDCAN_H_ */
#endif /* _STM32YYXX_UTILS_FDCAN_H_ */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _STM32YYXX_UTIL_I2C_H_
#define _STM32YYXX_UTIL_I2C_H_
#ifndef _STM32YYXX_UTILS_I2C_H_
#define _STM32YYXX_UTILS_I2C_H_
/* LL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
Expand All @@ -12,4 +12,4 @@
#include "stm32_utils_i2c.h"
#endif
#pragma GCC diagnostic pop
#endif /* _STM32YYXX_UTIL_I2C_H_ */
#endif /* _STM32YYXX_UTILS_I2C_H_ */
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _STM32YYXX_UTIL_I3C_H_
#define _STM32YYXX_UTIL_I3C_H_
#ifndef _STM32YYXX_UTILS_I3C_H_
#define _STM32YYXX_UTILS_I3C_H_
/* LL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
Expand All @@ -16,4 +16,4 @@
#include "stm32u3xx_util_i3c.h"
#endif
#pragma GCC diagnostic pop
#endif /* _STM32YYXX_UTIL_I3C_H_ */
#endif /* _STM32YYXX_UTILS_I3C_H_ */
8 changes: 8 additions & 0 deletions libraries/SrcWrapper/src/HAL/stm32yyxx_utils_fdcan.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* HAL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

#ifdef STM32C5xx
#include "stm32_utils_fdcan.c"
#endif
#pragma GCC diagnostic pop
8 changes: 8 additions & 0 deletions libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* HAL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

#ifdef STM32C5xx
#include "stm32_utils_i2c.c"
#endif
#pragma GCC diagnostic pop
8 changes: 8 additions & 0 deletions libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i3c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* HAL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

#ifdef STM32C5xx
#include "stm32_utils_i3c.c"
#endif
#pragma GCC diagnostic pop
Loading