Files
STM32F4-Base/App/cfg/README.md
T

29 lines
1.5 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/cfg/ — 配置引擎
> **`/config.ini` 配置引擎**:分层解析、持久化(原子写)、旧档迁移。
> 属主 = **defaultTask**(单任务收敛,静态态);其它任务不得直接触碰。
## 文件一览
| 文件 | 作用 |
|---|---|
| `cfg_file.c/h` | **配置引擎核心**:解析 / 查询 / 保存 / 2s 周期 `cfg_file_poll` |
| `cfg_file_store.h` | **存储后端抽象接口**(MCU=FreeRTOS 堆 / 模拟器=宿主堆,共享核心零分配符号) |
| `cfg_file_store_mcu.c` | **MCU 端后端实现**:`/config.ini`(`/config.TMP` + `f_rename` 原子写) |
## 设计要点
- **单任务收敛**:`cfg_file` 为静态态,只有 defaultTask 操作;UI 保存请求经
`SYS_EVT_CFG_SAVE` 事件唤醒 defaultTask 执行(netTask/uiTask 不得直接调用)
- **零分配共享核心**:核心逻辑不含任何分配符号,动态内存收进平台后端
(`cfg_store_alloc/free`:MCU→`pvPortMalloc`,模拟器→宿主堆)
- **原子写**:写 `/config.TMP` 后 `f_rename` 替换,避免掉电损坏
- **旧档迁移**:首启时把旧格式转换为当前格式(`net_cfg_legacy.c` 负责网络段)
- **自研代码禁用 C 库堆分配**:MicroLIB 堆仅 512B(`malloc` 必返回 NULL)
## 相关文档
- `docs/子系统设计/配置文件设计说明.md` — 完整设计(分层/解析/持久化/迁移)
- `docs/子系统设计/网络配置说明.md` — 网络段
- `docs/审查记录/项目审计改进清单.md` P3-2 — 临时文件名硬编码问题