Skip to content

Commit f1c0d7f

Browse files
committed
[genpinmap] Fix FDCAN issue
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 0bd6239 commit f1c0d7f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/genpinmap/genpinmap_arduino.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,13 @@ def print_all_lists():
372372
print_spi(spisclk_list)
373373
if print_list_header("", "SPI_SSEL", "SPI", spissel_list):
374374
print_spi(spissel_list)
375-
if print_list_header("CAN", "CAN_RD", "CAN", canrd_list, cantd_list):
375+
if len(canrd_list) and "FDCAN" in canrd_list[0][2]:
376+
canname = "FDCAN"
377+
else:
378+
canname = "CAN"
379+
if print_list_header(canname, "CAN_RD", canname, canrd_list, cantd_list):
376380
print_can(canrd_list)
377-
if print_list_header("", "CAN_TD", "CAN", cantd_list):
381+
if print_list_header("", "CAN_TD", canname, cantd_list):
378382
print_can(cantd_list)
379383
if print_list_header("ETHERNET", "Ethernet", "ETH", eth_list):
380384
print_eth()
@@ -595,14 +599,15 @@ def print_can(lst):
595599
for p in lst:
596600
result = get_gpio_af_num(p[1], p[2])
597601
s1 = "%-10s" % (" {" + p[0] + ",")
598-
# 2nd element is the CAN_XX signal
599-
instance = p[2].split("_")[0].replace("CAN", "")
600-
if len(instance) == 0:
601-
instance = "1"
602+
# 2nd element is the (FD)CAN_XX signal
603+
instance_name = p[2].split("_")[0]
604+
instance_number = instance_name.replace("FD", "").replace("CAN", "")
605+
if len(instance_number) == 0:
606+
instance_name += "1"
602607
if "STM32F10" in mcu_file and lst == canrd_list:
603-
s1 += "CAN" + instance + ", STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, "
608+
s1 += instance_name + ", STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, "
604609
else:
605-
s1 += "CAN" + instance + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, "
610+
s1 += instance_name + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, "
606611
r = result.split(" ")
607612
for af in r:
608613
s2 = s1 + af + ")},\n"

0 commit comments

Comments
 (0)