@@ -638,33 +638,34 @@ def print_eth():
638638
639639
640640def print_qspi (lst ):
641- prev_s = ""
642- wpin = width_format (lst )
643- if "OCTOSPIM_P1" in lst [0 ][2 ]:
644- winst = 7
645- else :
646- winst = 6
647- for p in lst :
648- result = get_gpio_af_num (p [1 ], p [2 ])
649- s1 = start_elem_format .format (p [0 ] + "," , width = wpin )
650- # 2nd element is the XXXXSPI_YYYY signal
651- if "OCTOSPIM_P1" in p [2 ]:
652- s1 += "OCTOSPI1,"
653- elif "OCTOSPIM_P2" in p [2 ]:
654- s1 += "OCTOSPI2,"
655- else :
656- s1 += "QUADSPI,"
657- s1 += " STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, " + result + ")},"
658- # check duplicated lines, only signal differs
659- if prev_s == s1 :
660- s1 = "|" + p [2 ]
641+ if lst :
642+ prev_s = ""
643+ wpin = width_format (lst )
644+ if "OCTOSPIM_P1" in lst [0 ][2 ]:
645+ winst = 7
661646 else :
662- if len (prev_s ) > 0 :
663- out_c_file .write ("\n " )
664- prev_s = s1
665- s1 += " // " + p [2 ]
666- out_c_file .write (s1 + "\n " )
667- out_c_file .write (end_array_format .format ("" , w1 = wpin - 3 , w2 = winst ))
647+ winst = 6
648+ for p in lst :
649+ result = get_gpio_af_num (p [1 ], p [2 ])
650+ s1 = start_elem_format .format (p [0 ] + "," , width = wpin )
651+ # 2nd element is the XXXXSPI_YYYY signal
652+ if "OCTOSPIM_P1" in p [2 ]:
653+ s1 += "OCTOSPI1,"
654+ elif "OCTOSPIM_P2" in p [2 ]:
655+ s1 += "OCTOSPI2,"
656+ else :
657+ s1 += "QUADSPI,"
658+ s1 += " STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, " + result + ")},"
659+ # check duplicated lines, only signal differs
660+ if prev_s == s1 :
661+ s1 = "|" + p [2 ]
662+ else :
663+ if len (prev_s ) > 0 :
664+ out_c_file .write ("\n " )
665+ prev_s = s1
666+ s1 += " // " + p [2 ]
667+ out_c_file .write (s1 + "\n " )
668+ out_c_file .write (end_array_format .format ("" , w1 = wpin - 3 , w2 = winst ))
668669
669670
670671def print_sd ():
@@ -686,54 +687,54 @@ def print_sd():
686687
687688
688689def print_usb (lst ):
689- use_hs_in_fs = False
690- nb_loop = 1
691- inst = "USB"
692- if lst == usb_otgfs_list :
693- inst = "USB_OTG_FS"
694- elif lst == usb_otghs_list :
695- inst = "USB_OTG_HS"
696- nb_loop = 2
697- wpin = width_format (lst )
698- winst = len (inst ) - 1
699- for nb in range (nb_loop ):
700- for p in lst :
701- result = get_gpio_af_num (p [1 ], p [2 ])
702- s1 = start_elem_format .format (p [0 ] + "," , width = wpin )
703- if lst == usb_otghs_list :
704- if nb == 0 :
705- if "ULPI" in p [2 ]:
706- continue
707- elif not use_hs_in_fs :
708- out_c_file .write ("#ifdef USE_USB_HS_IN_FS\n " )
709- use_hs_in_fs = True
690+ if lst :
691+ use_hs_in_fs = False
692+ nb_loop = 1
693+ inst = "USB"
694+ if lst == usb_otgfs_list :
695+ inst = "USB_OTG_FS"
696+ elif lst == usb_otghs_list :
697+ inst = "USB_OTG_HS"
698+ nb_loop = 2
699+ wpin = width_format (lst )
700+ winst = len (inst ) - 1
701+ for nb in range (nb_loop ):
702+ for p in lst :
703+ result = get_gpio_af_num (p [1 ], p [2 ])
704+ s1 = start_elem_format .format (p [0 ] + "," , width = wpin )
705+ if lst == usb_otghs_list :
706+ if nb == 0 :
707+ if "ULPI" in p [2 ]:
708+ continue
709+ elif not use_hs_in_fs :
710+ out_c_file .write ("#ifdef USE_USB_HS_IN_FS\n " )
711+ use_hs_in_fs = True
712+ else :
713+ if "ULPI" not in p [2 ]:
714+ continue
715+ elif use_hs_in_fs :
716+ out_c_file .write ("#else\n " )
717+ use_hs_in_fs = False
718+
719+ # 2nd element is the USB_XXXX signal
720+ if not p [2 ].startswith ("USB_D" ) and "VBUS" not in p [2 ]:
721+ if "ID" not in p [2 ]:
722+ s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, "
723+ else :
724+ # ID pin: AF_PP + PULLUP
725+ s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, "
710726 else :
711- if "ULPI" not in p [2 ]:
712- continue
713- elif use_hs_in_fs :
714- out_c_file .write ("#else\n " )
715- use_hs_in_fs = False
716-
717- # 2nd element is the USB_XXXX signal
718- if not p [2 ].startswith ("USB_D" ) and "VBUS" not in p [2 ]:
719- if "ID" not in p [2 ]:
720- s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, "
727+ # USB_DM/DP and VBUS: INPUT + NOPULL
728+ s1 += inst + ", STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, "
729+ if result == "NOTFOUND" :
730+ s1 += "0)},"
721731 else :
722- # ID pin: AF_PP + PULLUP
723- s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, "
724- else :
725- # USB_DM/DP and VBUS: INPUT + NOPULL
726- s1 += inst + ", STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, "
727- if result == "NOTFOUND" :
728- s1 += "0)},"
729- else :
730- r = result .split (" " )
731- for af in r :
732- s1 += af + ")},"
733- s1 += " // " + p [2 ] + "\n "
734- out_c_file .write (s1 )
732+ r = result .split (" " )
733+ for af in r :
734+ s1 += af + ")},"
735+ s1 += " // " + p [2 ] + "\n "
736+ out_c_file .write (s1 )
735737
736- if lst :
737738 if lst == usb_otghs_list :
738739 out_c_file .write ("#endif /* USE_USB_HS_IN_FS */\n " )
739740 out_c_file .write (end_array_format .format ("" , w1 = wpin - 3 , w2 = winst ))
0 commit comments