10323c4c22
Bench verification of the IO board needs an observation window: production build has no consumer of ioboard_di_snap_read(), so the DI values were invisible. Add TEST_SUITE_IOBOARD as a semi-automatic bench sequence and fix two real bugs found while wiring it in. New files: - test/board/ioboard_test.h, test/board/ioboard_test_task.c Test suite: - Owns its own thread (iobTest, 4096 words) instead of running in testTask: testTask is osPriorityBelowNormal, below defaultTask whose 1ms console drain loop can starve a blocking wait in a lower priority context. - Phases: bit-order self-check, DI eight-point bijection, DO point-by-point toggle with operator confirmation, release-all on every exit path. - Only exit is ioboard_release_all(); it is called from the entry guard, every phase failure, the write-failure branch and the thread tail. - Sample window is 20 reads x 2ms = 40ms and does overlap the 50ms production poll. That is stated as harmless in the header: the driver wraps the whole read in taskENTER_CRITICAL (26us, not the whole 40ms), both sides only read, and a torn cross-reader sample is caught by the debounce layer rather than acted upon. default_task.c fix: - DEFAULT_TASK_DI_PUBLISH_EN was defined twice: once at file scope and once inside default_task_func(). #define has no scope, so the second was a redefinition of the first. Collapsed to a single authoritative site. - Add TEST_SUITE_STORAGE to the disable list: the STORAGE suite owns the file system via testTask, and default_task_di_poll() referenced four statics that live inside an !TEST_SUITE_STORAGE block, which broke the STORAGE build with 11 errors. - Shrink the !TEST_SUITE_STORAGE block to cover only default_task_net_cfg_save_notify() and move the three declarations out; move edges/fails into the #else branch so the empty branch references none of the four statics. Registration and gates: - MDK-ARM/STM32F407-Demo.uvprojx and simulator/CMakeLists.txt entries. - scripts/check_test_suite.py: whitelist TEST_SUITE_IOBOARD. - scripts/stack_report.py: let a self-started thread that is not declared in Src/freertos.c osThreadAttr_t still be budget checked. - test/run_all_suites.py: bring the suite into the orchestrator view. Verified: six-build matrix all 0 errors 0 warnings. CH395F/STORAGE/GD5F/RTC and the product build are bit-identical at Code=257936; the IOBOARD build is Code=264640 (+6704), which is the evidence that the suite really enters the image. Host unit tests 100/100, stack report 1760/4096 words (57%).
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 按语义取数(采样节拍由 TIM3 硬件触发) |
rs485_task.c/h |
(RS-485 任务) | — | 半双工 RS-485 协议通信 |
../sync/time_sync.c |
timeSyncTask | Normal | 墙钟时间同步(实现不在本目录,见 ../sync/README.md) |
上表栈大小/优先级以
Src/freertos.c为准(README.md/AGENTS.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