Skip to content

Commit 23bd927

Browse files
committed
ci(stm32wrapper): add HAL legacy support
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 9f59cfd commit 23bd927

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

CI/update/stm32wrapper.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ def wrap(arg_core, arg_cmsis, log):
184184
lower = serie.lower()
185185

186186
# Search stm32yyxx_[hal|ll]*.c file
187-
filelist = src.glob(f"stm32{lower}xx_*.c")
187+
filelist = src.glob(f"**/stm32{lower}xx_*.c")
188188
for fp in filelist:
189+
legacy = True if fp.parent.name == "Legacy" else False
189190
# File name
190191
fn = fp.name
191192
found = peripheral_c_regex.match(fn)
@@ -194,14 +195,30 @@ def wrap(arg_core, arg_cmsis, log):
194195
peripheral = found.group(1) if found else "hal"
195196
if "_ll_" in fn:
196197
if peripheral in ll_c_dict:
197-
ll_c_dict[peripheral].append(lower)
198+
if legacy:
199+
# Change legacy value if exists
200+
current_list = ll_c_dict.pop(peripheral)
201+
if current_list[-1][0] == lower:
202+
current_list.pop()
203+
current_list.append((lower, legacy))
204+
ll_c_dict[peripheral] = current_list
205+
else:
206+
ll_c_dict[peripheral].append((lower, legacy))
198207
else:
199-
ll_c_dict[peripheral] = [lower]
208+
ll_c_dict[peripheral] = [(lower, legacy)]
200209
else:
201210
if peripheral in hal_c_dict:
202-
hal_c_dict[peripheral].append(lower)
211+
if legacy:
212+
# Change legacy value if exists
213+
current_list = hal_c_dict.pop(peripheral)
214+
if current_list[-1][0] == lower:
215+
current_list.pop()
216+
current_list.append((lower, legacy))
217+
hal_c_dict[peripheral] = current_list
218+
else:
219+
hal_c_dict[peripheral].append((lower, legacy))
203220
else:
204-
hal_c_dict[peripheral] = [lower]
221+
hal_c_dict[peripheral] = [(lower, legacy)]
205222

206223
# Search stm32yyxx_ll_*.h file
207224
filelist = inc.glob(f"stm32{lower}xx_ll_*.h")

CI/update/templates/stm32yyxx_zz_ppp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#pragma GCC diagnostic push
33
#pragma GCC diagnostic ignored "-Wunused-parameter"
44

5-
{% for serie in serieslist %}
5+
{% for serie, legacy in serieslist %}
66
{% if loop.first %}
77
#ifdef STM32{{serie.upper()}}xx
88
{% else %}
@@ -11,6 +11,9 @@
1111
{% if type == periph %}
1212
#include "stm32{{serie}}xx_{{type}}.c"
1313
{% else %}
14+
{% if legacy %}
15+
#include "Legacy/stm32{{serie}}xx_{{type}}_{{periph}}.c"
16+
{% endif %}
1417
#include "stm32{{serie}}xx_{{type}}_{{periph}}.c"
1518
{% endif %}
1619
{% if loop.last %}

0 commit comments

Comments
 (0)