Skip to content

Commit 611ec14

Browse files
authored
Merge pull request ARMmbed#15081 from jeromecoutant/PR_PERIPHSCRIPT
STM32: STM32_gen_PeripheralPins.py v1.20.4
2 parents 0fac696 + 4da602f commit 611ec14

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from argparse import RawTextHelpFormatter
2828
import subprocess
2929

30-
GENPINMAP_VERSION = "1.20.3"
30+
GENPINMAP_VERSION = "1.20.4"
3131

3232
ADD_DEVICE_IF = 0
3333
ADD_GPIO_PINMAP = 0
@@ -240,25 +240,10 @@ def get_gpio_af_num_stm32f1(pintofind, iptofind):
240240
) in myc.childNodes:
241241
if mygpioaf != "":
242242
mygpioaf += " "
243-
mygpioaf += mygpioaflist.data.replace(
244-
"__HAL_", ""
245-
).replace(
246-
"_REMAP", ""
247-
)
243+
mygpioaf += mygpioaflist.data.replace("__HAL_", "")
248244
if mygpioaf == "":
249245
mygpioaf = "AFIO_NONE"
250-
return mygpioaf.replace("AFIO_NONE", "0")\
251-
.replace("AFIO_SPI1_ENABLE", "1")\
252-
.replace("AFIO_I2C1_ENABLE", "2")\
253-
.replace("AFIO_USART1_ENABLE", "3")\
254-
.replace("AFIO_USART3_PARTIAL", "5")\
255-
.replace("AFIO_TIM1_PARTIAL", "6")\
256-
.replace("AFIO_TIM3_PARTIAL", "7")\
257-
.replace("AFIO_TIM2_ENABLE", "8")\
258-
.replace("AFIO_TIM2_PARTIAL_1", "8")\
259-
.replace("AFIO_TIM2_PARTIAL_2", "8")\
260-
.replace("AFIO_TIM3_ENABLE", "9")\
261-
.replace("AFIO_CAN1_2", "10")
246+
return mygpioaf
262247

263248
def store_pin(pin, name, functionality):
264249
# store pin I/O
@@ -395,6 +380,9 @@ def store_sys(pin, name, signal):
395380

396381

397382
def make_cmakelist():
383+
global TARGET_NAME
384+
if TARGET_NAME == "":
385+
TARGET_NAME = "xxx"
398386
mbed_target = "mbed-" + TARGET_NAME.replace("_", "-").lower()
399387
mbed_family = "mbed-" + TARGET_SUBFAMILY.lower()
400388

@@ -534,7 +522,10 @@ def print_footer():
534522

535523
for EachLED in sorted(StandardLED):
536524
led_label = " // %s" % EachLED
537-
out_h_file.write("#define LED%i %-5s %s\n" % (name_counter, re.sub(r'(P.)', r'\1_', StandardLED[EachLED]), led_label))
525+
commented_line = ""
526+
if "TODO" in led_label:
527+
commented_line = "// "
528+
out_h_file.write("%s#define LED%i %-5s %s\n" % (commented_line, name_counter, re.sub(r'(P.)', r'\1_', StandardLED[EachLED]), led_label))
538529
name_counter += 1
539530

540531
name_counter = 1
@@ -544,7 +535,10 @@ def print_footer():
544535
button_label = ""
545536
if EachBUTTON in PinLabel:
546537
button_label = " // %s" % PinLabel[EachBUTTON]
547-
out_h_file.write("#define BUTTON%i %-5s %s\n" % (name_counter, re.sub(r'(P.)', r'\1_', EachBUTTON).split('/')[0].split('-')[0], button_label))
538+
commented_line = ""
539+
if "TODO" in button_label:
540+
commented_line = "// "
541+
out_h_file.write("%s#define BUTTON%i %-5s %s\n" % (commented_line, name_counter, re.sub(r'(P.)', r'\1_', EachBUTTON).split('/')[0].split('-')[0], button_label))
548542
name_counter += 1
549543

550544
line_to_write = ("""
@@ -1594,7 +1588,7 @@ def parse_board_file(file_name):
15941588

15951589
parser.add_argument("-g", "--gpio", help="Add GPIO PinMap table", action="store_true")
15961590
parser.add_argument("-n", "--nopull", help="Avoid STM32_open_pin_data git pull", action="store_true")
1597-
parser.add_argument("-f", "--flat", help="All targets stored in targets_custom/TARGET_STM/", action="store_true")
1591+
parser.add_argument("-f", "--flat", help="All targets stored in TARGET_CUSTOM/TARGET_STM/", action="store_true")
15981592
parser.add_argument("-d", "--debug", help="Few debug info in console", action="store_true")
15991593

16001594
args = parser.parse_args()
@@ -1846,7 +1840,10 @@ def parse_board_file(file_name):
18461840
if args.mcu:
18471841
m = re.match("(STM32[\w]{7})", EachTargetName)
18481842
if m:
1849-
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' %TARGET_FAMILY, 'TARGET_%s' %TARGET_SUBFAMILY, 'TARGET_%s' % m.group(0))
1843+
if FLAT_DIRECTORY == 0:
1844+
out_path = os.path.join(cur_dir, 'TARGET_CUSTOM', 'TARGET_STM', 'TARGET_%s' %TARGET_FAMILY, 'TARGET_%s' %TARGET_SUBFAMILY, 'TARGET_%s' % m.group(0))
1845+
else:
1846+
out_path = os.path.join(cur_dir, 'TARGET_CUSTOM', 'TARGET_%s' % m.group(0))
18501847
if EachTargetName.endswith('A'):
18511848
out_path += "_A"
18521849
elif EachTargetName.endswith('P'):
@@ -1865,9 +1862,9 @@ def parse_board_file(file_name):
18651862
else:
18661863
if EachTargetName == MCU_USERNAME:
18671864
if FLAT_DIRECTORY == 0:
1868-
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' % TARGET_FAMILY, 'TARGET_%s' % TARGET_SUBFAMILY, 'TARGET_%s' % TARGET_NAME)
1865+
out_path = os.path.join(cur_dir, 'TARGET_CUSTOM', 'TARGET_STM', 'TARGET_%s' % TARGET_FAMILY, 'TARGET_%s' % TARGET_SUBFAMILY, 'TARGET_%s' % TARGET_NAME)
18691866
else:
1870-
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' % TARGET_NAME)
1867+
out_path = os.path.join(cur_dir, 'TARGET_CUSTOM', 'TARGET_%s' % TARGET_NAME)
18711868
else:
18721869
continue
18731870

@@ -1891,6 +1888,7 @@ def parse_board_file(file_name):
18911888
cmake_file = open(cmake_filename, 'w')
18921889

18931890
#open input file
1891+
DUAL_PAD = False
18941892
try:
18951893
xml_mcu = parse(input_file_name)
18961894
except:

0 commit comments

Comments
 (0)