我正在使用 Atmel Studio 6.2,芯片 xmega64D3,并且在初始化结构的某些字段时遇到问题:
typedef struct
{
uint32_t val;
uint32_t inv;
uint32_t xor;
}SPROTU32;
typedef struct
{
SPROTU32 SerialNr;
SPROTU32 SwVersion;
SPROTU32 HwVersion;
SPROTU32 ProdCode;
SPROTU32 ProdDate;
SPROTU32 PartNum;
}BasicData;
#define sw_high 02
#define sw_low 12
#define sw_ver ((sw_high << 16) + sw_low)
#define hw_high 01
#define hw_low 06
#define hw_ver ((hw_high << 16) + hw_low)
#define DEFAULT_SERIAL 0
#define DEFAULT_SW_VERSION sw_ver
#define DEFAULT_HW_VERSION hw_ver
#define DEFAULT_PROD_CODE 0
#define DEFAULT_PROD_DATE 0
#define DEFAULT_PART_NUM 05545410
EEMEM BasicData eeBasicData =
{
{DEFAULT_SERIAL,~DEFAULT_SERIAL,DEFAULT_SERIAL^0x55555555},
{DEFAULT_SW_VERSION,~DEFAULT_SW_VERSION,DEFAULT_SW_VERSION^0x55555555},
{DEFAULT_HW_VERSION,~DEFAULT_HW_VERSION,DEFAULT_HW_VERSION^0x55555555},
{DEFAULT_PROD_CODE,~DEFAULT_PROD_CODE,DEFAULT_PROD_CODE^0x55555555},
{DEFAULT_PROD_DATE,~DEFAULT_PROD_DATE,DEFAULT_PROD_DATE^0x55555555},
{DEFAULT_PART_NUM,~DEFAULT_PART_NUM,DEFAULT_PART_NUM^0x55555555}
};
编译器总是说初始化器不是恒定的。那么,我该怎么做才能用我想要的东西来初始化我的结构呢?