Skip to content

Commit f182253

Browse files
committed
[genpinmap] Add SD peripheral
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 4fcf78e commit f182253

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/genpinmap/genpinmap_arduino.py

+35
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
usb_list = [] # 'PIN','name','USB'
3434
usb_otgfs_list = [] # 'PIN','name','USB'
3535
usb_otghs_list = [] # 'PIN','name','USB'
36+
sd_list = [] # 'PIN','name','SD'
3637

3738

3839
def find_gpio_file():
@@ -296,6 +297,14 @@ def store_usb(pin, name, signal):
296297
usb_otghs_list.append([pin, name, signal])
297298

298299

300+
# function to store SD pins
301+
def store_sd(pin, name, signal):
302+
# print(pin, signal, name)
303+
if isPinAndSignalInList(pin, signal, sd_list):
304+
return
305+
sd_list.append([pin, name, signal])
306+
307+
299308
def print_header():
300309
s = """/*
301310
*******************************************************************************
@@ -377,6 +386,8 @@ def print_all_lists():
377386
print_usb(usb_otgfs_list)
378387
if print_list_header("", "USB_OTG_HS", "PCD", usb_otghs_list):
379388
print_usb(usb_otghs_list)
389+
if print_list_header("SD", "SD", "SD", sd_list):
390+
print_sd()
380391
# Print specific PinNames in header file
381392
print_syswkup_h()
382393
print_usb_h()
@@ -687,6 +698,26 @@ def print_syswkup_h():
687698
out_h_file.write(s1)
688699

689700

701+
def print_sd():
702+
for p in sd_list:
703+
result = get_gpio_af_num(p[1], p[2])
704+
s1 = "%-10s" % (" {" + p[0] + ",")
705+
# 2nd element is the SD signal
706+
a = p[2].split("_")
707+
if a[1].startswith("C") or a[1].endswith("DIR"):
708+
s1 += a[0] + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, " + result + ")},"
709+
else:
710+
s1 += a[0] + ", STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, " + result + ")},"
711+
s1 += " // " + p[2] + "\n"
712+
out_c_file.write(s1)
713+
out_c_file.write(
714+
""" {NC, NP, 0}
715+
};
716+
#endif
717+
"""
718+
)
719+
720+
690721
def print_usb(lst):
691722
use_hs_in_fs = False
692723
nb_loop = 1
@@ -788,6 +819,7 @@ def sort_my_lists():
788819
usb_list.sort(key=natural_sortkey)
789820
usb_otgfs_list.sort(key=natural_sortkey)
790821
usb_otghs_list.sort(key=natural_sortkey)
822+
sd_list.sort(key=natural_sortkey)
791823

792824

793825
def clean_all_lists():
@@ -813,6 +845,7 @@ def clean_all_lists():
813845
del usb_list[:]
814846
del usb_otgfs_list[:]
815847
del usb_otghs_list[:]
848+
del sd_list[:]
816849

817850

818851
def parse_pins():
@@ -855,6 +888,8 @@ def parse_pins():
855888
store_sys(pin, name, sig)
856889
if "USB" in sig:
857890
store_usb(pin, name, sig)
891+
if sig.startswith("SD"):
892+
store_sd(pin, name, sig)
858893

859894

860895
# main

0 commit comments

Comments
 (0)