Skip to content

Commit e756125

Browse files
committed
ci(stm32variant): manage PWR_WAKEUP LINE vs PIN
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 750d92f commit e756125

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

CI/update/stm32variant.py

+33
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
usb_inst = {"usb": "", "otg_fs": "", "otg_hs": ""}
8484
mcu_family = ""
8585
mcu_refname = ""
86+
mcu_core = []
8687
mcu_flash = []
8788
mcu_ram = []
8889
legacy_hal = {
@@ -154,13 +155,15 @@ def parse_mcu_file():
154155
global gpiofile
155156
global mcu_family
156157
global mcu_refname
158+
global mcu_core
157159

158160
tim_regex = r"^(TIM\d+)$"
159161
usb_regex = r"^(USB(?!PD|_HOST|_DEVICE|X).*)$"
160162
gpiofile = ""
161163
del tim_inst_list[:]
162164
del mcu_ram[:]
163165
del mcu_flash[:]
166+
del mcu_core[:]
164167
usb_inst["usb"] = ""
165168
usb_inst["otg_fs"] = ""
166169
usb_inst["otg_hs"] = ""
@@ -176,6 +179,13 @@ def parse_mcu_file():
176179
if mcu_family.endswith("+"):
177180
mcu_family = mcu_family[:-1]
178181
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])
179189

180190
ram_node = mcu_node.getElementsByTagName("Ram")
181191
for f in ram_node:
@@ -1245,6 +1255,27 @@ def manage_syswkup():
12451255

12461256

12471257
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+
12481279
# Print specific PinNames in header file
12491280
pinvar_h_template = j2_env.get_template(pinvar_h_filename)
12501281

@@ -1281,6 +1312,7 @@ def print_pinamevar():
12811312
remap_pins_list=remap_pins_list,
12821313
waltpin=max(waltpin),
12831314
alt_pins_list=alt_pins_list,
1315+
syswkup_type=syswkup_type,
12841316
syswkup_pins_list=syswkup_pins_list,
12851317
wusbpin=max(wusbpin),
12861318
usb_pins_list=sorted_usb_pins_list,
@@ -2705,6 +2737,7 @@ def manage_repo():
27052737
# Open input file
27062738
xml_mcu = parse(str(mcu_file))
27072739
parse_mcu_file()
2740+
27082741
# Generate only for specified pattern series or supported one
27092742
# Check if mcu_family is supported by the core
27102743
if (

CI/update/templates/PinNamesVar.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
{% set outer_loop = loop %}
2828
{% if syswkup_list %}
2929
{% for syswkup in syswkup_list %}
30-
#ifdef PWR_WAKEUP_PIN{{outer_loop.index}}
30+
#ifdef PWR_WAKEUP_{{syswkup_type}}{{outer_loop.index}}
3131
SYS_WKUP{{outer_loop.index}}{{"_{}".format(loop.index - 1) if loop.index > 1}} = {{syswkup[0]}},{{syswkup[1]}}
3232
#endif
3333
{% endfor %}
3434
{% else %}
35-
#ifdef PWR_WAKEUP_PIN{{loop.index}}
35+
#ifdef PWR_WAKEUP_{{syswkup_type}}{{loop.index}}
3636
SYS_WKUP{{loop.index}} = NC,
3737
#endif
3838
{% endif %}

0 commit comments

Comments
 (0)