Files
STM32F4-Base/test/host/time_sync/stub/cmsis_os2.h
T
wandering1 a2f5d1397a 主机单测:新增卷锁与时间同步两套用例(33+80 项)并登记钩子
- vol_lock(App/fs/vol_lock.c):33 用例。核心不变量是 fail-open——
  互斥量创建失败时 vol_lock_wait() 必须返回 1 且绝不阻塞,因为调用者
  defaultTask 是看门狗喂狗点;板端该路径只在内存耗尽时才可能走到。
- time_sync(App/sync/time_sync.c):80 用例。本模块是 N-17 看门狗风险的
  全部逻辑贡献者,用例钉死分片喂狗节奏、监听退避、报文重组(半包/粘连/
  EOF/真错/预算耗尽/tick 回绕)、重听门控;用 longjmp 跳出 for(;;) 任务循环。
- 两套均为纯逻辑主机侧测试,MSVC 离线编译真实源文件(#include 纳入)。
- 新增钩子 vol-lock-unit-test、time-sync-unit-test(7f/7g)。
- 全量主机单测:watchdog 39 + sys_clock 100 + cfg_file 149 + phasor 57
  + adc_input 70 + vol_lock 33 + time_sync 80 = 528 项,全绿。
2026-10-10 18:03:31 +08:00

60 lines
1.8 KiB
C
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.
/*
* 主机侧单测桩:cmsis_os2.h
* 模块功能:为 App/sync/time_sync.c(经 sys_events.h)提供主机可编译的 CMSIS-RTOS v2
* 事件标志接口与类型。
*
* ⚠ 仅供 test/host/time_sync/ 使用,不参与 MCU 构建。
* 真实头在 Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/,会拖入整套
* FreeRTOS + CMSIS 内核对象,主机侧不引入。
*
* 保真点(对齐 cmsis_os2.h):
* - osEventFlagsId_t = void*(:195)、osMutexId_t = void*(:198);
* - osStatus_t 枚举含 osOK = 0;
* - 标志位 osFlagsWaitAny=0 / osFlagsNoClear=0x2 / osFlagsError=0x80000000
* / osFlagsErrorTimeout=0xFFFFFFFE(:153~164);
* - uint32_t osEventFlagsWait(id, flags, options, timeout)(:539)。
* osEventFlagsWait 由测试单元给强符号桩(可注入"未就绪/超时"并驱动屏障循环)。
*
* 创建日期:2026-10-10
*/
#ifndef CMSIS_OS2_H
#define CMSIS_OS2_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* 不透明句柄 */
typedef void *osEventFlagsId_t;
typedef void *osMutexId_t;
/* 状态码(只保留被测代码用到的子集) */
typedef enum {
osOK = 0,
osError = -1,
osErrorTimeout = -2,
osErrorResource = -3,
osErrorParameter = -4
} osStatus_t;
/* 事件标志选项(cmsis_os2.h:153~164) */
#define osFlagsWaitAny 0x00000000U
#define osFlagsWaitAll 0x00000001U
#define osFlagsNoClear 0x00000002U
#define osFlagsError 0x80000000U
#define osFlagsErrorUnknown 0xFFFFFFFFU
#define osFlagsErrorTimeout 0xFFFFFFFEU
#define osFlagsErrorResource 0xFFFFFFFDU
#define osFlagsErrorParameter 0xFFFFFFFCU
uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);
#ifdef __cplusplus
}
#endif
#endif /* CMSIS_OS2_H */