@@ -1393,6 +1393,16 @@ def print_boards_entry():
13931393 return generic_list
13941394
13951395
1396+ def print_general_clock (generic_list ):
1397+ generic_clock_template = j2_env .get_template (generic_clock_filename )
1398+ generic_clock_file .write (
1399+ generic_clock_template .render (
1400+ year = datetime .datetime .now ().year ,
1401+ generic_list = generic_list ,
1402+ )
1403+ )
1404+
1405+
13961406# List management
13971407tokenize = re .compile (r"(\d+)|(\D+)" ).findall
13981408
@@ -1721,6 +1731,7 @@ def manage_repo():
17211731variant_h_filename = "variant.h"
17221732variant_cpp_filename = "variant.cpp"
17231733boards_entry_filename = "boards_entry.txt"
1734+ generic_clock_filename = "generic_clock.c"
17241735repo_local_path = cur_dir / "repo"
17251736cubemxdir = ""
17261737gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
@@ -1734,7 +1745,13 @@ def manage_repo():
17341745parser = argparse .ArgumentParser (
17351746 description = textwrap .dedent (
17361747 """\
1737- By default, generate {}, {}, {}, {} and {}
1748+ By default, generates:
1749+ - {},
1750+ - {},
1751+ - {},
1752+ - {},
1753+ - {}
1754+ - {}
17381755for all xml files description available in STM32CubeMX internal database.
17391756Internal database path must be defined in {}.
17401757It can be the one from STM32CubeMX directory if defined:
@@ -1748,6 +1765,7 @@ def manage_repo():
17481765 variant_cpp_filename ,
17491766 variant_h_filename ,
17501767 boards_entry_filename ,
1768+ generic_clock_filename ,
17511769 config_filename ,
17521770 cubemxdir ,
17531771 gh_url ,
@@ -1774,15 +1792,10 @@ def manage_repo():
17741792 metavar = "xml" ,
17751793 help = textwrap .dedent (
17761794 """\
1777- Generate {}, {}, {} and {}
1778- for specified mcu xml file description in database.
1795+ Generate all files for specified mcu xml file description in database.
17791796This xml file can contain non alpha characters in its name,
1780- you should call it with double quotes""" .format (
1781- periph_c_filename ,
1782- pinvar_h_filename ,
1783- variant_cpp_filename ,
1784- variant_h_filename ,
1785- )
1797+ you should call it with double quotes.
1798+ """
17861799 ),
17871800)
17881801
@@ -1902,6 +1915,7 @@ def manage_repo():
19021915 variant_cpp_filepath = out_temp_path / variant_cpp_filename
19031916 variant_h_filepath = out_temp_path / variant_h_filename
19041917 boards_entry_filepath = out_temp_path / boards_entry_filename
1918+ generic_clock_filepath = out_temp_path / generic_clock_filename
19051919 out_temp_path .mkdir (parents = True , exist_ok = True )
19061920
19071921 # open output file
@@ -1910,12 +1924,13 @@ def manage_repo():
19101924 variant_cpp_file = open (variant_cpp_filepath , "w" , newline = "\n " )
19111925 variant_h_file = open (variant_h_filepath , "w" , newline = "\n " )
19121926 boards_entry_file = open (boards_entry_filepath , "w" , newline = "\n " )
1913-
1927+ generic_clock_file = open ( generic_clock_filepath , "w" , newline = " \n " )
19141928 parse_pins ()
19151929 sort_my_lists ()
19161930 manage_alternate ()
19171931
19181932 generic_list = print_boards_entry ()
1933+ print_general_clock (generic_list )
19191934 print_peripheral ()
19201935 print_pinamevar ()
19211936 print_variant (generic_list )
@@ -1942,6 +1957,7 @@ def manage_repo():
19421957 variant_h_file .close ()
19431958 variant_cpp_file .close ()
19441959 boards_entry_file .close ()
1960+ generic_clock_file .close ()
19451961 xml_mcu .unlink ()
19461962 xml_gpio .unlink ()
19471963
@@ -2089,7 +2105,7 @@ def manage_repo():
20892105 new_line_c += " || {}" .format (pre )
20902106 new_line_h += " && !{}" .format (pre )
20912107 update_file (mcu_dir / variant_cpp_filename , update_regex , new_line_c )
2092-
2108+ update_file ( mcu_dir / generic_clock_filename , update_regex , new_line_c )
20932109 update_file (mcu_dir / variant_h_filename , update_regex , new_line_h )
20942110
20952111 # Appending to board_entry file
@@ -2104,8 +2120,12 @@ def manage_repo():
21042120
21052121 # Move to variants/ folder
21062122 out_path = out_family_path / mcu_dir .stem
2123+ generic_clock_filepath = out_path / generic_clock_filename
21072124 out_path .mkdir (parents = True , exist_ok = True )
21082125 for fname in mcu_dir .glob ("*.*" ):
2109- fname .replace (out_path / fname .name )
2126+ if fname .name == generic_clock_filename and generic_clock_filepath .exists ():
2127+ fname .unlink ()
2128+ else :
2129+ fname .replace (out_path / fname .name )
21102130# Clean temporary dir
21112131rm_tree (tmp_dir )
0 commit comments