|
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):
|
@@ -671,12 +697,12 @@ def usb_pinmap(lst):
|
671 | 697 | nb_loop = 1
|
672 | 698 |
|
673 | 699 | if lst == usb_otgfs_list:
|
674 |
| - inst = "USB_OTG_FS" |
| 700 | + inst = usb_inst["otg_fs"] |
675 | 701 | elif lst == usb_otghs_list:
|
676 |
| - inst = "USB_OTG_HS" |
| 702 | + inst = usb_inst["otg_hs"] |
677 | 703 | nb_loop = 2
|
678 | 704 | else:
|
679 |
| - inst = "USB" |
| 705 | + inst = usb_inst["usb"] |
680 | 706 | for nb in range(nb_loop):
|
681 | 707 | for p in lst:
|
682 | 708 | hsinfs = 0
|
@@ -1042,15 +1068,8 @@ def timer_variant():
|
1042 | 1068 | "TIM8",
|
1043 | 1069 | "TIM20",
|
1044 | 1070 | ]
|
1045 |
| - tim_inst_list = [] |
1046 |
| - tim_regex = r"^(TIM\d+)$" |
| 1071 | + |
1047 | 1072 | tone = servo = "TIMx"
|
1048 |
| - itemlist = xml_mcu.getElementsByTagName("IP") |
1049 |
| - # Collect all TIMx instance |
1050 |
| - for s in itemlist: |
1051 |
| - inst = re.match(tim_regex, s.attributes["InstanceName"].value) |
1052 |
| - if inst: |
1053 |
| - tim_inst_list.append(inst.group(1)) |
1054 | 1073 | if tim_inst_list:
|
1055 | 1074 | for pref in tim_inst_order:
|
1056 | 1075 | if pref in tim_inst_list:
|
@@ -1651,8 +1670,8 @@ def manage_repo():
|
1651 | 1670 |
|
1652 | 1671 | # open input file
|
1653 | 1672 | xml_mcu = parse(str(mcu_file))
|
1654 |
| - gpiofile = find_gpio_file() |
1655 |
| - if gpiofile == "ERROR": |
| 1673 | + parse_IP_file() |
| 1674 | + if not gpiofile: |
1656 | 1675 | print("Could not find GPIO file")
|
1657 | 1676 | quit()
|
1658 | 1677 | xml_gpio = parse(str(dirIP / ("GPIO-" + gpiofile + "_Modes.xml")))
|
|
0 commit comments