@@ -79,10 +79,15 @@ def get_gpio_af_num(pintofind, iptofind):
79
79
if myc .nodeType == Node .ELEMENT_NODE :
80
80
# myc = node of ALTERNATE
81
81
for mygpioaflist in myc .childNodes :
82
- if mygpioaflist .data not in mygpioaf :
82
+ if (
83
+ mygpioaflist .data
84
+ not in mygpioaf
85
+ ):
83
86
if mygpioaf != "" :
84
87
mygpioaf += " "
85
- mygpioaf += mygpioaflist .data
88
+ mygpioaf += (
89
+ mygpioaflist .data
90
+ )
86
91
# print (mygpioaf)
87
92
if mygpioaf == "" :
88
93
mygpioaf = "GPIO_AF_NONE"
@@ -650,43 +655,53 @@ def print_syswkup_h():
650
655
651
656
def print_usb (lst ):
652
657
use_hs_in_fs = False
658
+ nb_loop = 1
653
659
inst = "USB"
654
660
if lst == usb_otgfs_list :
655
661
inst = "USB_OTG_FS"
656
662
elif lst == usb_otghs_list :
657
663
inst = "USB_OTG_HS"
664
+ nb_loop = 2
658
665
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, "
674
691
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
+
688
703
if lst :
689
- if use_hs_in_fs :
704
+ if lst == usb_otghs_list :
690
705
out_c_file .write ("#endif /* USE_USB_HS_IN_FS */\n " )
691
706
out_c_file .write (
692
707
""" {NC, NP, 0}
0 commit comments