Skip to content

Commit 055c30f

Browse files
committed
[stm32variant] Update to generate in the core
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 8b09d3a commit 055c30f

File tree

4 files changed

+33
-30
lines changed

4 files changed

+33
-30
lines changed

CI/utils/stm32variant.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ def timer_variant():
11011101
return dict(tone=tone, servo=servo)
11021102

11031103

1104-
def print_variant():
1104+
def print_variant(generic_def):
11051105
variant_h_template = j2_env.get_template(variant_h_filename)
11061106
variant_cpp_template = j2_env.get_template(variant_cpp_filename)
11071107

@@ -1184,15 +1184,10 @@ def print_variant():
11841184
if sd_list:
11851185
hal_modules_list.append("HAL_SD_MODULE_ENABLED")
11861186

1187-
mcu_serie = re.match(r"STM32([FGHLW][\dBL]|MP[\d])", mcu_file.stem)
1188-
if not mcu_serie:
1189-
print("No serie match found!")
1190-
exit(1)
1191-
mcu_serie = mcu_serie.group(1).lower()
1192-
11931187
variant_h_file.write(
11941188
variant_h_template.render(
11951189
year=datetime.datetime.now().year,
1190+
generic_def=generic_def,
11961191
pins_number_list=pins_number_list,
11971192
alt_pins_list=alt_pins_list,
11981193
waltpin=max(waltpin),
@@ -1211,9 +1206,9 @@ def print_variant():
12111206
variant_cpp_file.write(
12121207
variant_cpp_template.render(
12131208
year=datetime.datetime.now().year,
1209+
generic_def=generic_def,
12141210
pinnames_list=pinnames_list,
12151211
analog_pins_list=analog_pins_list,
1216-
mcu_serie=mcu_serie,
12171212
)
12181213
)
12191214

@@ -1533,10 +1528,12 @@ def manage_repo():
15331528

15341529
# main
15351530
cur_dir = Path.cwd()
1531+
root_dir = cur_dir.parents[1]
1532+
system_path = root_dir / "system"
15361533
templates_dir = cur_dir / "templates"
15371534
periph_c_filename = "PeripheralPins.c"
15381535
pinvar_h_filename = "PinNamesVar.h"
1539-
config_filename = Path("config.json")
1536+
config_filename = Path("variant_config.json")
15401537
variant_h_filename = "variant.h"
15411538
variant_cpp_filename = "variant.cpp"
15421539
repo_local_path = cur_dir / "repo"
@@ -1572,18 +1569,16 @@ def manage_repo():
15721569
epilog=textwrap.dedent(
15731570
"""\
15741571
After files generation, review them carefully and please report any issue to GitHub:
1575-
\thttps://github.com/stm32duino/Arduino_Tools/issues\n
1576-
Once generated, you can comment a line if the pin should not be used
1577-
(overlaid with some HW on the board, for instance) and update all undefined pins
1578-
in variant."""
1572+
\thttps://github.com/stm32duino/Arduino_Core_STM32/issues
1573+
"""
15791574
),
15801575
formatter_class=RawTextHelpFormatter,
15811576
)
15821577
group = parser.add_mutually_exclusive_group()
15831578
group.add_argument(
15841579
"-l",
15851580
"--list",
1586-
help="list available xml files description in STM32CubeMX",
1581+
help="list available xml files description in database",
15871582
action="store_true",
15881583
)
15891584
group.add_argument(
@@ -1593,7 +1588,7 @@ def manage_repo():
15931588
help=textwrap.dedent(
15941589
"""\
15951590
Generate {}, {}, {} and {}
1596-
for specified mcu xml file description in STM32CubeMX.
1591+
for specified mcu xml file description in database.
15971592
This xml file can contain non alpha characters in its name,
15981593
you should call it with double quotes""".format(
15991594
periph_c_filename,
@@ -1688,7 +1683,7 @@ def manage_repo():
16881683
mcu_dir = "STM32MP1xx"
16891684
else:
16901685
mcu_dir = mcu_file.name[:7] + "xx"
1691-
out_path = cur_dir / "Arduino" / mcu_dir / mcu_file.stem
1686+
out_path = root_dir / "variants" / mcu_dir / mcu_file.stem
16921687
periph_c_filepath = out_path / periph_c_filename
16931688
pinvar_h_filepath = out_path / pinvar_h_filename
16941689
variant_cpp_filepath = out_path / variant_cpp_filename
@@ -1721,9 +1716,20 @@ def manage_repo():
17211716
parse_pins()
17221717
sort_my_lists()
17231718
manage_alternate()
1719+
1720+
# manage ARDUINO_GENERIC_* define name
1721+
# Search if several flash size
1722+
sub = re.search(r"STM32(.*)\((.*)\)(.*)", mcu_file.stem)
1723+
generic_def = []
1724+
if sub:
1725+
for flash in sub.group(2).split("-"):
1726+
generic_def.append((sub.group(1) + flash + sub.group(3)).upper())
1727+
else:
1728+
generic_def = [mcu_file.stem.upper()]
1729+
17241730
print_peripheral()
17251731
print_pinamevar()
1726-
print_variant()
1732+
print_variant(generic_def)
17271733

17281734
print(
17291735
"* Total I/O pins found: {}".format(

CI/utils/templates/PeripheralPins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*******************************************************************************
3-
* Copyright (c) {{year}}, STMicroelectronics
3+
* Copyright (c) 2020-{{year}}, STMicroelectronics
44
* All rights reserved.
55
*
66
* This software component is licensed by ST under BSD 3-Clause license,

CI/utils/templates/variant.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*******************************************************************************
3-
* Copyright (c) {{year}}, STMicroelectronics
3+
* Copyright (c) 2020-{{year}}, STMicroelectronics
44
* All rights reserved.
55
*
66
* This software component is licensed by ST under BSD 3-Clause license,
@@ -10,6 +10,7 @@
1010
*
1111
*******************************************************************************
1212
*/
13+
#if defined(ARDUINO_GENERIC_{{generic_list[0].board}}){% for name in generic_list[1:] %} || defined(ARDUINO_GENERIC_{{name.board}}){% endfor %}
1314

1415
#include "pins_arduino.h"
1516

@@ -39,17 +40,8 @@ const uint32_t analogInputPin[] = {
3940
{% endfor %}
4041
};
4142

42-
/**
43-
* @brief System Clock Configuration
44-
* @param None
45-
* @retval None
46-
*/
47-
WEAK void SystemClock_Config(void)
48-
{
49-
/* SystemClock_Config can be generated by STM32CubeMX */
50-
}
51-
5243
#ifdef __cplusplus
5344
} // extern "C"
5445
#endif
46+
#endif /* ARDUINO_GENERIC_* */
5547

CI/utils/templates/variant.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*******************************************************************************
3-
* Copyright (c) {{year}}, STMicroelectronics
3+
* Copyright (c) 2020-{{year}}, STMicroelectronics
44
* All rights reserved.
55
*
66
* This software component is licensed by ST under BSD 3-Clause license,
@@ -11,6 +11,10 @@
1111
*******************************************************************************
1212
*/
1313

14+
#if !defined(ARDUINO_GENERIC_{{generic_list[0].board}}){% for name in generic_list[1:] %} && !defined(ARDUINO_GENERIC_{{name.board}}){% endfor %}
15+
16+
#include VARIANT_BOARD_H
17+
#else
1418
#ifndef _VARIANT_ARDUINO_STM32_
1519
#define _VARIANT_ARDUINO_STM32_
1620
#ifdef __cplusplus
@@ -144,4 +148,5 @@ extern "C" {
144148
#endif
145149

146150
#endif /* _VARIANT_ARDUINO_STM32_ */
151+
#endif /* !ARDUINO_GENERIC_* */
147152

0 commit comments

Comments
 (0)