Skip to content

Commit 26bb0c9

Browse files
committed
[ext] Add STM32 Low-Level Library as module
1 parent ab7c1ca commit 26bb0c9

File tree

4 files changed

+57
-0
lines changed

4 files changed

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

0 commit comments

Comments
 (0)