Files
STM32F4-Base/App/task/README.md
T
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

40 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# App/task/ — FreeRTOS 任务实现
> 6 个任务的入口函数与任务体。任务创建在 `Src/freertos.c`(`MX_FREERTOS_Init`),
> **栈大小/优先级的唯一事实源也是 `Src/freertos.c`**;本目录只放任务**实现**。
## 任务清单
| 文件 | 任务 | 优先级 | 职责 |
|---|---|---|---|
| `default_task.c/h` | defaultTask | Normal | FTL + FatFS 挂载、配置引擎属主、syslog 唯一写者、LED 指示 |
| `net_task.c/h` | netTask | Normal | `net_stack_bring_up` → 置 NET_READY → 循环 `net_poll` + `net_process_messages` |
| `ui_task.c/h` | uiTask | BelowNormal | LVGL 界面(菜单 / 内容页 / 待机)+ 推流 |
| `adc_task.c/h` | adcTask | AboveNormal | ADC 采集消费:TPAFE5160 快照 + 消费 STM32 ADC1 DMA 乒乓缓冲一帧,经 [`../algo/adc_input.c`](../algo/README.md) **按语义**取数(采样节拍由 TIM3 硬件触发) |
| `rs485_task.c/h` | (RS-485 任务) | — | 半双工 RS-485 协议通信 |
| `../sync/time_sync.c` | timeSyncTask | Normal | 墙钟时间同步(实现不在本目录,见 [`../sync/README.md`](../sync/README.md)) |
> 上表栈大小/优先级以 `Src/freertos.c` 为准(`README.md` 的任务表由
> `scripts/gen_task_table.py` 生成,勿手抄)。
## 就绪屏障(重要)
任务间**不用魔法延时**,改用 `App/app/sys_events.h` 的 Event Flags:
- `SYS_EVT_NET_READY` / `SYS_EVT_STORAGE_READY` 等是**状态位**——等待时必须
`osFlagsWaitAny|osFlagsNoClear`,**不能用默认消费型等待**(否则先到的消费者会清掉位,
导致 `ftpTask` 的 `WaitAll(两位)` 永不成立 → FTP 静默不监听)
- `SYS_EVT_CFG_SAVE` / `SYS_EVT_NET_RECONFIG` 等**命令位**保持消费型等待
## 平台约束(改本目录前必读)
- **内核启动前禁止任何 FreeRTOS/CMSIS-RTOS API 调用**(`osMessageQueueNew` 等会杀死启动)
- 就绪屏障位一律用 `osFlagsNoClear`
- 内存预算紧张,改栈/缓冲前先核算(`docs/内存管理/`)
## 相关文档
- 启动顺序与屏障:`docs/架构设计/项目启动顺序管理.md`
- 内存与定栈规则:`docs/内存管理/RAM使用分析与优化方案.md`
- 栈水位实测:`scripts/stack_report.py`