6666 datetime .datetime .now ().year
6767)
6868
69-
69+ # GPIO file parsing
7070def find_gpio_file ():
7171 res = "ERROR"
7272 itemlist = xml_mcu .getElementsByTagName ("IP" )
@@ -495,7 +495,6 @@ def print_adc():
495495 s_pin_data += "_ADC_CONTROL"
496496 s_pin_data += ", GPIO_NOPULL, 0, "
497497
498- manage_alternate (adclist )
499498 wpin = width_format (adclist )
500499
501500 for p in adclist :
@@ -542,7 +541,6 @@ def print_dac():
542541
543542
544543def print_i2c (lst ):
545- manage_alternate (lst )
546544 wpin = width_format (lst )
547545 for p in lst :
548546 result = get_gpio_af_num (p [1 ], p [2 ])
@@ -562,7 +560,6 @@ def print_i2c(lst):
562560
563561
564562def print_pwm ():
565- manage_alternate (pwm_list )
566563 wpin = width_format (pwm_list )
567564
568565 for p in pwm_list :
@@ -589,7 +586,6 @@ def print_pwm():
589586
590587
591588def print_uart (lst ):
592- manage_alternate (lst )
593589 wpin = width_format (lst )
594590 for p in lst :
595591 result = get_gpio_af_num (p [1 ], p [2 ])
@@ -609,7 +605,6 @@ def print_uart(lst):
609605
610606
611607def print_spi (lst ):
612- manage_alternate (lst )
613608 wpin = width_format (lst )
614609 for p in lst :
615610 result = get_gpio_af_num (p [1 ], p [2 ])
@@ -848,11 +843,10 @@ def print_usb_h():
848843 pinvar_h_file .write ("#endif\n " )
849844
850845
846+ # Variant files generation
851847def spi_pins_variant ():
852848 ss_pin = ss1_pin = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = "PYn"
853849
854- # mosi_pin = spimosi_list[0][0].replace("_", "")
855- # mosi_inst = spimosi_list[0][2].split("_", 1)[0]
856850 # Iterate to find match instance if any
857851 for mosi in spimosi_list :
858852 mosi_inst = mosi [2 ].split ("_" , 1 )[0 ]
@@ -1133,20 +1127,7 @@ def print_variant():
11331127 )
11341128
11351129
1136- def manage_alternate (lst ):
1137- prev_p = ""
1138- alt_index = 0
1139- for index , p in enumerate (lst ):
1140- if p [0 ] == prev_p :
1141- p [0 ] += "_ALT%d" % alt_index
1142- lst [index ] = p
1143- store_pin (p [0 ], p [1 ], alt_list )
1144- alt_index += 1
1145- else :
1146- prev_p = p [0 ]
1147- alt_index = 0
1148-
1149-
1130+ # List management
11501131tokenize = re .compile (r"(\d+)|(\D+)" ).findall
11511132
11521133
@@ -1160,7 +1141,6 @@ def natural_sortkey2(list_2_elem):
11601141
11611142def sort_my_lists ():
11621143 io_list .sort (key = natural_sortkey )
1163- alt_list .sort (key = natural_sortkey )
11641144 dualpad_list .sort (key = natural_sortkey )
11651145 remap_list .sort (key = natural_sortkey )
11661146 adclist .sort (key = natural_sortkey )
@@ -1227,6 +1207,74 @@ def clean_all_lists():
12271207 del sd_list [:]
12281208
12291209
1210+ def manage_alternate ():
1211+ update_alternate (adclist )
1212+ update_alternate (daclist )
1213+ update_alternate (i2cscl_list )
1214+ update_alternate (i2csda_list )
1215+ update_alternate (pwm_list )
1216+ update_alternate (uarttx_list )
1217+ update_alternate (uartrx_list )
1218+ update_alternate (uartcts_list )
1219+ update_alternate (uartrts_list )
1220+ update_alternate (spimosi_list )
1221+ update_alternate (spimiso_list )
1222+ update_alternate (spissel_list )
1223+ update_alternate (spisclk_list )
1224+ update_alternate (cantd_list )
1225+ update_alternate (canrd_list )
1226+ update_alternate (eth_list )
1227+ update_alternate (quadspidata0_list )
1228+ update_alternate (quadspidata1_list )
1229+ update_alternate (quadspidata2_list )
1230+ update_alternate (quadspidata3_list )
1231+ update_alternate (quadspisclk_list )
1232+ update_alternate (quadspissel_list )
1233+ update_alternate (syswkup_list )
1234+ update_alternate (usb_list )
1235+ update_alternate (usb_otgfs_list )
1236+ update_alternate_usb_otg_hs ()
1237+ update_alternate (sd_list )
1238+
1239+ alt_list .sort (key = natural_sortkey )
1240+
1241+
1242+
1243+ def update_alternate (lst ):
1244+ prev_p = ""
1245+ alt_index = 1
1246+ for index , p in enumerate (lst ):
1247+ if p [0 ] == prev_p :
1248+ p [0 ] += "_ALT%d" % alt_index
1249+ lst [index ] = p
1250+ store_pin (p [0 ], p [1 ], alt_list )
1251+ alt_index += 1
1252+ else :
1253+ prev_p = p [0 ]
1254+ alt_index = 1
1255+
1256+
1257+ def update_alternate_usb_otg_hs ():
1258+ prev_p = ""
1259+ alt_index = 1
1260+ for nb in range (2 ):
1261+ for index , p in enumerate (usb_otghs_list ):
1262+ if nb == 0 :
1263+ if "ULPI" in p [2 ]:
1264+ continue
1265+ else :
1266+ if "ULPI" not in p [2 ]:
1267+ continue
1268+ if p [0 ] == prev_p :
1269+ p [0 ] += "_ALT%d" % alt_index
1270+ usb_otghs_list [index ] = p
1271+ store_pin (p [0 ], p [1 ], alt_list )
1272+ alt_index += 1
1273+ else :
1274+ prev_p = p [0 ]
1275+ alt_index = 1
1276+
1277+
12301278def parse_pins ():
12311279 print (" * Getting pins per Ips..." )
12321280 pinregex = r"^(P[A-Z][0-9][0-5]?[_]?[C]?)|^(ANA[0-9])"
@@ -1445,6 +1493,7 @@ def parse_pins():
14451493
14461494 parse_pins ()
14471495 sort_my_lists ()
1496+ manage_alternate ()
14481497 print_periph_header ()
14491498 print_all_lists ()
14501499 print_variant ()
0 commit comments