4747gpiofile = ""
4848tim_inst_list = [] # TIMx instance
4949usb_inst = {"usb" : "" , "otg_fs" : "" , "otg_hs" : "" }
50+ mcu_family = ""
5051
5152# format
5253# Peripheral
6061# mcu file parsing
6162def parse_IP_file ():
6263 global gpiofile
64+ global mcu_family
6365 tim_regex = r"^(TIM\d+)$"
6466 usb_regex = r"^(USB(?!PD|_HOST|_DEVICE).*)$"
6567 gpiofile = ""
@@ -68,6 +70,9 @@ def parse_IP_file():
6870 usb_inst ["otg_fs" ] = ""
6971 usb_inst ["otg_hs" ] = ""
7072
73+ mcu_node = xml_mcu .getElementsByTagName ("Mcu" )[0 ]
74+ mcu_family = mcu_node .attributes ["Family" ].value
75+
7176 itemlist = xml_mcu .getElementsByTagName ("IP" )
7277 for s in itemlist :
7378 inst = re .match (tim_regex , s .attributes ["InstanceName" ].value )
@@ -1679,10 +1684,16 @@ def manage_repo():
16791684
16801685for mcu_file in mcu_list :
16811686 print ("Generating files for '{}'..." .format (mcu_file .name ))
1682- if "MP1" in mcu_file .name :
1683- mcu_dir = "STM32MP1xx"
1684- else :
1685- mcu_dir = mcu_file .name [:7 ] + "xx"
1687+
1688+ # Open input file
1689+ xml_mcu = parse (str (mcu_file ))
1690+ parse_IP_file ()
1691+ if not gpiofile :
1692+ print ("Could not find GPIO file" )
1693+ quit ()
1694+ xml_gpio = parse (str (dirIP / ("GPIO-" + gpiofile + "_Modes.xml" )))
1695+
1696+ mcu_dir = mcu_family + "xx"
16861697 out_path = root_dir / "variants" / mcu_dir / mcu_file .stem
16871698 periph_c_filepath = out_path / periph_c_filename
16881699 pinvar_h_filepath = out_path / pinvar_h_filename
@@ -1705,14 +1716,6 @@ def manage_repo():
17051716 variant_h_filepath .unlink ()
17061717 variant_h_file = open (variant_h_filepath , "w" , newline = "\n " )
17071718
1708- # open input file
1709- xml_mcu = parse (str (mcu_file ))
1710- parse_IP_file ()
1711- if not gpiofile :
1712- print ("Could not find GPIO file" )
1713- quit ()
1714- xml_gpio = parse (str (dirIP / ("GPIO-" + gpiofile + "_Modes.xml" )))
1715-
17161719 parse_pins ()
17171720 sort_my_lists ()
17181721 manage_alternate ()
0 commit comments