@@ -1101,7 +1101,7 @@ def timer_variant():
1101
1101
return dict (tone = tone , servo = servo )
1102
1102
1103
1103
1104
- def print_variant ():
1104
+ def print_variant (generic_def ):
1105
1105
variant_h_template = j2_env .get_template (variant_h_filename )
1106
1106
variant_cpp_template = j2_env .get_template (variant_cpp_filename )
1107
1107
@@ -1184,15 +1184,10 @@ def print_variant():
1184
1184
if sd_list :
1185
1185
hal_modules_list .append ("HAL_SD_MODULE_ENABLED" )
1186
1186
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
-
1193
1187
variant_h_file .write (
1194
1188
variant_h_template .render (
1195
1189
year = datetime .datetime .now ().year ,
1190
+ generic_def = generic_def ,
1196
1191
pins_number_list = pins_number_list ,
1197
1192
alt_pins_list = alt_pins_list ,
1198
1193
waltpin = max (waltpin ),
@@ -1211,9 +1206,9 @@ def print_variant():
1211
1206
variant_cpp_file .write (
1212
1207
variant_cpp_template .render (
1213
1208
year = datetime .datetime .now ().year ,
1209
+ generic_def = generic_def ,
1214
1210
pinnames_list = pinnames_list ,
1215
1211
analog_pins_list = analog_pins_list ,
1216
- mcu_serie = mcu_serie ,
1217
1212
)
1218
1213
)
1219
1214
@@ -1533,10 +1528,12 @@ def manage_repo():
1533
1528
1534
1529
# main
1535
1530
cur_dir = Path .cwd ()
1531
+ root_dir = cur_dir .parents [1 ]
1532
+ system_path = root_dir / "system"
1536
1533
templates_dir = cur_dir / "templates"
1537
1534
periph_c_filename = "PeripheralPins.c"
1538
1535
pinvar_h_filename = "PinNamesVar.h"
1539
- config_filename = Path ("config .json" )
1536
+ config_filename = Path ("variant_config .json" )
1540
1537
variant_h_filename = "variant.h"
1541
1538
variant_cpp_filename = "variant.cpp"
1542
1539
repo_local_path = cur_dir / "repo"
@@ -1572,18 +1569,16 @@ def manage_repo():
1572
1569
epilog = textwrap .dedent (
1573
1570
"""\
1574
1571
After files generation, review them carefully and please report any issue to GitHub:
1575
- \t https://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
+ \t https://github.com/stm32duino/Arduino_Core_STM32/issues
1573
+ """
1579
1574
),
1580
1575
formatter_class = RawTextHelpFormatter ,
1581
1576
)
1582
1577
group = parser .add_mutually_exclusive_group ()
1583
1578
group .add_argument (
1584
1579
"-l" ,
1585
1580
"--list" ,
1586
- help = "list available xml files description in STM32CubeMX " ,
1581
+ help = "list available xml files description in database " ,
1587
1582
action = "store_true" ,
1588
1583
)
1589
1584
group .add_argument (
@@ -1593,7 +1588,7 @@ def manage_repo():
1593
1588
help = textwrap .dedent (
1594
1589
"""\
1595
1590
Generate {}, {}, {} and {}
1596
- for specified mcu xml file description in STM32CubeMX .
1591
+ for specified mcu xml file description in database .
1597
1592
This xml file can contain non alpha characters in its name,
1598
1593
you should call it with double quotes""" .format (
1599
1594
periph_c_filename ,
@@ -1688,7 +1683,7 @@ def manage_repo():
1688
1683
mcu_dir = "STM32MP1xx"
1689
1684
else :
1690
1685
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
1692
1687
periph_c_filepath = out_path / periph_c_filename
1693
1688
pinvar_h_filepath = out_path / pinvar_h_filename
1694
1689
variant_cpp_filepath = out_path / variant_cpp_filename
@@ -1721,9 +1716,20 @@ def manage_repo():
1721
1716
parse_pins ()
1722
1717
sort_my_lists ()
1723
1718
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
+
1724
1730
print_peripheral ()
1725
1731
print_pinamevar ()
1726
- print_variant ()
1732
+ print_variant (generic_def )
1727
1733
1728
1734
print (
1729
1735
"* Total I/O pins found: {}" .format (
0 commit comments