83
83
usb_inst = {"usb" : "" , "otg_fs" : "" , "otg_hs" : "" }
84
84
mcu_family = ""
85
85
mcu_refname = ""
86
+ mcu_core = []
86
87
mcu_flash = []
87
88
mcu_ram = []
88
89
legacy_hal = {
@@ -154,13 +155,15 @@ def parse_mcu_file():
154
155
global gpiofile
155
156
global mcu_family
156
157
global mcu_refname
158
+ global mcu_core
157
159
158
160
tim_regex = r"^(TIM\d+)$"
159
161
usb_regex = r"^(USB(?!PD|_HOST|_DEVICE|X).*)$"
160
162
gpiofile = ""
161
163
del tim_inst_list [:]
162
164
del mcu_ram [:]
163
165
del mcu_flash [:]
166
+ del mcu_core [:]
164
167
usb_inst ["usb" ] = ""
165
168
usb_inst ["otg_fs" ] = ""
166
169
usb_inst ["otg_hs" ] = ""
@@ -176,6 +179,13 @@ def parse_mcu_file():
176
179
if mcu_family .endswith ("+" ):
177
180
mcu_family = mcu_family [:- 1 ]
178
181
mcu_refname = mcu_node .attributes ["RefName" ].value
182
+ core_node = mcu_node .getElementsByTagName ("Core" )
183
+ for f in core_node :
184
+ # Strip last non digit characters and extract the number
185
+ arm_core_ = re .sub (r"^A[Rr][Mm] Cortex-" , "" , f .firstChild .nodeValue ).strip ("+" )
186
+ mcu_core_family = re .sub (r"\d+$" , "" , arm_core_ )
187
+ mcu_core_digit = int (re .sub (r"^[ARM]" , "" , arm_core_ ))
188
+ mcu_core .append ([mcu_core_family , mcu_core_digit ])
179
189
180
190
ram_node = mcu_node .getElementsByTagName ("Ram" )
181
191
for f in ram_node :
@@ -1245,6 +1255,27 @@ def manage_syswkup():
1245
1255
1246
1256
1247
1257
def print_pinamevar ():
1258
+ # First check core version and search PWR_WAKEUP_*
1259
+ syswkup_type = "PIN"
1260
+ if mcu_core [0 ][1 ] == 33 :
1261
+ # Search in stm32{series}xx_hal_pwr.h WR_WAKEUP_
1262
+ pwr_header_file_path = (
1263
+ system_path
1264
+ / "Drivers"
1265
+ / f"{ mcu_family } xx_HAL_Driver"
1266
+ / "Inc"
1267
+ / f"stm32{ mcu_family .replace ('STM32' , '' ).lower ()} xx_hal_pwr.h"
1268
+ )
1269
+ if not (pwr_header_file_path ).exists ():
1270
+ print (f"Error: { pwr_header_file_path } not found!" )
1271
+ exit (1 )
1272
+ else :
1273
+ with open (pwr_header_file_path , "r" ) as pwr_header_file :
1274
+ for line in pwr_header_file :
1275
+ if "PWR_WAKEUP_LINE" in line :
1276
+ syswkup_type = "LINE"
1277
+ break
1278
+
1248
1279
# Print specific PinNames in header file
1249
1280
pinvar_h_template = j2_env .get_template (pinvar_h_filename )
1250
1281
@@ -1281,6 +1312,7 @@ def print_pinamevar():
1281
1312
remap_pins_list = remap_pins_list ,
1282
1313
waltpin = max (waltpin ),
1283
1314
alt_pins_list = alt_pins_list ,
1315
+ syswkup_type = syswkup_type ,
1284
1316
syswkup_pins_list = syswkup_pins_list ,
1285
1317
wusbpin = max (wusbpin ),
1286
1318
usb_pins_list = sorted_usb_pins_list ,
@@ -2705,6 +2737,7 @@ def manage_repo():
2705
2737
# Open input file
2706
2738
xml_mcu = parse (str (mcu_file ))
2707
2739
parse_mcu_file ()
2740
+
2708
2741
# Generate only for specified pattern series or supported one
2709
2742
# Check if mcu_family is supported by the core
2710
2743
if (
0 commit comments