Files
STM32F4-Base/App
wandering1 cc7f17f231 fix(dwt): stop resetting CYCCNT, a counter six modules share
Three of the six DWT CYCCNT users wrote the counter to zero on init:
console_log, net_latency_test and ch395f_reuse_bench. Every one of them
only ever takes the difference (CYCCNT - t0) against a local snapshot, so
the reset bought nothing and instead caused a bogus ~2^32 delta for
anyone who sampled across it. That delta trips the task_prof glitch guard
(TASK_PROF_GLITCH_CYC = 10 s worth of cycles), which discards the sample,
so a whole worst-case measurement could vanish silently.

All three call sites now leave the counter alone; the shared contract is
"enable only, never reset", documented at each of the six users. The
documented behaviour in the link latency test guide (section 4.3) is
updated to match.

Net source change is three deleted lines, no new executable code.

Verification:
- grep for a zero assignment to CYCCNT across the tree: no hits left.
- Keil build: Code=257932 RO-data=32108 RW-data=2104 ZI-data=152688,
  0 errors 0 warnings.
- Host unit tests: console_log 153/153, task_prof 27/27, ioboard 100/100,
  sb_link 164/164.
- Four console_log assertions pinned the absolute number of DWT register
  touches; dropping the reset write lowers it by one, so their expected
  counts move from 3 to 2 (and 4 to 3 for TC-CONLOG-093). The test text
  now says why the third write disappeared.
- check_doc_links: 6 known issues, unchanged from baseline.
2026-11-16 19:58:44 +08:00
..

App/ — 应用层

自研代码(非 CubeMX 生成、非第三方库)。本目录是项目的应用层:任务编排、业务逻辑、 日志与配置引擎、工具函数。所有文件遵循 docs/代码规范/嵌入式C语言代码规范_V1.0.md。

职责

Src/main.c(CubeMX 初始化)→ app_main_init(本目录 app/app_main.c)→ osKernelStart → 6 个 FreeRTOS 任务(见 task/)。osKernelStart 之前全是内核启动前代码,禁止调用任何 FreeRTOS/CMSIS-RTOS API(本条与「就绪屏障位必须 osFlagsNoClear」的理由 → docs/子系统设计/控制台单写者日志设计.md §2.5 与 docs/架构设计/项目启动顺序管理.md)。

目录结构(按职责分层)

目录 内容 README
app/ 应用入口与全局:app_main.c/h(初始化入口)、app_cfg.h(裁剪决策占位说明,当前无宏)、sys_events.h(就绪事件) app/README.md
cfg/ 配置引擎:/config.ini 解析 + 原子持久化(旧二进制档已废弃,2026-10-10) cfg/README.md
sync/ 时间同步任务:time_sync.c/h sync/README.md
algo/ 采集与算法层:语义取数 + 有效性判定 + 采样环/相量/测频 + 定值模型 + 保护元件框架 algo/README.md(索引);设计 → docs/算法/采集与算法层设计说明.md
log/ 日志子系统:syslog(NAND)+ 控制台单写者日志 log/README.md
task/ FreeRTOS 任务实现(6 个任务) task/README.md
util/ 通用工具:CRC / 环形缓冲 / 墙钟时间 util/README.md
protocol/ 通信协议(预留,当前为空) protocol/README.md

关键约束

  • 配置引擎单任务收敛:cfg/ 为静态态、属主是 defaultTask;UI 保存请求经 SYS_EVT_CFG_SAVE 事件唤醒,netTask/uiTask 不得直接触碰配置引擎
  • syslog 唯一写者:/log/* 只由 defaultTask 写入
  • 新增任务/缓冲/栈前必须先核算 RAM 余量(docs/内存管理/)

相关文档

  • 架构全景:docs/架构设计/项目架构总览.md
  • 启动顺序:docs/架构设计/项目启动顺序管理.md
  • 配置引擎:docs/子系统设计/配置文件设计.md
  • 日志:docs/子系统设计/控制台单写者日志设计.md、docs/子系统设计/运行与自检记录设计.md