Skip to content

Commit

Permalink
Merge pull request #14594 from jeromecoutant/PR_GEN_MCU
Browse files Browse the repository at this point in the history
STM32_gen_PeripheralPins.py : TargetName correction
  • Loading branch information
0xc0170 authored May 3, 2021
2 parents dace32a + 7150c06 commit 99cf33c
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
MCU_USERNAME= ""
TIM_MST = ""
ALTERNATE_DEFINITION = 0
TARGET_NAME = ""

TIM_DUALCORE_LIST = { # Timer used for us ticker is hardcoded in this script
"H745":"TIM2",
Expand Down Expand Up @@ -461,7 +462,7 @@ def print_header():
#ifdef __cplusplus
extern "C" {
#endif
""" % (date_year, os.path.basename(input_file_name), TargetName))
""" % (date_year, os.path.basename(input_file_name), TARGET_NAME))
out_h_file.write(line_to_write)

if DUAL_PAD:
Expand Down Expand Up @@ -1689,21 +1690,20 @@ def parse_board_file(file_name):
sys.exit(0)

parse_board_file(board_file_name)
TargetName = ""
if "Nucleo" in board_file_name:
TargetName += "NUCLEO_"
TARGET_NAME += "NUCLEO_"
elif "Discovery" in board_file_name:
TargetName += "DISCO_"
TARGET_NAME += "DISCO_"
elif "Evaluation" in board_file_name:
TargetName += "EVAL_"
TARGET_NAME += "EVAL_"
m = re.search(r'STM32([MFLGWH][\w]*)_Board', board_file_name)
if m:
TargetName += "%s" % m.group(1)
TARGET_NAME += "%s" % m.group(1)
# specific case
if "-P" in board_file_name:
TargetName += "_P"
TARGET_NAME += "_P"
elif "-Q" in board_file_name:
TargetName += "_Q"
TARGET_NAME += "_Q"

target_rename = { # manual renaming for some boards
"DISCO_L072C": "DISCO_L072CZ_LRWAN1",
Expand All @@ -1724,19 +1724,18 @@ def parse_board_file(file_name):
"DISCO_H747XIH": "DISCO_H747I"
}

if TargetName in target_rename:
TargetName = target_rename[TargetName]
if TARGET_NAME in target_rename:
TARGET_NAME = target_rename[TARGET_NAME]

if "DISC1" in board_file_name:
TargetName += "_DISC1"
TARGET_NAME += "_DISC1"

else:
sys.exit(1)

# Parse the user's custom board .ioc file
if args.custom:
parse_board_file(args.custom)
TargetName = ""

for mcu_file in mcu_list:
TargetNameList = []
Expand Down Expand Up @@ -1823,9 +1822,9 @@ def parse_board_file(file_name):
else:
if EachTargetName == MCU_USERNAME:
if FLAT_DIRECTORY == 0:
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' % TARGET_FAMILY, 'TARGET_%s' % TARGET_SUBFAMILY, 'TARGET_%s' % TargetName)
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' % TARGET_FAMILY, 'TARGET_%s' % TARGET_SUBFAMILY, 'TARGET_%s' % TARGET_NAME)
else:
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' % TargetName)
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' % TARGET_NAME)
else:
continue

Expand Down

0 comments on commit 99cf33c

Please sign in to comment.