5858)
5959all_ll_header_file_template = j2_env .get_template (all_ll_h_file )
6060ll_h_file_template = j2_env .get_template (ll_h_file )
61- util_h_file_template = j2_env .get_template ("stm32yyxx_util_ppp .h" )
61+ utils_h_file_template = j2_env .get_template ("stm32yyxx_utils_ppp .h" )
6262c_file_template = j2_env .get_template (c_file )
6363dsp_file_template = Template ('#include "../Source/{{ dsp_dir }}/{{ dsp_name }}"\n \n ' )
6464stm32_def_build_template = j2_env .get_template (stm32_def_build_file )
6565startup_stm32yyxx_template = j2_env .get_template (startup_stm32yyxx_file )
6666system_stm32_template = j2_env .get_template (system_stm32_file )
6767
6868# re
69- feat_c_regex = re .compile (r"stm32[^_]+ _(.*).c$" )
69+ feat_c_regex = re .compile (r"stm32[^_]* _(.*).c$" )
7070feat_h_regex = re .compile (r"stm32[^_]+_(.*).h$" )
71- feat_util_h_regex = re .compile (r"stm32[^_]+_util_(.*).h$" )
72- feat_utils_h_regex = re .compile (r"stm32_utils_(.*).h$" )
71+ feat_utils_h_regex = re .compile (r"stm32[^_]*_utils?_(.*).h$" )
7372
7473
7574def checkConfig (arg_core , arg_cmsis ):
@@ -225,7 +224,7 @@ def wrap(arg_core, arg_cmsis, log):
225224 ll_h_dict = {}
226225 ll_c_dict = {}
227226 hal_c_dict = {}
228- util_h_dict = {}
227+ utils_h_dict = {}
229228
230229 # Search all files for each series
231230 for series in stm32_series :
@@ -238,9 +237,10 @@ def wrap(arg_core, arg_cmsis, log):
238237 print (f"Generating for { series } ..." )
239238 lower = series .lower ()
240239
241- # Search stm32yyxx_[hal|ll] *.c file
242- filelist = src .glob (f "**/stm32{ lower } { nx } _ *.c" )
240+ # Search stm32yyxx_[hal|ll|utils?]*.c or stm32_utils?_ *.c file
241+ filelist = src .glob ("**/stm32*.c" )
243242 for fp in filelist :
243+ is_series_in_fn = fp .name .startswith (f"stm32{ lower } { nx } _" )
244244 legacy = fp .parent .name == "Legacy"
245245 # File name
246246 fn = fp .name
@@ -258,26 +258,37 @@ def wrap(arg_core, arg_cmsis, log):
258258 current_list = ll_c_dict .pop (feat )
259259 if current_list [- 1 ][0 ] == lower :
260260 current_list .pop ()
261- current_list .append ((lower , legacy , stm32_dict [series ]))
261+ current_list .append (
262+ (lower , legacy , stm32_dict [series ], is_series_in_fn )
263+ )
262264 ll_c_dict [feat ] = current_list
263265 else :
264- ll_c_dict [feat ].append ((lower , legacy , stm32_dict [series ]))
266+ ll_c_dict [feat ].append (
267+ (lower , legacy , stm32_dict [series ], is_series_in_fn )
268+ )
265269 else :
266- ll_c_dict [feat ] = [(lower , legacy , stm32_dict [series ])]
270+ ll_c_dict [feat ] = [
271+ (lower , legacy , stm32_dict [series ], is_series_in_fn )
272+ ]
267273 else :
268274 if feat in hal_c_dict :
269275 if legacy :
270276 # Change legacy value if exists
271277 current_list = hal_c_dict .pop (feat )
272278 if current_list [- 1 ][0 ] == lower :
273279 current_list .pop ()
274- current_list .append ((lower , legacy , stm32_dict [series ]))
280+ current_list .append (
281+ (lower , legacy , stm32_dict [series ], is_series_in_fn )
282+ )
275283 hal_c_dict [feat ] = current_list
276284 else :
277- hal_c_dict [feat ].append ((lower , legacy , stm32_dict [series ]))
285+ hal_c_dict [feat ].append (
286+ (lower , legacy , stm32_dict [series ], is_series_in_fn )
287+ )
278288 else :
279- hal_c_dict [feat ] = [(lower , legacy , stm32_dict [series ])]
280-
289+ hal_c_dict [feat ] = [
290+ (lower , legacy , stm32_dict [series ], is_series_in_fn )
291+ ]
281292 # Search stm32yyxx_ll_*.h file
282293 filelist = inc .glob (f"stm32{ lower } { nx } _ll_*.h" )
283294 for fp in filelist :
@@ -294,33 +305,26 @@ def wrap(arg_core, arg_cmsis, log):
294305 else :
295306 ll_h_dict [feature ] = [(lower , stm32_dict [series ])]
296307 # Search stm32yyxx_util_.*.h file
297- filelist = inc .glob (f"stm32{ lower } { nx } _util_*.h" )
298- for fp in filelist :
299- # File name
300- fn = fp .name
301- found = feat_util_h_regex .match (fn )
302- if not found :
303- continue
304- feature = found .group (1 )
305- # Add to util_h_dict to generate a header file for it
306- if feature in util_h_dict :
307- util_h_dict [feature ].append ((lower , stm32_dict [series ], False ))
308- else :
309- util_h_dict [feature ] = [(lower , stm32_dict [series ], False )]
310- # Search stm32yyxx_util_.*.h file
311- filelist = inc .glob (f"stm32_utils_*.h" )
308+ filelist = list (inc .glob ("stm32*_util_*.h" ))
309+ filelist += list (inc .glob ("stm32*_utils_*.h" ))
312310 for fp in filelist :
313311 # File name
314312 fn = fp .name
315313 found = feat_utils_h_regex .match (fn )
314+ is_series_in_fn = fp .name .startswith (f"stm32{ lower } { nx } _" )
316315 if not found :
317316 continue
318317 feature = found .group (1 )
319- # Add to util_h_dict to generate a header file for it
320- if feature in util_h_dict :
321- util_h_dict [feature ].append ((lower , stm32_dict [series ], True ))
318+ utils = "_utils_" in fn
319+ # Add to utils_h_dict to generate a header file for it
320+ if feature in utils_h_dict :
321+ utils_h_dict [feature ].append (
322+ (lower , stm32_dict [series ], is_series_in_fn , utils )
323+ )
322324 else :
323- util_h_dict [feature ] = [(lower , stm32_dict [series ], True )]
325+ utils_h_dict [feature ] = [
326+ (lower , stm32_dict [series ], is_series_in_fn , utils )
327+ ]
324328
325329 # Generate stm32yyxx_hal_*.c file
326330 for key , value in hal_c_dict .items ():
@@ -343,11 +347,11 @@ def wrap(arg_core, arg_cmsis, log):
343347 out_file .write (ll_h_file_template .render (feat = key , serieslist = value ))
344348 if log :
345349 print ("done" )
346- # Generate stm32yyxx_util_ *.h file
347- for key , value in util_h_dict .items ():
348- filepath = SrcWrapper_path / "inc" / f"stm32yyxx_util_ { key } .h"
350+ # Generate stm32yyxx_utils_ *.h file
351+ for key , value in utils_h_dict .items ():
352+ filepath = SrcWrapper_path / "inc" / f"stm32yyxx_utils_ { key } .h"
349353 with open (filepath , "w" , newline = "\n " ) as out_file :
350- out_file .write (util_h_file_template .render (feat = key , serieslist = value ))
354+ out_file .write (utils_h_file_template .render (feat = key , serieslist = value ))
351355 # Filter all LL header file
352356 all_ll_h_list = sorted (set (all_ll_h_list ))
353357 # Generate the all LL header file
0 commit comments