Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32: STM32_gen_PeripheralPins.py v1.20.4 #15081

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 22 additions & 24 deletions targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from argparse import RawTextHelpFormatter
import subprocess

GENPINMAP_VERSION = "1.20.3"
GENPINMAP_VERSION = "1.20.4"

ADD_DEVICE_IF = 0
ADD_GPIO_PINMAP = 0
Expand Down Expand Up @@ -240,25 +240,10 @@ def get_gpio_af_num_stm32f1(pintofind, iptofind):
) in myc.childNodes:
if mygpioaf != "":
mygpioaf += " "
mygpioaf += mygpioaflist.data.replace(
"__HAL_", ""
).replace(
"_REMAP", ""
)
mygpioaf += mygpioaflist.data.replace("__HAL_", "")
if mygpioaf == "":
mygpioaf = "AFIO_NONE"
return mygpioaf.replace("AFIO_NONE", "0")\
.replace("AFIO_SPI1_ENABLE", "1")\
.replace("AFIO_I2C1_ENABLE", "2")\
.replace("AFIO_USART1_ENABLE", "3")\
.replace("AFIO_USART3_PARTIAL", "5")\
.replace("AFIO_TIM1_PARTIAL", "6")\
.replace("AFIO_TIM3_PARTIAL", "7")\
.replace("AFIO_TIM2_ENABLE", "8")\
.replace("AFIO_TIM2_PARTIAL_1", "8")\
.replace("AFIO_TIM2_PARTIAL_2", "8")\
.replace("AFIO_TIM3_ENABLE", "9")\
.replace("AFIO_CAN1_2", "10")
return mygpioaf

def store_pin(pin, name, functionality):
# store pin I/O
Expand Down Expand Up @@ -395,6 +380,9 @@ def store_sys(pin, name, signal):


def make_cmakelist():
global TARGET_NAME
if TARGET_NAME == "":
TARGET_NAME = "xxx"
mbed_target = "mbed-" + TARGET_NAME.replace("_", "-").lower()
mbed_family = "mbed-" + TARGET_SUBFAMILY.lower()

Expand Down Expand Up @@ -534,7 +522,10 @@ def print_footer():

for EachLED in sorted(StandardLED):
led_label = " // %s" % EachLED
out_h_file.write("#define LED%i %-5s %s\n" % (name_counter, re.sub(r'(P.)', r'\1_', StandardLED[EachLED]), led_label))
commented_line = ""
if "TODO" in led_label:
commented_line = "// "
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))
name_counter += 1

name_counter = 1
Expand All @@ -544,7 +535,10 @@ def print_footer():
button_label = ""
if EachBUTTON in PinLabel:
button_label = " // %s" % PinLabel[EachBUTTON]
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))
commented_line = ""
if "TODO" in button_label:
commented_line = "// "
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))
name_counter += 1

line_to_write = ("""
Expand Down Expand Up @@ -1594,7 +1588,7 @@ def parse_board_file(file_name):

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

args = parser.parse_args()
Expand Down Expand Up @@ -1846,7 +1840,10 @@ def parse_board_file(file_name):
if args.mcu:
m = re.match("(STM32[\w]{7})", EachTargetName)
if m:
out_path = os.path.join(cur_dir, 'targets_custom', 'TARGET_STM', 'TARGET_%s' %TARGET_FAMILY, 'TARGET_%s' %TARGET_SUBFAMILY, 'TARGET_%s' % m.group(0))
if FLAT_DIRECTORY == 0:
out_path = os.path.join(cur_dir, 'TARGET_CUSTOM', 'TARGET_STM', 'TARGET_%s' %TARGET_FAMILY, 'TARGET_%s' %TARGET_SUBFAMILY, 'TARGET_%s' % m.group(0))
else:
out_path = os.path.join(cur_dir, 'TARGET_CUSTOM', 'TARGET_%s' % m.group(0))
if EachTargetName.endswith('A'):
out_path += "_A"
elif EachTargetName.endswith('P'):
Expand All @@ -1865,9 +1862,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' % TARGET_NAME)
out_path = os.path.join(cur_dir, 'TARGET_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' % TARGET_NAME)
out_path = os.path.join(cur_dir, 'TARGET_CUSTOM', 'TARGET_%s' % TARGET_NAME)
else:
continue

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

#open input file
DUAL_PAD = False
try:
xml_mcu = parse(input_file_name)
except:
Expand Down