Files
STM32F4-Base/Src
wandering1 e4981aa2f6 refactor(docs): point entry-file references at their new homes
AGENTS.md stopped being the store of record for build steps, Python env,
hardware pins, doc conventions, log cost and task ownership. Those facts
already live in docs, skills and role files; the entry file now only
points at them. This commit moves every reference that used to name the
entry file to the authoritative landing point, so a reader who follows a
link arrives at the fact instead of at a sentence that no longer exists.

What changed is links and prose, not behaviour. Code, scripts and tests
only have comment and docstring lines touched; the only non-comment edit
in the whole changeset is one note string inside the generated pin table
JSON, and its generator was changed in the same step so the two stay
byte-identical.

New landing points created before the references were retargeted:
- The console single-writer log design doc, section 7.1, is now the single
  authority for log cost: about 90 B flash and 216 B stack per DBG_ line,
  and the rule that deep call chains must predefine DBG_LINE_BUF_MAX.
  It also carries the full list of the twelve translation units that have
  tightened it, plus the grep command that decides the truth if the list
  and the code ever disagree.
- The document writing standard, section 2, now holds the BOM list.
- keil-build skill gains an exit code table: 0 success, 1 build failure,
  2 BuildEnvError, 3 usage, 4 build lock held. This corrects a belief
  that was never actually written down anywhere: exit 2 does not simply
  mean environment error, argparse also exits 2 and the wrapper script
  was remapped so the two no longer collide.

Regenerated and checked byte for byte:
- The end-to-end architecture SVG in docs/images from its generator.
- tools/netlist_semantics/pinout_kb.json from gen_kb.py.
Both are idempotent; running the generators again produces no diff.

Deliberately not touched, because machines read them:
- scripts/check_bom_drift.py joins every line containing BOM and asserts
  four paths are present, so the entry file BOM line must stay one line.
- scripts/gen_task_table.py reads the TASK_TABLE anchors directly.
- scripts/rename_maps and scripts/archive keep their historical wording;
  they describe what happened, not what is true now.

Verified: doc links report the same six pre-existing findings as the base
commit and no new ones, generated-fresh passes, bom drift is clean across
101 files, and AGENTS.md itself is unchanged in this commit.
2026-11-16 19:38:27 +08:00
..
2026-07-19 13:09:06 +08:00

Src/ — CubeMX 生成的源文件

⚠️ 本目录文件由 STM32CubeMX 生成(.ioc 重生成会覆盖),不是自研代码。 但允许在 USER CODE BEGIN/END 标记区之间写自定义代码。

文件一览

文件 生成 作用
main.c CubeMX 程序入口:HAL_Init → SystemClock_Config → 外设初始化 → app_main_init → osKernelStart
freertos.c CubeMX FreeRTOS 任务创建(MX_FREERTOS_Init)+ 任务栈/优先级定义
gpio.c / dma.c / spi.c / i2c.c / usart.c CubeMX 各外设 MX_xxx_Init
stm32f4xx_hal_msp.c CubeMX HAL 外设底层初始化(时钟使能、NVIC、引脚复用)
stm32f4xx_hal_timebase_tim.c 自研覆盖 HAL 时基改用 TIM7(非 SysTick),tick = 1ms
stm32f4xx_it.c CubeMX 中断服务函数(ISR)
system_stm32f4xx.c CMSIS 系统时钟初始化(SystemInit)

⚠️ 修改约定(铁律)

  • 自定义代码只写 USER CODE BEGIN xxx / USER CODE END xxx 标记区之间—— 标记区外的内容在 CubeMX 重新生成时会被无条件覆盖丢失
  • 本目录被 pre-commit 的 C 代码规范检查排除(因是生成代码,风格不受控)
  • Drivers/BSP/ 才是纯手工代码区;应用逻辑放 App/

关键点

  • HAL 时基 = TIM7,不是 SysTick;FreeRTOS 用 SysTick 之外的方式,tick = 1ms
  • NVIC 4 位优先级分组;外设中断优先级 ≥ 5(0~4 预留给 FreeRTOS)
  • 时钟:HSE 8MHz → PLL M=4/N=168/P=2 → 168MHz

相关文档

  • 架构全景:docs/架构设计/项目架构总览.md
  • 启动顺序:docs/架构设计/项目启动顺序管理.md
  • 任务表(唯一事实源 = freertos.c):根 README.md