2727from argparse import RawTextHelpFormatter
2828import subprocess
2929
30- GENPINMAP_VERSION = "1.20.3 "
30+ GENPINMAP_VERSION = "1.20.4 "
3131
3232ADD_DEVICE_IF = 0
3333ADD_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
263248def store_pin (pin , name , functionality ):
264249 # store pin I/O
@@ -395,6 +380,9 @@ def store_sys(pin, name, signal):
395380
396381
397382def 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
15951589parser .add_argument ("-g" , "--gpio" , help = "Add GPIO PinMap table" , action = "store_true" )
15961590parser .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" )
15981592parser .add_argument ("-d" , "--debug" , help = "Few debug info in console" , action = "store_true" )
15991593
16001594args = 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
0 commit comments