Skip to content

Commit 2453a90

Browse files
committed
[genpinmap] Fix PinMap_USB_OTG_HS
If USE_USB_HS_IN_FS is defined only those pins have to be defined Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent a7ee669 commit 2453a90

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed

src/genpinmap/genpinmap_arduino.py

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,15 @@ def get_gpio_af_num(pintofind, iptofind):
7979
if myc.nodeType == Node.ELEMENT_NODE:
8080
# myc = node of ALTERNATE
8181
for mygpioaflist in myc.childNodes:
82-
if mygpioaflist.data not in mygpioaf:
82+
if (
83+
mygpioaflist.data
84+
not in mygpioaf
85+
):
8386
if mygpioaf != "":
8487
mygpioaf += " "
85-
mygpioaf += mygpioaflist.data
88+
mygpioaf += (
89+
mygpioaflist.data
90+
)
8691
# print (mygpioaf)
8792
if mygpioaf == "":
8893
mygpioaf = "GPIO_AF_NONE"
@@ -650,43 +655,53 @@ def print_syswkup_h():
650655

651656
def print_usb(lst):
652657
use_hs_in_fs = False
658+
nb_loop = 1
653659
inst = "USB"
654660
if lst == usb_otgfs_list:
655661
inst = "USB_OTG_FS"
656662
elif lst == usb_otghs_list:
657663
inst = "USB_OTG_HS"
664+
nb_loop = 2
658665

659-
for p in lst:
660-
result = get_gpio_af_num(p[1], p[2])
661-
s1 = "%-10s" % (" {" + p[0] + ",")
662-
if lst == usb_otghs_list:
663-
if "ULPI" not in p[2] and not use_hs_in_fs:
664-
out_c_file.write("#ifdef USE_USB_HS_IN_FS\n")
665-
use_hs_in_fs = True
666-
if "ULPI" in p[2] and use_hs_in_fs:
667-
out_c_file.write("#endif /* USE_USB_HS_IN_FS */\n")
668-
use_hs_in_fs = False
669-
670-
# 2nd element is the USB_XXXX signal
671-
if not p[2].startswith("USB_D") and "VBUS" not in p[2]:
672-
if "ID" not in p[2]:
673-
s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, "
666+
for nb in range(nb_loop):
667+
for p in lst:
668+
result = get_gpio_af_num(p[1], p[2])
669+
s1 = "%-10s" % (" {" + p[0] + ",")
670+
if lst == usb_otghs_list:
671+
if nb == 0:
672+
if "ULPI" in p[2]:
673+
continue
674+
elif not use_hs_in_fs:
675+
out_c_file.write("#ifdef USE_USB_HS_IN_FS\n")
676+
use_hs_in_fs = True
677+
else:
678+
if "ULPI" not in p[2]:
679+
continue
680+
elif use_hs_in_fs:
681+
out_c_file.write("#else\n")
682+
use_hs_in_fs = False
683+
684+
# 2nd element is the USB_XXXX signal
685+
if not p[2].startswith("USB_D") and "VBUS" not in p[2]:
686+
if "ID" not in p[2]:
687+
s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, "
688+
else:
689+
# ID pin: AF_PP + PULLUP
690+
s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, "
674691
else:
675-
# ID pin: AF_PP + PULLUP
676-
s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, "
677-
else:
678-
# USB_DM/DP and VBUS: INPUT + NOPULL
679-
s1 += inst + ", STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, "
680-
if result == "NOTFOUND":
681-
s1 += "0)},"
682-
else:
683-
r = result.split(" ")
684-
for af in r:
685-
s1 += af + ")},"
686-
s1 += " // " + p[2] + "\n"
687-
out_c_file.write(s1)
692+
# USB_DM/DP and VBUS: INPUT + NOPULL
693+
s1 += inst + ", STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, "
694+
if result == "NOTFOUND":
695+
s1 += "0)},"
696+
else:
697+
r = result.split(" ")
698+
for af in r:
699+
s1 += af + ")},"
700+
s1 += " // " + p[2] + "\n"
701+
out_c_file.write(s1)
702+
688703
if lst:
689-
if use_hs_in_fs:
704+
if lst == usb_otghs_list:
690705
out_c_file.write("#endif /* USE_USB_HS_IN_FS */\n")
691706
out_c_file.write(
692707
""" {NC, NP, 0}

0 commit comments

Comments
 (0)