@@ -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" )
0 commit comments