|
STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
|
Conventions and workflow for stm32_rtos. The reasons behind them are in Design notes.
A layer includes headers only from itself and the layers below it (see the layer diagram). drivers/ never includes board/; app/ includes only the peripheral and RTOS APIs once they exist. If code needs to reach two layers down, the layer in between is missing something; add it there.
A new layer directory goes in the Makefile's SRC_DIRS (and INC_DIRS for its inc/), the Doxyfile's INPUT, and scripts/check_pr_files.sh.
Include headers by bare name (#include "rcc_reg.h"). Every inc/ directory is on the include path. Never use a root-relative path.
| Kind | Convention | Example |
|---|---|---|
| Struct | Name_t, tag equal to typedef | typedef struct GpioRegisters_t {...} GpioRegisters_t; |
| Enum | Name_e | DriverStatus_e |
| Function | camelCase, module prefix | rccPllConfig() |
| Macro | SCREAMING_SNAKE_CASE | RCC_CR_HSEON |
| Register field | <PERIPH>_<REG>_<FIELD>, plus _Pos/_Msk | RCC_CFGR_SW_Msk |
| Register header | <peripheral>_reg.h in arch/cortex-m4/inc/ (core) or soc/stm32f446/inc/ (chip) | gpio_reg.h |
| Include guard | #ifndef FOO_H ... #endif /* FOO_H */ |
Register bit and mask macros cast before shifting, ((uint32_t)1U << n) (see MISRA deviations).
See Register blocks as parameters, Error contract and const register parameters.
make docs fails on any warning, including a missing @param. Each new file starts with a @file block. Without one Doxygen does not check the file at all, and CI rejects the pull request.
Functions
Header content
Text
Grouping
Register headers
## Tests
Every .c in a code layer has a test_<name>.c in the matching tests/unit/<layer>/ folder (arch/, soc/, drivers/, board/), and every register header is included by a test.
## Workflow
One-time setup: make hooks. The pre-commit hook then runs format-check, test, lint, docs, all and smoke on the working tree (not just what is staged).
| Command | Use | | ----------------------— | -------------------------------------------------------— | | make format | Apply .clang-format. Never hand-format. | | make lint | cppcheck + MISRA. Run scripts/install_cppcheck.sh once for CI's version. | | make test SANITIZE=1 | The suite under ASan and UBSan, as CI runs it. | | make coverage | 100% line and branch gate (CI only, not the hook). | | make all ANALYZE=1 | GCC's static analyzer (CI only, not the hook). | | make spell | codespell; add a real word to .codespellrc with a reason. | | make check-pr | CI's pull-request file checks, against BASE (default origin/develop). |
The full command list is in the README.
## CI
ci.yml runs on every pull request and on pushes to main and develop. It can also be started by hand from the Actions tab. Nothing runs on a schedule.
Pull requests start from .github/pull_request_template.md. CI's pinned tools are bumped by hand (see SECURITY.md).
The trust boundaries for each workflow are described in SECURITY.md.
## Branches and pull requests