//设置一个故障类型结构
typedef struct {
u16 Evevtdev:2;//1—前门故障,2—后门故障,3—测试设备故障
u16 EventSty:1;//1—基本功能测试,0-可靠性测试
u16 EventStyle:5;//错误号
}EventStr;
union ASSEMBLY_EVENT
{
u16 all;
EventStr EventBit;
};
//===============================================================================
//设置一个测试状态结构
typedef struct {
u32 u32_OpenCnt; //开门次数
u32 u32_OpenFullCnt;//开门到位次数
u32 u32_Closecnt;//关门次数
u32 u32_CloseFullCnt;//关门到位次数
u32 u32_Close23cnt;//关门2/3次数
}Tesrstate;
//===============================================================================
//设置一个测试方法结构
typedef struct {
u8 TestStart:1;//1—开始测试,0---停止测试
u8 TestMethod:2;//1—方式一,2-方式二
u8 :5; //保留
u8 OpenTime;//门开齐后延时的时间
u8 closeTime;//门关齐后延时的时间
u16 TestCNT; //测试次数上限
}TestMethodStr;
//===============================================================================
//输出控制命令
typedef struct
{
u16 st1:1; //
u16 st2:1; //bit1
u16 st3:1; //bit2
u16 overhaul:1; //bit3:检修
u16 Rev:1; //bit4:
u16 Dob:1; //bit5:
u16 res:10;//bit6~bit15:保留
}AssemblyTestCMDType;
union ASSEMBLY_TEST_CMD
{
u16 all;
AssemblyTestCMDType bit;
};
//端口输入状态
typedef struct
{
u16 OpenFull:1; //bit0:开门到位---DOL
u16 CloseFull:1; //bit1:关门到位-----DOS
u16 Stall:1; //bit2:堵转
u16 Fault:1; //bit3:故障
u16 res:12; //bit4~bit15:保留
}AssemblyTestInputType;
union ASSEMBLY_TEST_INPUT
{
u16 all;
AssemblyTestInputType bit;
};
typedef struct
{
union ASSEMBLY_EVENT event; //输出 判断状态
union ASSEMBLY_TEST_CMD cmd; //输出 控制命令
union ASSEMBLY_TEST_INPUT input; //输入 控制命令
Tesrstate tesrstate;
TestMethodStr TestMethod[2];
u8 TaskStart;
u16 TestTimeCnt;
u16 Step;
u16 CmdSwTimeCnt;
u16 ControllerNum; //控制器号
u16 DelayCheckTime;
u16 NormalCheckTime;
}ASSEMBLY_TEST_STRUCT;
//===============================================================================
#define ASSEMBLY_TEST_STRUCT_DEFAULTS {\
0,\
0,\
0,\
0,0,0,0,0,\
{{0,0,0,1000,1000,1000},{0,0,0,1000,1000,1000}},\
0,\
0,\
0,\
0,\
0,\
0,\
0,\
}
ASSEMBLY_TEST_STRUCT g_hAssemblyTestVar
我想使用如上的方法定义以一个结构体,但是使用IAR编译总是通不过
错误提示:
Building configuration: STM32100B-EVAL_Demo - STM32100B-EVAL_Demo
Updating build tree...
main.c
Warning[Pe069]: integer conversion resulted in truncation E:\code\开关门命令测试\TTCTL\Project\TTCtl\src\main.c 35
Error[Pe146]: too many initializer values E:\code\开关门命令测试\TTCTL\Project\TTCtl\src\main.c 35
Warning[Pe069]: integer conversion resulted in truncation E:\code\开关门命令测试\TTCTL\Project\TTCtl\src\main.c 35
Error[Pe146]: too many initializer values E:\code\开关门命令测试\TTCTL\Project\TTCtl\src\main.c 35
Error while running C/C++ Compiler
Total number of errors: 2
Total number of warnings: 2
根据提示是
#define ASSEMBLY_TEST_STRUCT_DEFAULTS {\
0,\
0,\
0,\
0,0,0,0,0,\
{{0,0,0,1000,1000,1000},{0,0,0,1000,1000,1000}},\
0,\
0,\
0,\
0,\
0,\
0,\
0,\
}
的初始化值太多,但是我看了看真好的
请大侠帮忙看看咋回事
|
|