|
| 1 | +From ab75db19f9dfef873c5d2949b22eb64d78fa948b Mon Sep 17 00:00:00 2001 |
| 2 | +From: Riccardo Rizzo < [email protected]> |
| 3 | +Date: Mon, 28 Jun 2021 15:03:50 +0200 |
| 4 | +Subject: [PATCH 88/91] STM32: PWM: add export HRTIM capable pins to |
| 5 | + PeripheralPins |
| 6 | + |
| 7 | +--- |
| 8 | + .../tools/STM32_gen_PeripheralPins.py | 77 +++++++++++++++++++ |
| 9 | + 1 file changed, 77 insertions(+) |
| 10 | + |
| 11 | +diff --git a/targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py b/targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py |
| 12 | +index f8fbe34b47..08da8743d9 100644 |
| 13 | +--- a/targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py |
| 14 | ++++ b/targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py |
| 15 | +@@ -42,6 +42,7 @@ daclist = [] #'PIN','name','DACSignal' |
| 16 | + i2cscl_list = [] #'PIN','name','I2CSCLSignal' |
| 17 | + i2csda_list = [] #'PIN','name','I2CSDASignal' |
| 18 | + pwm_list = [] #'PIN','name','PWM' |
| 19 | ++hrtim_list = [] #'PIN','name','HRTIM' |
| 20 | + uarttx_list = [] #'PIN','name','UARTtx' |
| 21 | + uartrx_list = [] #'PIN','name','UARTrx' |
| 22 | + uartcts_list = [] #'PIN','name','UARTcts' |
| 23 | +@@ -289,6 +290,10 @@ def store_pwm(pin, name, signal): |
| 24 | + if "_CH" in signal: |
| 25 | + pwm_list.append([pin, name, signal]) |
| 26 | + |
| 27 | ++# function to store hrtim timers |
| 28 | ++def store_hrtim(pin, name, signal): |
| 29 | ++ if "_CH" in signal: |
| 30 | ++ hrtim_list.append([pin, name, signal]) |
| 31 | + |
| 32 | + # function to store Uart pins |
| 33 | + def store_uart(pin, name, signal): |
| 34 | +@@ -541,6 +546,8 @@ def print_all_lists(): |
| 35 | + print_i2c(i2cscl_list) |
| 36 | + if print_list_header("PWM", "PWM", pwm_list, "PWMOUT"): |
| 37 | + print_pwm() |
| 38 | ++ if print_list_header("PWM_HRTIM", "PWM_HRTIM", hrtim_list, "PWMOUT"): |
| 39 | ++ print_hrtim() |
| 40 | + if print_list_header("SERIAL", "UART_TX", uarttx_list, "SERIAL"): |
| 41 | + print_uart(uarttx_list) |
| 42 | + if print_list_header("", "UART_RX", uartrx_list, "SERIAL"): |
| 43 | +@@ -869,6 +876,71 @@ def print_pwm(): |
| 44 | + if ADD_DEVICE_IF: |
| 45 | + out_c_file.write( "#endif\n" ) |
| 46 | + |
| 47 | ++def print_hrtim(): |
| 48 | ++ prev_p = '' |
| 49 | ++ alt_index = 0 |
| 50 | ++ |
| 51 | ++ tim_dualcore = "NOT_KNOWN" |
| 52 | ++ for EachTarget in TIM_DUALCORE_LIST: |
| 53 | ++ if EachTarget in mcu_file: |
| 54 | ++ tim_dualcore = TIM_DUALCORE_LIST[EachTarget] |
| 55 | ++ |
| 56 | ++ for parsed_pin in hrtim_list: |
| 57 | ++ result = get_gpio_af_num(parsed_pin[1], parsed_pin[2]) |
| 58 | ++ commented_line = " " |
| 59 | ++ if parsed_pin[1] in PinLabel: |
| 60 | ++ if "STDIO_UART" in PinLabel[parsed_pin[1]]: |
| 61 | ++ commented_line = "//" |
| 62 | ++ if "RCC_OSC" in PinLabel[parsed_pin[1]]: |
| 63 | ++ commented_line = "//" |
| 64 | ++ if "%s_" % TIM_MST in parsed_pin[2]: |
| 65 | ++ commented_line = "//" |
| 66 | ++ if "%s_" % tim_dualcore in parsed_pin[2]: |
| 67 | ++ commented_line = "//" |
| 68 | ++ if commented_line != "//": |
| 69 | ++ if parsed_pin[0] == prev_p: |
| 70 | ++ prev_p = parsed_pin[0] |
| 71 | ++ parsed_pin[0] += '_ALT%d' % alt_index |
| 72 | ++ store_pin(parsed_pin[0], parsed_pin[0], "") |
| 73 | ++ alt_index += 1 |
| 74 | ++ else: |
| 75 | ++ prev_p = parsed_pin[0] |
| 76 | ++ alt_index = 0 |
| 77 | ++ s1 = "%-17s" % (commented_line + " {" + parsed_pin[0] + ',') |
| 78 | ++ # parsed_pin[2] : TIM2_CH1 / TIM15_CH1N |
| 79 | ++ a = parsed_pin[2].split('_') |
| 80 | ++ inst = a[0].replace("HRTIM", "PWM_I") |
| 81 | ++ # if len(inst) == 3: |
| 82 | ++ # inst += '1' |
| 83 | ++ s1 += "%-8s" % (inst + ',') |
| 84 | ++ N = len(a[1]) |
| 85 | ++ |
| 86 | ++ timer = a[1][0: N -1] |
| 87 | ++ chan = a[1][N - 1: N] |
| 88 | ++ |
| 89 | ++ if chan.endswith('1'): |
| 90 | ++ chan = ', 0' |
| 91 | ++ else: |
| 92 | ++ chan = ', 1' |
| 93 | ++ s1 += 'STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, ' |
| 94 | ++ r = result.split(' ') |
| 95 | ++ prev_s1 = "" |
| 96 | ++ for af in r: |
| 97 | ++ if s1 == prev_s1: |
| 98 | ++ continue |
| 99 | ++ else: |
| 100 | ++ prev_s1 = s1 |
| 101 | ++ s2 = s1 + af + ', ' + timer + chan + ')}, // ' + parsed_pin[2] |
| 102 | ++ if parsed_pin[1] in PinLabel: |
| 103 | ++ s2 += ' // Connected to ' + PinLabel[parsed_pin[1]] |
| 104 | ++ s2 += '\n' |
| 105 | ++ out_c_file.write(s2) |
| 106 | ++ out_c_file.write( """ {NC, NC, 0} |
| 107 | ++}; |
| 108 | ++""") |
| 109 | ++ if ADD_DEVICE_IF: |
| 110 | ++ out_c_file.write( "#endif\n" ) |
| 111 | ++ |
| 112 | + |
| 113 | + def print_uart(l): |
| 114 | + global ALTERNATE_DEFINITION |
| 115 | +@@ -1289,6 +1361,8 @@ def sort_my_lists(): |
| 116 | + i2csda_list.sort(key=natural_sortkey) |
| 117 | + pwm_list.sort(key=natural_sortkey2) # first sort on name column |
| 118 | + pwm_list.sort(key=natural_sortkey) |
| 119 | ++ hrtim_list.sort(key=natural_sortkey2) # first sort on name column |
| 120 | ++ hrtim_list.sort(key=natural_sortkey) |
| 121 | + uarttx_list.sort(key=natural_sortkey_uart) # first sort on name column |
| 122 | + uartrx_list.sort(key=natural_sortkey_uart) # first sort on name column |
| 123 | + uartcts_list.sort(key=natural_sortkey_uart) # first sort on name column |
| 124 | +@@ -1331,6 +1405,7 @@ def clean_all_lists(): |
| 125 | + del i2cscl_list[:] |
| 126 | + del i2csda_list[:] |
| 127 | + del pwm_list[:] |
| 128 | ++ del hrtim_list[:] |
| 129 | + del uarttx_list[:] |
| 130 | + del uartrx_list[:] |
| 131 | + del uartcts_list[:] |
| 132 | +@@ -1403,6 +1478,8 @@ def parse_pins(): |
| 133 | + store_i2c(pin, name, sig) |
| 134 | + if re.match("^TIM", sig) is not None: # ignore HRTIM |
| 135 | + store_pwm(pin, name, sig) |
| 136 | ++ if re.match("^HRTIM", sig) is not None: # ignore HRTIM |
| 137 | ++ store_hrtim(pin, name, sig) |
| 138 | + if re.match("^(LPU|US|U)ART", sig) is not None: |
| 139 | + store_uart(pin, name, sig) |
| 140 | + if "SPI" in sig: |
| 141 | +-- |
| 142 | +2.32.0 |
| 143 | + |
0 commit comments