|
| 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