Files
STM32F4-Base/App/util
wandering1 2b466b85f0 feat(ui): add DI/DO status page showing 8 inputs and 4 outputs
New read-only content page under 实时数据 → 开入开出 showing the board's
8 opto inputs (DI_A..DI_H, 合/分) and 4 relay outputs (KO6/TRIP/ERT/CLZ,
吸合/释放) as a 12-row list, 8 rows per page, 2 pages.

Data path reuses the existing de-bounced input poll instead of adding a
second hardware reader:

  defaultTask (50 ms) → ioboard_di_snap_publish() → de-bounced snapshot
    → ioboard_di_snap_lookup()  [new registration channel]
    → ui_data_feed_tick() (uiTask, 200 ms)
    → ui_data_rt_t.dio_di_* / dio_do_*

No new critical sections, no new hardware access on the UI path. Outputs
come from the volatile shadow register (a memory read, no lock).

Semantic honesty, recorded in ui_page_di_do.c and README §6:
  · Output state is the software shadow register (ODR mirror), NOT a
    mechanical contact feedback — this platform has no auxiliary contact
    readback path. ioboard_do_read_level() also reads ODR, so comparing
    the two is tautological.
  · IOBOARD_DO_LEVEL_ACTIVE polarity has not been checked against the
    schematic.
  · Input bit order has not been verified by manual shorting. The
    2026-11-16 run read 0x00 eight times because the operator had no time
    to short each channel — the data path itself was fine.
  · Board-level inputs are deliberately kept out of the 33-point telemetry
    bitmap (IEC 104 point-table semantics); the two have no mapping.

Invalid snapshots render "--", never 合/分 or 吸合/释放: painting "no data"
as "all inputs released" would tell the field the inputs are open when we
simply failed to read them.

Board-verified 2026-11-16: page 1 shows 分 on all 8 inputs, page 2 shows
释放 on all 4 outputs, page footer and paging correct. Input bit order
still pending manual shorting.

Also: regenerate ui_font_cn_12 for 吸/释, add golden references for both
pages, align check_menu_rows.py L2 geometry with the now-4-item submenu,
and register the new source file in both the Keil project and CMake.

Reviewed independently; zero blocking findings.
2026-11-16 21:45:08 +08:00
..

App/util/ — 通用工具函数

平台无关的纯工具模块(无 FreeRTOS 依赖、无硬件依赖),可在 MCU 与 PC 模拟器中共用。

文件一览

文件 作用
sys_clock.c/h 墙钟时间管理:RTC 基准、tick 回绕防护、每 30 天惰性再基准化
task_watchdog.c/h 独立看门狗(IWDG)判定状态机:任务心跳位图 + defaultTask 单一喂狗者

已删除(2026-10-02):crc.c/h(CRC-16 Modbus / CRC-8)与 ringbuf.c/h(SPSC 环形缓冲) 两模块零调用者且未编入任何构建——CRC 从未被链接使用:名义上的关联点 net_cfg_legacy.c (旧档迁移,该文件亦已于 2026-10-10 删除)自带静态 s_crc16_modbus(), 从不调用本模块;环形缓冲由 App/log/console_log.c 内联实现(s_con_ring)。 保留只会造成"有统一实现"的误导,故整体移除。

设计要点

sys_clock

  • 以 SD2506 RTC 为基准,HAL tick 计数补齐亚秒精度
  • 49.7 天 tick 回绕防护:每 30 天惰性再基准化(sys_clock_get 内部触发)
  • RTC 故障时降级到默认时间基准并返回 -1,触发"时钟芯片异常"自检上报
  • 设计详见 docs/子系统设计/系统墙钟时间维护说明.md

task_watchdog

  • 任务心跳位图:各任务只置位(task_wd_beat),校验者取走并清零(单字原子,无锁)
  • 单一喂狗者:defaultTask 每 100 ms 抽样判定,仅当位图等于必需掩码时才喂狗
  • 硬件访问收敛:IWDG 寄存器与 HAL_GetTick() 经 wd_platform_* 弱钩子访问 (声明在 task_watchdog.h 末段),MCU 端为 __weak 默认实现,主机侧单测以同名强符号覆盖 → 可在 PC 上跑纯逻辑回归
  • 设计详见 docs/子系统设计/看门狗设计说明.md;单测见 docs/测试说明/单元测试/看门狗单元测试说明.md

相关文档

  • docs/子系统设计/系统墙钟时间维护说明.md
  • docs/子系统设计/看门狗设计说明.md
  • docs/测试说明/单元测试/看门狗单元测试说明.md