modm_data.header2svd
CMSIS Header to SVD Pipeline
class
Header:
10class Header: 11 CMSIS_PATH = root_path("ext/cmsis/header/CMSIS/Core/Include") 12 _CACHE_HEADER = defaultdict(dict) 13 14 def __init__(self, filename, substitutions=None): 15 self.filename = filename 16 self.substitutions = {r"__(IO|IM|I|O)": ""} 17 if substitutions is not None: 18 self.substitutions.update(substitutions) 19 20 @property 21 def _cache(self): 22 return Header._CACHE_HEADER[self.filename] 23 24 @property 25 def header(self): 26 from CppHeaderParser import CppHeader 27 28 if "header" not in self._cache: 29 content = self.filename.read_text(encoding="utf-8-sig", errors="replace") 30 for pattern, subs in self.substitutions.items(): 31 content = re.sub(pattern, subs, content, flags=(re.DOTALL | re.MULTILINE)) 32 self._cache["header"] = CppHeader(content, "string") 33 return self._cache["header"]
CMSIS_PATH =
PosixPath('/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/ext/cmsis/header/CMSIS/Core/Include')
header
24 @property 25 def header(self): 26 from CppHeaderParser import CppHeader 27 28 if "header" not in self._cache: 29 content = self.filename.read_text(encoding="utf-8-sig", errors="replace") 30 for pattern, subs in self.substitutions.items(): 31 content = re.sub(pattern, subs, content, flags=(re.DOTALL | re.MULTILINE)) 32 self._cache["header"] = CppHeader(content, "string") 33 return self._cache["header"]