@@ -1337,6 +1337,16 @@ def print_boards_entry():
13371337 return generic_list
13381338
13391339
1340+ def print_general_clock (generic_list ):
1341+ generic_clock_template = j2_env .get_template (generic_clock_filename )
1342+ generic_clock_file .write (
1343+ generic_clock_template .render (
1344+ year = datetime .datetime .now ().year ,
1345+ generic_list = generic_list ,
1346+ )
1347+ )
1348+
1349+
13401350# List management
13411351tokenize = re .compile (r"(\d+)|(\D+)" ).findall
13421352
@@ -1665,6 +1675,7 @@ def manage_repo():
16651675variant_h_filename = "variant.h"
16661676variant_cpp_filename = "variant.cpp"
16671677boards_entry_filename = "boards_entry.txt"
1678+ generic_clock_filename = "generic_clock.c"
16681679repo_local_path = cur_dir / "repo"
16691680cubemxdir = ""
16701681gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
@@ -1678,7 +1689,13 @@ def manage_repo():
16781689parser = argparse .ArgumentParser (
16791690 description = textwrap .dedent (
16801691 """\
1681- By default, generate {}, {}, {}, {} and {}
1692+ By default, generates:
1693+ - {},
1694+ - {},
1695+ - {},
1696+ - {},
1697+ - {}
1698+ - {}
16821699for all xml files description available in STM32CubeMX internal database.
16831700Internal database path must be defined in {}.
16841701It can be the one from STM32CubeMX directory if defined:
@@ -1692,6 +1709,7 @@ def manage_repo():
16921709 variant_cpp_filename ,
16931710 variant_h_filename ,
16941711 boards_entry_filename ,
1712+ generic_clock_filename ,
16951713 config_filename ,
16961714 cubemxdir ,
16971715 gh_url ,
@@ -1718,15 +1736,10 @@ def manage_repo():
17181736 metavar = "xml" ,
17191737 help = textwrap .dedent (
17201738 """\
1721- Generate {}, {}, {} and {}
1722- for specified mcu xml file description in database.
1739+ Generate all files for specified mcu xml file description in database.
17231740This xml file can contain non alpha characters in its name,
1724- you should call it with double quotes""" .format (
1725- periph_c_filename ,
1726- pinvar_h_filename ,
1727- variant_cpp_filename ,
1728- variant_h_filename ,
1729- )
1741+ you should call it with double quotes.
1742+ """
17301743 ),
17311744)
17321745
@@ -1844,6 +1857,7 @@ def manage_repo():
18441857 variant_cpp_filepath = out_temp_path / variant_cpp_filename
18451858 variant_h_filepath = out_temp_path / variant_h_filename
18461859 boards_entry_filepath = out_temp_path / boards_entry_filename
1860+ generic_clock_filepath = out_temp_path / generic_clock_filename
18471861 out_temp_path .mkdir (parents = True , exist_ok = True )
18481862
18491863 # open output file
@@ -1852,12 +1866,13 @@ def manage_repo():
18521866 variant_cpp_file = open (variant_cpp_filepath , "w" , newline = "\n " )
18531867 variant_h_file = open (variant_h_filepath , "w" , newline = "\n " )
18541868 boards_entry_file = open (boards_entry_filepath , "w" , newline = "\n " )
1855-
1869+ generic_clock_file = open ( generic_clock_filepath , "w" , newline = " \n " )
18561870 parse_pins ()
18571871 sort_my_lists ()
18581872 manage_alternate ()
18591873
18601874 generic_list = print_boards_entry ()
1875+ print_general_clock (generic_list )
18611876 print_peripheral ()
18621877 print_pinamevar ()
18631878 print_variant (generic_list )
@@ -1884,6 +1899,7 @@ def manage_repo():
18841899 variant_h_file .close ()
18851900 variant_cpp_file .close ()
18861901 boards_entry_file .close ()
1902+ generic_clock_file .close ()
18871903 xml_mcu .unlink ()
18881904 xml_gpio .unlink ()
18891905
@@ -2014,7 +2030,7 @@ def manage_repo():
20142030 new_line_c += " || {}" .format (pre )
20152031 new_line_h += " && !{}" .format (pre )
20162032 update_file (mcu_dir / variant_cpp_filename , update_regex , new_line_c )
2017-
2033+ update_file ( mcu_dir / generic_clock_filename , update_regex , new_line_c )
20182034 update_file (mcu_dir / variant_h_filename , update_regex , new_line_h )
20192035
20202036 # Appending to board_entry file
@@ -2029,8 +2045,12 @@ def manage_repo():
20292045
20302046 # Move to variants/ folder
20312047 out_path = out_family_path / mcu_dir .stem
2048+ generic_clock_filepath = out_path / generic_clock_filename
20322049 out_path .mkdir (parents = True , exist_ok = True )
20332050 for fname in mcu_dir .glob ("*.*" ):
2034- fname .replace (out_path / fname .name )
2051+ if fname .name == generic_clock_filename and generic_clock_filepath .exists ():
2052+ fname .unlink ()
2053+ else :
2054+ fname .replace (out_path / fname .name )
20352055# Clean temporary dir
20362056rm_tree (tmp_dir )
0 commit comments