First doc writeup

This commit is contained in:
2026-06-05 00:11:55 +02:00
parent 6f0009cfbb
commit 0ea7b83bea
4 changed files with 190 additions and 44 deletions

View File

@@ -1,20 +1,27 @@
# NeoECU Firmware Coding Guidelines
## Naming Conventions
Functions : camelCase
Variables : python_case
Constants : UPPER_CASE
Macros : UPPER_CASE
Types : python_case_t
These rules apply to the `CM7` engine-control firmware.
## Performance Standard
Don't use heap at all if possible avoid mallocs at all cost.
Don't make heavy computation in ISR delegate everything to a task that you'll wake.
Don't copy big chunks of memory, use pointers if you need to read a buffer, even if simply passing the buffer as a parameter compiles it will have huge overhead.
## Style
## Readability Standard
Avoid more than one layer of pointer indirection if possible.
Don't use void* they are unclear and make mistakes more likely.
Avoid magic numbers and indexes, use macros and constants to define them clearly.
Define all macros in macros.h and all global variables and constants in glocal_state.h.
Use one c file per feature, avoid big monoliths that become hard to jump around.
- Functions: `camelCase`
- Variables: `python_case`
- Constants and macros: `UPPER_CASE`
- Types: `python_case_t`
## Real-Time Code
- Do not allocate from the heap in the engine-control path.
- Prefer static task, buffer, and control-structure allocation.
- Keep ISRs short: capture data, update the minimum state, wake a task, return.
- Keep heavy validation, filtering, and scheduling logic in task context.
- Avoid avoidable copies, indirection, and generic `void *` plumbing.
## Structure
- Keep one source file per feature or subsystem where practical.
- Put shared engine state in `global_state.h`.
- Put shared helper macros in `macros.h`.
- Prefer explicit state machines over implicit control flow.
- Make ISR-to-task ownership obvious from names and file placement.
- Use named constants and enums instead of magic numbers.