Skip to content

Commit

Permalink
[ext] Update STM32 CMSIS Headers
Browse files Browse the repository at this point in the history
Fixes STM32L1 define/header selection
  • Loading branch information
salkinium committed Sep 17, 2020
1 parent 31a2ced commit 81265c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions ext/st/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,18 @@ def getDefineForDevice(device_id, familyDefines):
if len(deviceDefines) == 1:
return deviceDefines[0]

# now we match for the size-id.
# sort with respecting variants
minlen = min(len(d) for d in deviceDefines)
deviceDefines.sort(key=lambda d: (d[:minlen], d[minlen:]))

# now we match for the size-id (and variant-id if applicable).
devNameMatch = devName + "x{}".format(device_id.size.upper())
if device_id.family == "l1":
# Map STM32L1xxQC and STM32L1xxZC -> STM32L162QCxA variants
if device_id.pin in ["q", "z"] and device_id.size == "c":
devNameMatch += "A"
else:
devNameMatch += device_id.variant.upper()
for define in deviceDefines:
if devNameMatch <= define:
return define
Expand Down Expand Up @@ -70,7 +80,7 @@ def common_rcc_map(env):
define = None

content = Path(localpath(folder, family_header)).read_text(encoding="utf-8", errors="replace")
match = re.findall(r"if defined\((?P<define>STM32[F|L|G].....)\)", content)
match = re.findall(r"if defined\((?P<define>STM32[F|L|G][\w\d]+)\)", content)
define = getDefineForDevice(device.identifier, match)
if define is None or match is None:
raise ValidateException("No device define found for '{}'!".format(device.partname))
Expand Down
2 changes: 1 addition & 1 deletion ext/st/stm32
Submodule stm32 updated 100 files

0 comments on commit 81265c6

Please sign in to comment.