|
43 | 43 | usb_otghs_list = [] # 'PIN','name','USB' |
44 | 44 | sd_list = [] # 'PIN','name','SD' |
45 | 45 |
|
| 46 | +# IP information |
| 47 | +gpiofile = "" |
| 48 | +tim_inst_list = [] # TIMx instance |
| 49 | +usb_inst = {"usb": "", "otg_fs": "", "otg_hs": ""} |
| 50 | + |
46 | 51 | # format |
47 | 52 | # Peripheral |
48 | 53 | start_elem_fmt = " {{{:{width}}" |
|
52 | 57 | """ |
53 | 58 |
|
54 | 59 |
|
55 | | -# GPIO file parsing |
56 | | -def find_gpio_file(): |
57 | | - res = "ERROR" |
| 60 | +# mcu file parsing |
| 61 | +def parse_IP_file(): |
| 62 | + global gpiofile |
| 63 | + tim_regex = r"^(TIM\d+)$" |
| 64 | + usb_regex = r"^(USB(?!PD|_HOST|_DEVICE).*)$" |
| 65 | + gpiofile = "" |
| 66 | + del tim_inst_list[:] |
| 67 | + usb_inst["usb"] = "" |
| 68 | + usb_inst["otg_fs"] = "" |
| 69 | + usb_inst["otg_hs"] = "" |
| 70 | + |
58 | 71 | itemlist = xml_mcu.getElementsByTagName("IP") |
59 | 72 | for s in itemlist: |
60 | | - if "GPIO" in s.attributes["Name"].value: |
61 | | - res = s.attributes["Version"].value |
62 | | - break |
63 | | - return res |
| 73 | + inst = re.match(tim_regex, s.attributes["InstanceName"].value) |
| 74 | + if inst: |
| 75 | + # Collect all TIMx instance |
| 76 | + tim_inst_list.append(inst.group(1)) |
| 77 | + else: |
| 78 | + inst = re.match(usb_regex, s.attributes["InstanceName"].value) |
| 79 | + if inst: |
| 80 | + if "OTG" in inst.group(1): |
| 81 | + if "FS" in inst.group(1): |
| 82 | + usb_inst["otg_fs"] = inst.group(1) |
| 83 | + else: |
| 84 | + usb_inst["otg_hs"] = inst.group(1) |
| 85 | + else: |
| 86 | + usb_inst["usb"] = inst.group(1) |
| 87 | + else: |
| 88 | + if gpiofile == "" and "GPIO" in s.attributes["Name"].value: |
| 89 | + gpiofile = s.attributes["Version"].value |
64 | 90 |
|
65 | 91 |
|
66 | 92 | def get_gpio_af_num(pintofind, iptofind): |
@@ -675,12 +701,12 @@ def usb_pinmap(lst): |
675 | 701 | nb_loop = 1 |
676 | 702 |
|
677 | 703 | if lst == usb_otgfs_list: |
678 | | - inst = "USB_OTG_FS" |
| 704 | + inst = usb_inst["otg_fs"] |
679 | 705 | elif lst == usb_otghs_list: |
680 | | - inst = "USB_OTG_HS" |
| 706 | + inst = usb_inst["otg_hs"] |
681 | 707 | nb_loop = 2 |
682 | 708 | else: |
683 | | - inst = "USB" |
| 709 | + inst = usb_inst["usb"] |
684 | 710 | for nb in range(nb_loop): |
685 | 711 | for p in lst: |
686 | 712 | hsinfs = 0 |
@@ -1048,15 +1074,8 @@ def timer_variant(): |
1048 | 1074 | "TIM8", |
1049 | 1075 | "TIM20", |
1050 | 1076 | ] |
1051 | | - tim_inst_list = [] |
1052 | | - tim_regex = r"^(TIM\d+)$" |
| 1077 | + |
1053 | 1078 | tone = servo = "TIMx" |
1054 | | - itemlist = xml_mcu.getElementsByTagName("IP") |
1055 | | - # Collect all TIMx instance |
1056 | | - for s in itemlist: |
1057 | | - inst = re.match(tim_regex, s.attributes["InstanceName"].value) |
1058 | | - if inst: |
1059 | | - tim_inst_list.append(inst.group(1)) |
1060 | 1079 | if tim_inst_list: |
1061 | 1080 | for pref in tim_inst_order: |
1062 | 1081 | if pref in tim_inst_list: |
@@ -1676,8 +1695,8 @@ def manage_repo(): |
1676 | 1695 |
|
1677 | 1696 | # open input file |
1678 | 1697 | xml_mcu = parse(str(mcu_file)) |
1679 | | - gpiofile = find_gpio_file() |
1680 | | - if gpiofile == "ERROR": |
| 1698 | + parse_IP_file() |
| 1699 | + if not gpiofile: |
1681 | 1700 | print("Could not find GPIO file") |
1682 | 1701 | quit() |
1683 | 1702 | xml_gpio = parse(str(dirIP / ("GPIO-" + gpiofile + "_Modes.xml"))) |
|
0 commit comments