66
66
datetime .datetime .now ().year
67
67
)
68
68
69
-
69
+ # GPIO file parsing
70
70
def find_gpio_file ():
71
71
res = "ERROR"
72
72
itemlist = xml_mcu .getElementsByTagName ("IP" )
@@ -495,7 +495,6 @@ def print_adc():
495
495
s_pin_data += "_ADC_CONTROL"
496
496
s_pin_data += ", GPIO_NOPULL, 0, "
497
497
498
- manage_alternate (adclist )
499
498
wpin = width_format (adclist )
500
499
501
500
for p in adclist :
@@ -542,7 +541,6 @@ def print_dac():
542
541
543
542
544
543
def print_i2c (lst ):
545
- manage_alternate (lst )
546
544
wpin = width_format (lst )
547
545
for p in lst :
548
546
result = get_gpio_af_num (p [1 ], p [2 ])
@@ -562,7 +560,6 @@ def print_i2c(lst):
562
560
563
561
564
562
def print_pwm ():
565
- manage_alternate (pwm_list )
566
563
wpin = width_format (pwm_list )
567
564
568
565
for p in pwm_list :
@@ -589,7 +586,6 @@ def print_pwm():
589
586
590
587
591
588
def print_uart (lst ):
592
- manage_alternate (lst )
593
589
wpin = width_format (lst )
594
590
for p in lst :
595
591
result = get_gpio_af_num (p [1 ], p [2 ])
@@ -609,7 +605,6 @@ def print_uart(lst):
609
605
610
606
611
607
def print_spi (lst ):
612
- manage_alternate (lst )
613
608
wpin = width_format (lst )
614
609
for p in lst :
615
610
result = get_gpio_af_num (p [1 ], p [2 ])
@@ -848,11 +843,10 @@ def print_usb_h():
848
843
pinvar_h_file .write ("#endif\n " )
849
844
850
845
846
+ # Variant files generation
851
847
def spi_pins_variant ():
852
848
ss_pin = ss1_pin = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = "PYn"
853
849
854
- # mosi_pin = spimosi_list[0][0].replace("_", "")
855
- # mosi_inst = spimosi_list[0][2].split("_", 1)[0]
856
850
# Iterate to find match instance if any
857
851
for mosi in spimosi_list :
858
852
mosi_inst = mosi [2 ].split ("_" , 1 )[0 ]
@@ -1143,20 +1137,7 @@ def print_variant():
1143
1137
)
1144
1138
1145
1139
1146
- def manage_alternate (lst ):
1147
- prev_p = ""
1148
- alt_index = 0
1149
- for index , p in enumerate (lst ):
1150
- if p [0 ] == prev_p :
1151
- p [0 ] += "_ALT%d" % alt_index
1152
- lst [index ] = p
1153
- store_pin (p [0 ], p [1 ], alt_list )
1154
- alt_index += 1
1155
- else :
1156
- prev_p = p [0 ]
1157
- alt_index = 0
1158
-
1159
-
1140
+ # List management
1160
1141
tokenize = re .compile (r"(\d+)|(\D+)" ).findall
1161
1142
1162
1143
@@ -1170,7 +1151,6 @@ def natural_sortkey2(list_2_elem):
1170
1151
1171
1152
def sort_my_lists ():
1172
1153
io_list .sort (key = natural_sortkey )
1173
- alt_list .sort (key = natural_sortkey )
1174
1154
dualpad_list .sort (key = natural_sortkey )
1175
1155
remap_list .sort (key = natural_sortkey )
1176
1156
adclist .sort (key = natural_sortkey )
@@ -1237,6 +1217,53 @@ def clean_all_lists():
1237
1217
del sd_list [:]
1238
1218
1239
1219
1220
+ def manage_alternate ():
1221
+ update_alternate (adclist )
1222
+ update_alternate (daclist )
1223
+ update_alternate (i2cscl_list )
1224
+ update_alternate (i2csda_list )
1225
+ update_alternate (pwm_list )
1226
+ update_alternate (uarttx_list )
1227
+ update_alternate (uartrx_list )
1228
+ update_alternate (uartcts_list )
1229
+ update_alternate (uartrts_list )
1230
+ update_alternate (spimosi_list )
1231
+ update_alternate (spimiso_list )
1232
+ update_alternate (spissel_list )
1233
+ update_alternate (spisclk_list )
1234
+ update_alternate (cantd_list )
1235
+ update_alternate (canrd_list )
1236
+ update_alternate (eth_list )
1237
+ update_alternate (quadspidata0_list )
1238
+ update_alternate (quadspidata1_list )
1239
+ update_alternate (quadspidata2_list )
1240
+ update_alternate (quadspidata3_list )
1241
+ update_alternate (quadspisclk_list )
1242
+ update_alternate (quadspissel_list )
1243
+ update_alternate (syswkup_list )
1244
+ update_alternate (usb_list )
1245
+ update_alternate (usb_otgfs_list )
1246
+ update_alternate (usb_otghs_list )
1247
+ update_alternate (sd_list )
1248
+
1249
+ alt_list .sort (key = natural_sortkey )
1250
+
1251
+
1252
+
1253
+ def update_alternate (lst ):
1254
+ prev_p = ""
1255
+ alt_index = 0
1256
+ for index , p in enumerate (lst ):
1257
+ if p [0 ] == prev_p :
1258
+ p [0 ] += "_ALT%d" % alt_index
1259
+ lst [index ] = p
1260
+ store_pin (p [0 ], p [1 ], alt_list )
1261
+ alt_index += 1
1262
+ else :
1263
+ prev_p = p [0 ]
1264
+ alt_index = 0
1265
+
1266
+
1240
1267
def parse_pins ():
1241
1268
print (" * Getting pins per Ips..." )
1242
1269
pinregex = r"^(P[A-Z][0-9][0-5]?[_]?[C]?)|^(ANA[0-9])"
@@ -1455,6 +1482,7 @@ def parse_pins():
1455
1482
1456
1483
parse_pins ()
1457
1484
sort_my_lists ()
1485
+ manage_alternate ()
1458
1486
print_periph_header ()
1459
1487
print_all_lists ()
1460
1488
print_variant ()
0 commit comments