diff --git a/CI/update/stm32wrapper.py b/CI/update/stm32wrapper.py index 721857ef8f..c5b4ca4c2d 100644 --- a/CI/update/stm32wrapper.py +++ b/CI/update/stm32wrapper.py @@ -58,7 +58,7 @@ ) 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) @@ -66,10 +66,9 @@ 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): @@ -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: @@ -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 @@ -258,12 +258,18 @@ 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: @@ -271,13 +277,18 @@ def wrap(arg_core, arg_cmsis, log): 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: @@ -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(): @@ -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 diff --git a/CI/update/templates/stm32yyxx_feat.c b/CI/update/templates/stm32yyxx_feat.c index 622460ddce..82778a2f58 100644 --- a/CI/update/templates/stm32yyxx_feat.c +++ b/CI/update/templates/stm32yyxx_feat.c @@ -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 %} @@ -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 %} diff --git a/CI/update/templates/stm32yyxx_util_ppp.h b/CI/update/templates/stm32yyxx_utils_ppp.h similarity index 56% rename from CI/update/templates/stm32yyxx_util_ppp.h rename to CI/update/templates/stm32yyxx_utils_ppp.h index 494f5d59f2..7eb8c096ad 100644 --- a/CI/update/templates/stm32yyxx_util_ppp.h +++ b/CI/update/templates/stm32yyxx_utils_ppp.h @@ -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" @@ -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_ */ diff --git a/libraries/I3C/src/I3C.h b/libraries/I3C/src/I3C.h index 82a8457327..34c2cd8da9 100644 --- a/libraries/I3C/src/I3C.h +++ b/libraries/I3C/src/I3C.h @@ -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 diff --git a/libraries/SrcWrapper/inc/stm32yyxx_util_fdcan.h b/libraries/SrcWrapper/inc/stm32yyxx_utils_fdcan.h similarity index 75% rename from libraries/SrcWrapper/inc/stm32yyxx_util_fdcan.h rename to libraries/SrcWrapper/inc/stm32yyxx_utils_fdcan.h index 6ab89cdcbf..149a9099b9 100644 --- a/libraries/SrcWrapper/inc/stm32yyxx_util_fdcan.h +++ b/libraries/SrcWrapper/inc/stm32yyxx_utils_fdcan.h @@ -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" @@ -12,4 +12,4 @@ #include "stm32_utils_fdcan.h" #endif #pragma GCC diagnostic pop -#endif /* _STM32YYXX_UTIL_FDCAN_H_ */ +#endif /* _STM32YYXX_UTILS_FDCAN_H_ */ diff --git a/libraries/SrcWrapper/inc/stm32yyxx_util_i2c.h b/libraries/SrcWrapper/inc/stm32yyxx_utils_i2c.h similarity index 76% rename from libraries/SrcWrapper/inc/stm32yyxx_util_i2c.h rename to libraries/SrcWrapper/inc/stm32yyxx_utils_i2c.h index 7e15b77114..ff4186d5c5 100644 --- a/libraries/SrcWrapper/inc/stm32yyxx_util_i2c.h +++ b/libraries/SrcWrapper/inc/stm32yyxx_utils_i2c.h @@ -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" @@ -12,4 +12,4 @@ #include "stm32_utils_i2c.h" #endif #pragma GCC diagnostic pop -#endif /* _STM32YYXX_UTIL_I2C_H_ */ +#endif /* _STM32YYXX_UTILS_I2C_H_ */ diff --git a/libraries/SrcWrapper/inc/stm32yyxx_util_i3c.h b/libraries/SrcWrapper/inc/stm32yyxx_utils_i3c.h similarity index 81% rename from libraries/SrcWrapper/inc/stm32yyxx_util_i3c.h rename to libraries/SrcWrapper/inc/stm32yyxx_utils_i3c.h index 83c10c03c0..3041693155 100644 --- a/libraries/SrcWrapper/inc/stm32yyxx_util_i3c.h +++ b/libraries/SrcWrapper/inc/stm32yyxx_utils_i3c.h @@ -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" @@ -16,4 +16,4 @@ #include "stm32u3xx_util_i3c.h" #endif #pragma GCC diagnostic pop -#endif /* _STM32YYXX_UTIL_I3C_H_ */ +#endif /* _STM32YYXX_UTILS_I3C_H_ */ diff --git a/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_fdcan.c b/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_fdcan.c new file mode 100644 index 0000000000..52eb8aaea7 --- /dev/null +++ b/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_fdcan.c @@ -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 diff --git a/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i2c.c b/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i2c.c new file mode 100644 index 0000000000..2ced1d98ee --- /dev/null +++ b/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i2c.c @@ -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 diff --git a/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i3c.c b/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i3c.c new file mode 100644 index 0000000000..afe593aba3 --- /dev/null +++ b/libraries/SrcWrapper/src/HAL/stm32yyxx_utils_i3c.c @@ -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