@@ -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
15351530cur_dir = Path .cwd ()
1531+ root_dir = cur_dir .parents [1 ]
1532+ system_path = root_dir / "system"
15361533templates_dir = cur_dir / "templates"
15371534periph_c_filename = "PeripheralPins.c"
15381535pinvar_h_filename = "PinNamesVar.h"
1539- config_filename = Path ("config .json" )
1536+ config_filename = Path ("variant_config .json" )
15401537variant_h_filename = "variant.h"
15411538variant_cpp_filename = "variant.cpp"
15421539repo_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- \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+ """
15791574 ),
15801575 formatter_class = RawTextHelpFormatter ,
15811576)
15821577group = parser .add_mutually_exclusive_group ()
15831578group .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)
15891584group .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 .
15971592This xml file can contain non alpha characters in its name,
15981593you 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 (
0 commit comments