|
1 | 1 | """
|
2 | 2 | * mbed Microcontroller Library
|
3 |
| -* Copyright (c) 2006-2018 ARM Limited |
4 |
| -* Copyright (c) 2019 STMicroelectronics |
| 3 | +* Copyright (c) 2006-2019 ARM Limited |
| 4 | +* Copyright (c) 2006-2019 STMicroelectronics |
5 | 5 | *
|
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License");
|
7 | 7 | * you may not use this file except in compliance with the License.
|
|
27 | 27 | from xml.dom.minidom import parse, Node
|
28 | 28 | from argparse import RawTextHelpFormatter
|
29 | 29 |
|
30 |
| -GENPINMAP_VERSION = "1.7" |
| 30 | +GENPINMAP_VERSION = "1.8" |
31 | 31 |
|
32 | 32 | ADD_DEVICE_IF = 0
|
33 | 33 | ADD_QSPI_FEATURE = 1
|
|
57 | 57 | quadspidata3_list = [] #'PIN','name','QUADSPIDATA3'
|
58 | 58 | quadspisclk_list = [] #'PIN','name','QUADSPISCLK'
|
59 | 59 | quadspissel_list = [] #'PIN','name','QUADSPISSEL'
|
60 |
| -usb_list = [] #'PIN','name','USB' |
| 60 | +usb_list = [] # 'PIN','name','USB' |
| 61 | +usb_otgfs_list = [] # 'PIN','name','USB' |
| 62 | +usb_otghs_list = [] # 'PIN','name','USB' |
61 | 63 | osc_list = [] #'PIN','name','OSC'
|
62 | 64 | sys_list = [] #'PIN','name','SYS'
|
63 | 65 |
|
@@ -332,7 +334,12 @@ def store_qspi(pin, name, signal):
|
332 | 334 |
|
333 | 335 | # function to store USB pins
|
334 | 336 | def store_usb(pin, name, signal):
|
335 |
| - usb_list.append([pin, name, signal]) |
| 337 | + if "OTG" not in signal: |
| 338 | + usb_list.append([pin, name, signal]) |
| 339 | + elif signal.startswith("USB_OTG_FS"): |
| 340 | + usb_otgfs_list.append([pin, name, signal]) |
| 341 | + elif signal.startswith("USB_OTG_HS"): |
| 342 | + usb_otghs_list.append([pin, name, signal]) |
336 | 343 |
|
337 | 344 |
|
338 | 345 | # function to store OSC pins
|
@@ -518,7 +525,15 @@ def print_all_lists():
|
518 | 525 | print_qspi(quadspisclk_list)
|
519 | 526 | if print_list_header("", "QSPI_SSEL", quadspissel_list, "QSPI"):
|
520 | 527 | print_qspi(quadspissel_list)
|
| 528 | + if print_list_header("USBDEVICE", "USB_FS", usb_list, "USBDEVICE"): |
| 529 | + print_usb(usb_list) |
| 530 | + if print_list_header("USBDEVICE", "USB_FS", usb_otgfs_list, "USBDEVICE"): |
| 531 | + print_usb(usb_otgfs_list) |
| 532 | + if print_list_header("USBDEVICE", "USB_HS", usb_otghs_list, "USBDEVICE"): |
| 533 | + print_usb(usb_otghs_list) |
521 | 534 | print_h_file(usb_list, "USB")
|
| 535 | + print_h_file(usb_otgfs_list, "USB FS") |
| 536 | + print_h_file(usb_otghs_list, "USB HS") |
522 | 537 | print_h_file(eth_list, "ETHERNET")
|
523 | 538 | print_h_file(osc_list, "OSCILLATOR")
|
524 | 539 | print_h_file(sys_list, "DEBUG")
|
@@ -873,8 +888,80 @@ def print_qspi(l):
|
873 | 888 | if ADD_DEVICE_IF:
|
874 | 889 | out_c_file.write( "#endif\n" )
|
875 | 890 |
|
| 891 | +def print_usb(lst): |
| 892 | + use_hs_in_fs = False |
| 893 | + nb_loop = 1 |
| 894 | + inst = "USB_FS" |
| 895 | + if lst is usb_otgfs_list: |
| 896 | + inst = "USB_FS" |
| 897 | + elif lst is usb_otghs_list: |
| 898 | + inst = "USB_HS" |
| 899 | + nb_loop = 2 |
| 900 | + |
| 901 | + for nb in range(nb_loop): |
| 902 | + for p in lst: |
| 903 | + result = get_gpio_af_num(p[1], p[2]) |
| 904 | + |
| 905 | + CommentedLine = " " |
| 906 | + |
| 907 | + if p[1] in PinLabel.keys(): |
| 908 | + if "STDIO_UART" in PinLabel[p[1]]: |
| 909 | + CommentedLine = "//" |
| 910 | + if "RCC_OSC" in PinLabel[p[1]]: |
| 911 | + CommentedLine = "//" |
| 912 | + |
| 913 | + if "_SOF" in p[2] or "_NOE" in p[2]: |
| 914 | + CommentedLine = "//" |
| 915 | + |
| 916 | + if lst is usb_otghs_list: |
| 917 | + if nb == 0: |
| 918 | + if "ULPI" in p[2]: |
| 919 | + continue |
| 920 | + elif not use_hs_in_fs: |
| 921 | + out_c_file.write("#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_HS_IN_FS)\n") |
| 922 | + use_hs_in_fs = True |
| 923 | + else: |
| 924 | + if "ULPI" not in p[2]: |
| 925 | + continue |
| 926 | + elif use_hs_in_fs: |
| 927 | + out_c_file.write("#else /* MBED_CONF_TARGET_USB_SPEED */\n") |
| 928 | + use_hs_in_fs = False |
| 929 | + |
| 930 | + s1 = "%-16s" % (CommentedLine + " {" + p[0] + ',') |
| 931 | + |
| 932 | + # 2nd element is the USB_XXXX signal |
| 933 | + if not p[2].startswith("USB_D") and "VBUS" not in p[2]: |
| 934 | + if "ID" not in p[2]: |
| 935 | + s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, " |
| 936 | + else: |
| 937 | + # ID pin: AF_PP + PULLUP |
| 938 | + s1 += inst + ", STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, " |
| 939 | + else: |
| 940 | + # USB_DM/DP and VBUS: INPUT + NOPULL |
| 941 | + s1 += inst + ", STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, " |
| 942 | + if result == "NOTFOUND": |
| 943 | + s1 += "0)}," |
| 944 | + else: |
| 945 | + r = result.split(" ") |
| 946 | + for af in r: |
| 947 | + s1 += af + ")}," |
| 948 | + s1 += " // " + p[2] |
| 949 | + if p[1] in PinLabel.keys(): |
| 950 | + s1 += ' // Connected to ' + PinLabel[p[1]] |
| 951 | + s1 += "\n" |
| 952 | + out_c_file.write(s1) |
| 953 | + if lst: |
| 954 | + if lst is usb_otghs_list: |
| 955 | + out_c_file.write("#endif /* MBED_CONF_TARGET_USB_SPEED */\n") |
| 956 | + out_c_file.write(""" {NC, NC, 0} |
| 957 | +}; |
| 958 | +""") |
| 959 | + if ADD_DEVICE_IF: |
| 960 | + out_c_file.write( "#endif\n" ) |
| 961 | + |
876 | 962 |
|
877 | 963 | def print_h_file(l, comment):
|
| 964 | + l.sort(key=natural_sortkey2) |
878 | 965 | if len(l) > 0:
|
879 | 966 | s = ("\n /**** %s pins ****/\n" % comment)
|
880 | 967 | out_h_file.write(s)
|
@@ -934,16 +1021,15 @@ def sort_my_lists():
|
934 | 1021 | spisclk_list.sort(key=natural_sortkey)
|
935 | 1022 | cantd_list.sort(key=natural_sortkey)
|
936 | 1023 | canrd_list.sort(key=natural_sortkey)
|
937 |
| - eth_list.sort(key=natural_sortkey2) |
938 | 1024 | quadspidata0_list.sort(key=natural_sortkey)
|
939 | 1025 | quadspidata1_list.sort(key=natural_sortkey)
|
940 | 1026 | quadspidata2_list.sort(key=natural_sortkey)
|
941 | 1027 | quadspidata3_list.sort(key=natural_sortkey)
|
942 | 1028 | quadspisclk_list.sort(key=natural_sortkey)
|
943 | 1029 | quadspissel_list.sort(key=natural_sortkey)
|
944 |
| - usb_list.sort(key=natural_sortkey2) |
945 |
| - osc_list.sort(key=natural_sortkey2) |
946 |
| - sys_list.sort(key=natural_sortkey2) |
| 1030 | + usb_list.sort(key=natural_sortkey) |
| 1031 | + usb_otgfs_list.sort(key=natural_sortkey) |
| 1032 | + usb_otghs_list.sort(key=natural_sortkey) |
947 | 1033 |
|
948 | 1034 | def clean_all_lists():
|
949 | 1035 | del io_list[:]
|
|
0 commit comments