Skip to content
This repository was archived by the owner on Oct 6, 2021. It is now read-only.

Commit ca93082

Browse files
committed
Add Ethernet pinmap generation
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 9891aae commit ca93082

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

genpinmap/genpinmap_arduino.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
spisclk_list = [] #'PIN','name','SPISCLK'
2020
cantd_list = [] #'PIN','name','CANTD'
2121
canrd_list = [] #'PIN','name','CANRD'
22+
eth_list = [] #'PIN','name','ETH'
2223

2324

2425
def find_gpio_file(xmldoc):
@@ -126,6 +127,10 @@ def store_can(pin, name, signal):
126127
if "_TX" in signal:
127128
cantd_list.append([pin,name,signal])
128129

130+
#function to store ETH list
131+
def store_eth (pin, name, signal):
132+
eth_list.append([pin,name,signal])
133+
129134
def print_header():
130135
s = ("""/*
131136
*******************************************************************************
@@ -198,6 +203,8 @@ def print_all_lists():
198203
print_can(xml, canrd_list)
199204
if print_list_header("", "CAN_TD", cantd_list, "CAN"):
200205
print_can(xml, cantd_list)
206+
if print_list_header("ETHERNET", "Ethernet", eth_list, "ETH"):
207+
print_eth(xml, eth_list)
201208

202209
def print_list_header(comment, name, l, switch):
203210
if len(l)>0:
@@ -378,6 +385,33 @@ def print_can(xml, l):
378385
#endif
379386
""")
380387

388+
def print_eth(xml, l):
389+
i=0
390+
if len(l)>0:
391+
prev_s = ''
392+
while i < len(l):
393+
p=l[i]
394+
result = get_gpio_af_num(xml, p[1], p[2])
395+
if result != 'NOTFOUND':
396+
s1 = "%-12s" % (" {" + p[0] + ',')
397+
#2nd element is the ETH_XXXX signal
398+
s1 += 'ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, ' + result +')},'
399+
#check duplicated lines, only signal differs
400+
if (prev_s == s1):
401+
s1 = '|' + p[2]
402+
else:
403+
if len(prev_s)>0:
404+
out_file.write('\n')
405+
prev_s = s1
406+
s1 += ' // ' + p[2]
407+
out_file.write(s1)
408+
i += 1
409+
410+
out_file.write( """\n {NC, NP, 0}
411+
};
412+
#endif
413+
""")
414+
381415
tokenize = re.compile(r'(\d+)|(\D+)').findall
382416
def natural_sortkey(list_2_elem):
383417

@@ -399,6 +433,7 @@ def sort_my_lists():
399433
spisclk_list.sort(key=natural_sortkey)
400434
cantd_list.sort(key=natural_sortkey)
401435
canrd_list.sort(key=natural_sortkey)
436+
eth_list.sort(key=natural_sortkey)
402437

403438
return
404439

@@ -518,6 +553,8 @@ def sort_my_lists():
518553
store_spi( pin, name, sig)
519554
if "CAN" in sig:
520555
store_can( pin, name, sig)
556+
if "ETH" in sig:
557+
store_eth( pin, name, sig)
521558

522559
print (" * * * Sorting lists...")
523560
sort_my_lists()

0 commit comments

Comments
 (0)