Skip to content

Commit 972949b

Browse files
committed
[ext] Add STM32 Low-Level Library as module
1 parent bb42736 commit 972949b

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@
4949
[submodule "ext/nlohmann/json"]
5050
path = ext/nlohmann/json
5151
url = https://github.com/modm-ext/json-partial.git
52+
[submodule "ext/st/cube-hal"]
53+
path = ext/st/cube-hal
54+
url = https://github.com/modm-ext/stm32-cube-hal-drivers.git
File renamed without changes.

ext/st/cube-hal

Submodule cube-hal added at 12ab4b0

ext/st/ll.lb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2025, Niklas Hauser
5+
#
6+
# This file is part of the modm project.
7+
#
8+
# This Source Code Form is subject to the terms of the Mozilla Public
9+
# License, v. 2.0. If a copy of the MPL was not distributed with this
10+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
11+
# -----------------------------------------------------------------------------
12+
13+
import re
14+
from pathlib import Path
15+
16+
class Header(Module):
17+
def __init__(self, header):
18+
self.name = header.stem.split("_ll_")[1]
19+
self.header = header
20+
21+
def init(self, module):
22+
module.name = self.name
23+
module.description = self.name.replace("_", " ").upper()
24+
25+
def prepare(self, module, options):
26+
return True
27+
28+
def build(self, env):
29+
env.outbasepath = "modm/ext/st/ll"
30+
env.copy(self.header, f"{self.name}.h")
31+
32+
33+
def init(module):
34+
module.name = ":cmsis:ll"
35+
module.description = "STM32 Low-Level (LL) Library"
36+
37+
38+
def prepare(module, options):
39+
target = options[":target"].identifier
40+
if target.platform != "stm32":
41+
return False
42+
43+
folder = f"stm32{target.family}xx"
44+
for header in Path(localpath(f"cube-hal/{folder}/Inc")).glob("*_ll_*.h"):
45+
module.add_submodule(Header(header))
46+
47+
module.depends(":cmsis:device")
48+
return True
49+
50+
51+
def build(env):
52+
pass

0 commit comments

Comments
 (0)