在codewarrior中怎样使用自定义类型和结构
- UID
- 111199
- 性别
- 男
|
在codewarrior中怎样使用自定义类型和结构
CANBUS 电液控制汽车电子,希望和大家交朋友!
http://www.51mcu.cn |
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
|
|
|
|
|
- UID
- 147911
- 性别
- 男
|
自定义类型和结构是类似于移植嵌入式操作系统中的那样么?
例如
typedef unsigned char BOOLEAN;
typedef unsigned char INT8U;
吗? |
|
|
|
|
|
- UID
- 111199
- 性别
- 男
|
头文件看的不是太明白,能否举个例子,我是这样用的但总是不行:
typedef struct aaa{
unsigned char enable;
unsigned int in;
unsigned int upper;
unsigned int lowper;
unsigned int zero;
unsigned int dead;
};
//typedef TIMAGE* PIMAGE ;
aaa *p
int sensor(*p);
{
static unsigned int in1,in2,in3,in4,in5;
volatile int out;
volatile float invar,E;
if(aaa.enable & 1)
{
//in5 = in4;in4 =in3;in3 = in2;in2 =in1;in1 = in;
invar = p.in;//(in1+in2+in3+in4+in5)/5.0;
E = invar - (float)pp.zero;
if (fabsf(E) > (float)aaa.dead)
{
if(E > 0.0)
{
out = (E - (float)aaa.dead)*32767.0/((float)(aaa.upper-aaa.zero-aaa.dead));
}
else
{
out = (E + (float)aaa.dead)*32767.0/((float)(aaa.zero-aaa.lowper-aaa.dead));
}
}
else
{
out = 0;
}
}
else
{
out = 0;
}
return out;
} |
CANBUS 电液控制汽车电子,希望和大家交朋友!
http://www.51mcu.cn |
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
改成这样试试:
typedef struct {
unsigned char enable;
unsigned int in;
unsigned int upper;
unsigned int lowper;
unsigned int zero;
unsigned int dead;
} aaa;
|
|
|
|
|
|