Skip to content

Commit 2e8c0ec

Browse files
committed
STM32: add HRTIM patches
1 parent a09bee8 commit 2e8c0ec

5 files changed

+633
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
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+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
From 3f15d89980fb4d994932a3feba1d4535c6b97acd Mon Sep 17 00:00:00 2001
2+
From: Riccardo Rizzo <[email protected]>
3+
Date: Mon, 28 Jun 2021 15:05:40 +0200
4+
Subject: [PATCH 89/91] STM32H7: add HRTIM capable pins
5+
6+
---
7+
targets/TARGET_STM/PeripheralPins.h | 8 ++++++++
8+
.../TARGET_PORTENTA_H7/PeripheralPins.c | 16 ++++++++++++++++
9+
2 files changed, 24 insertions(+)
10+
11+
diff --git a/targets/TARGET_STM/PeripheralPins.h b/targets/TARGET_STM/PeripheralPins.h
12+
index fe4954068a..ae4fe1fb84 100644
13+
--- a/targets/TARGET_STM/PeripheralPins.h
14+
+++ b/targets/TARGET_STM/PeripheralPins.h
15+
@@ -60,6 +60,7 @@ extern const PinMap PinMap_I2C_SCL[];
16+
//*** PWM ***
17+
#if DEVICE_PWMOUT
18+
extern const PinMap PinMap_PWM[];
19+
+extern const PinMap PinMap_PWM_HRTIM[];
20+
#endif
21+
22+
//*** SERIAL ***
23+
@@ -117,6 +118,13 @@ extern const PinMap PinMap_OSPI_SSEL[];
24+
#define USE_USB_OTG_HS 2
25+
#define USE_USB_HS_IN_FS 3
26+
27+
+// HRTIM channels
28+
+#define CHA 0
29+
+#define CHB 1
30+
+#define CHC 2
31+
+#define CHD 3
32+
+#define CHE 4
33+
+
34+
#if DEVICE_USBDEVICE
35+
extern const PinMap PinMap_USB_HS[];
36+
extern const PinMap PinMap_USB_FS[];
37+
diff --git a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/PeripheralPins.c b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/PeripheralPins.c
38+
index 5e680fa387..1ca15d00a9 100644
39+
--- a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/PeripheralPins.c
40+
+++ b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/PeripheralPins.c
41+
@@ -288,6 +288,22 @@ MBED_WEAK const PinMap PinMap_PWM[] = {
42+
{PK_1_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N
43+
{NC, NC, 0}
44+
};
45+
+//*** PWM_HRTIM ***
46+
+
47+
+MBED_WEAK const PinMap PinMap_PWM_HRTIM[] = {
48+
+ {PA_8, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_HRTIM1, CHB, 1)}, // HRTIM_CHB2
49+
+ {PA_9, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_HRTIM1, CHC, 0)}, // HRTIM_CHC1
50+
+ {PA_10, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_HRTIM1, CHC, 1)}, // HRTIM_CHC2
51+
+ {PA_11, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_HRTIM1, CHD, 0)}, // HRTIM_CHD1
52+
+ {PA_12, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_HRTIM1, CHD, 1)}, // HRTIM_CHD2
53+
+ {PC_6, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_HRTIM1, CHA, 0)}, // HRTIM_CHA1
54+
+ {PC_7, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_HRTIM1, CHA, 1)}, // HRTIM_CHA2
55+
+ {PC_8, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_HRTIM1, CHB, 0)}, // HRTIM_CHB1
56+
+ {PG_6, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_HRTIM1, CHE, 0)}, // HRTIM_CHE1
57+
+ {PG_7, PWM_I, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_HRTIM1, CHE, 1)}, // HRTIM_CHE2
58+
+ {NC, NC, 0}
59+
+};
60+
+
61+
62+
//*** SERIAL ***
63+
64+
--
65+
2.32.0
66+

0 commit comments

Comments
 (0)