Rule
0 installs · 0 said it worked
Embedded STM32 HAL firmware coding rules for Cursor
Cursor rule file guiding AI-written embedded C/C++ for STM32 MCUs covering project structure, HAL usage, interrupts, memory and timing limits, hardware-focused testing, and common mistakes.
People use this for
- stm32 hal firmware rules
- embedded c coding guidelines
- microcontroller interrupt handling best practices
- write stm32 hal code safely
- generate embedded firmware with interrupts and dma
- Name
embedded-stm32-hal-firmware-coding-rules-for-cursor- Works with
- Cursor
- License
- CC0(as observed at the source)
- Version
- v1 · updated Nov 29, 2026
Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.
Are you the author?Claim this profileRequest removal
Use this rule
$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/embedded-stm32-hal-firmware-coding-rules-for-cursor-qumt/export/mdc" -o .cursor/rules/embedded-stm32-hal-firmware-coding-rules-for-cursor.mdcThen open a new session; Cursor picks it up from .cursor/rules/.
Manual install
Save embedded-stm32-hal-firmware-coding-rules-for-cursor.mdc as .cursor/rules/embedded-stm32-hal-firmware-coding-rules-for-cursor.mdc for this project or ~/.cursor/rules/embedded-stm32-hal-firmware-coding-rules-for-cursor.mdc for every project, then start a new session.
Rule
description: Embedded C/C++ rules for MCU, STM32, HAL, interrupts, DMA, memory constraints, and hardware-focused testing globs: ["/*.c", "/.h", "**/.cpp", "/*.hpp", "/*.ioc", "CMakeLists.txt", "Makefile", "platformio.ini"] alwaysApply: false
Embedded MCU, STM32, and HAL Rules
Project Structure
- Keep board support, drivers, middleware, application logic, and tests separate.
- Isolate generated CubeMX or vendor code from hand-written application code.
- Put hardware abstraction behind narrow interfaces so logic can be tested without hardware.
- Document clock tree, pin mappings, peripheral ownership, and interrupt priorities.
STM32 HAL and Peripherals
- Initialize peripherals in one place and avoid hidden reconfiguration.
- Check return values from HAL calls and handle timeout/error cases.
- Keep blocking HAL calls out of time-critical paths.
- Use DMA for high-throughput UART, SPI, I2C, ADC, or timer capture paths when appropriate.
- Document buffer ownership and lifetime for DMA operations.
- Use
volatileonly for memory shared with ISRs or hardware registers.
Interrupts and Concurrency
- Keep ISRs short and deterministic.
- Defer heavy work from interrupts to the main loop, RTOS task, or event queue.
- Protect shared data with critical sections, atomics, queues, or RTOS primitives.
- Avoid dynamic allocation in interrupts.
- Make interrupt priority decisions explicit.
Memory and Timing
- Avoid heap allocation in firmware unless the project explicitly allows it.
- Check stack usage for ISRs and RTOS tasks.
- Keep lookup tables
constso they can live in flash. - Use fixed-width integer types for hardware-facing code.
- Add timeouts for hardware waits.
- Treat watchdog configuration as part of application design, not a late add-on.
Testing and Debugging
- Unit test pure logic on host builds.
- Use hardware-in-the-loop tests for peripheral behavior.
- Add assertions for impossible hardware states in debug builds.
- Use SWD/JTAG, logic analyzers, and serial logs with rate limits.
- Keep fault handlers useful: capture reset reason, fault registers, and build version when possible.
Common Mistakes
- Do not modify generated files unless the workflow preserves changes.
- Do not busy-wait forever on hardware flags.
- Do not share buffers between DMA and CPU without synchronization.
- Do not assume peripheral reset state after low-power modes.
No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.
Tried it
Reports from people who added this rule to their editor. They roll up into the badges above.
No one has filed a report yet. Try the prompt and be the first.
Related rules
- Kubernetes container requests and limits rightsizing assistant
System-style skill that turns per-container CPU and memory usage percentiles into safer Kubernetes requests and limits, flags OOM, throttling and eviction risks first, estimates freed capacity, and plans a staged rollout via manifest patches.
Coding · @f
- Quality engineering agent role for risk-based test strategy and CI quality gates
A senior quality engineering role prompt that guides an assistant through risk-based test strategy, test automation architecture, CI/CD quality gates, edge-case analysis, and defect management, writing results to a TODO checklist file.
Coding · @wkaandemir
- Autonomous coding agent that builds a verified app-builder harness
Master system prompt that directs an autonomous senior Python engineer to build a spec-driven, evidence-traced app-builder harness milestone by milestone without asking questions.
Coding · @mahfuzahmedog
- Agent that writes, runs, and repairs tests after code changes
A system prompt defining a test-writer-fixer agent that writes unit, integration, and end-to-end tests, runs suites, analyzes failures, and repairs tests without weakening them.
Coding · @ersinyilmaz
- Flaky Test Detector: separate flaky CI tests from real failures
Agent skill that reads repeated CI run results (JUnit XML or CSV history), flags tests that pass and fail without code changes, ranks them by flip and failure rate, and recommends targeted fixes or quarantine plans instead of retries.
Coding · @f
License: CC0v1 · published Nov 29, 2026
Comments
No comments yet. If you tried this prompt, say how it went.