下面这种错误出现了好多~~~求大虾
r_cg_MPU6050.h(49) : CC78K0R error E0301: Syntax error
r_cg_MPU6050.h(51) : CC78K0R error E0323: Missing ','r_cg_MPU6050.h(51) : CC78K0R error E0301: Syntax error
r_cg_MPU6050.h(52) : CC78K0R error E0323: Missing ','
r_cg_MPU6050.h(52) : CC78K0R error E0301: Syntax error
void delay(unsigned int k);
void InitLcd();
void lcd_printf(uchar *s,int temp_data);
void WaitForEnable(void);
void WriteDataLCM(uchar dataW);
void WriteCommandLCM(uchar CMD,uchar Attribc);
void DisplayOneChar(uchar X,uchar Y,uchar DData);
void DisplayListChar(uchar X,uchar Y,uchar *DData,L);
void InitMPU6050(); //???MPU6050
void Delay5us();
void I2C_Start();
void I2C_Stop();
void I2C_SendACK(bit ack);
bit I2C_RecvACK();
void I2C_SendByte(uchar dat);
uchar I2C_RecvByte();
void I2C_ReadPage();
void I2C_WritePage();
uchar Single_ReadI2C(uchar REG_Address); //??I2C??
void Single_WriteI2C(uchar REG_Address,uchar REG_data);
void MMPU();
void lcd_printf(uchar *s,int temp_data)
{
if(temp_data<0)
{
temp_data=-temp_data;
*s='-';
}
else *s=' ';
*++s =temp_data/100+0x30;
temp_data=temp_data%100; //????
*++s =temp_data/10+0x30;
temp_data=temp_data%10; //????
*++s =temp_data+0x30;
}
//****************************************
//??
//****************************************
void delay(unsigned int k)
{
unsigned int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<121;j++);
}
}
//****************************************
//LCD1602???
//****************************************
void InitLcd()
{
WriteCommandLCM(0x38,1);
WriteCommandLCM(0x08,1);
WriteCommandLCM(0x01,1);
WriteCommandLCM(0x06,1);
WriteCommandLCM(0x0c,1);
DisplayOneChar(0,0,'A');
DisplayOneChar(0,1,'G');
}
void WaitForEnable(void)
{
DataPort=0Xff;
LCM_RS=0;LCM_RW=1;NOP();NOP();NOP();
LCM_EN=1;NOP();NOP();NOP();NOP();NOP();NOP();NOP();
while(DataPort&0x80);
LCM_EN=0;
}
void WriteCommandLCM(uchar CMD,uchar Attribc)
{
if(Attribc)WaitForEnable();
LCM_RS=0;LCM_RW=0;NOP();NOP();NOP();
DataPort=CMD;NOP();NOP();NOP();
LCM_EN=1;NOP();NOP();NOP();NOP();NOP();NOP();
LCM_EN=0;
}
//****************************************
//LCD1602????
//****************************************
void WriteDataLCM(uchar dataW)
{
WaitForEnable();
LCM_RS=1;LCM_RW=0;NOP();NOP();
DataPort=dataW;NOP();NOP();NOP();
LCM_EN=1;NOP();NOP();NOP();NOP();NOP();NOP();LCM_EN=0;
}
//****************************************
//LCD1602??????
//****************************************
void DisplayOneChar(uchar X,uchar Y,uchar DData)
{
Y&=1;
X&=15;
if(Y)X|=0x40;
X|=0x80;
WriteCommandLCM(X,0);
WriteDataLCM(DData);
}
//****************************************
//LCD1602?????
//****************************************
void DisplayListChar(uchar X,uchar Y,uchar *DData,L)
{
uchar ListLength=0;
Y&=0x1;
X&=0xF;
while(L--)
{
DisplayOneChar(X,Y,DData[ListLength]);
ListLength++;
X++;
}
}
//**************************************
void Delay5us()
{
delay(1);
}
//**************************************
//I2C????
//**************************************
void I2C_Start()
{
SSDA = 1; //?????
SSCL = 1; //?????
Delay5us(); //??
SSDA = 0; //?????
Delay5us(); //??
SSCL = 0; //?????
}
//**************************************
//I2C????
//**************************************
void I2C_Stop()
{
SSDA = 0; //?????
SSCL = 1; //?????
Delay5us(); //??
SSDA = 1; //?????
Delay5us(); //??
}
//**************************************
//I2C??????
//????:ack (0:ACK 1:NAK)
//**************************************
void I2C_SendACK(bit ack)
{
SSDA = ack; //?????
SSCL = 1; //?????
Delay5us(); //??
SSCL = 0; //?????
Delay5us(); //??
}
//**************************************
//I2C??????
//**************************************
bit I2C_RecvACK()
{
SSCL = 1; //?????
Delay5us(); //??
CY = SDA; //?????
SSCL = 0; //?????
Delay5us(); //??
return CY;
}
//**************************************
//?I2C??????????
//**************************************
void I2C_SendByte(uchar dat)
{
uchar i;
for (i=0; i<8; i++) //8????
{
dat <<= 1; //????????
SSDA = CY; //????
SSCL = 1; //?????
Delay5us(); //??
SSCL = 0; //?????
Delay5us(); //??
}
I2C_RecvACK();
}
//**************************************
//?I2C??????????
//**************************************
uchar I2C_RecvByte()
{
uchar i;
uchar dat = 0;
SSDA = 1; //??????,??????,
for (i=0; i<8; i++) //8????
{
dat <<= 1;
SSCL = 1; //?????
Delay5us(); //??
dat |= SDA; //???
SSCL = 0; //?????
Delay5us(); //??
}
return dat;
}
//**************************************
//?I2C??????????
//**************************************
void Single_WriteI2C(uchar REG_Address,uchar REG_data)
{
I2C_Start(); //????
I2C_SendByte(SlaveAddress); //??????+???
I2C_SendByte(REG_Address); //???????,
I2C_SendByte(REG_data); //???????,
I2C_Stop(); //??????
}
//**************************************
//?I2C??????????
//**************************************
uchar Single_ReadI2C(uchar REG_Address)
{
uchar REG_data;
I2C_Start(); //????
I2C_SendByte(SlaveAddress); //??????+???
I2C_SendByte(REG_Address); //????????,?0??
I2C_Start(); //????
I2C_SendByte(SlaveAddress+1); //??????+???
REG_data=I2C_RecvByte(); //???????
I2C_SendACK(1); //??????
I2C_Stop(); //????
return REG_data;
}
//**************************************
//???MPU6050
//**************************************
void InitMPU6050()
{
Single_WriteI2C(PWR_MGMT_1, 0x00); //??????
Single_WriteI2C(SMPLRT_DIV, 0x07);
Single_WriteI2C(CONFIG, 0x06);
Single_WriteI2C(GYRO_CONFIG, 0x18);
Single_WriteI2C(ACCEL_CONFIG, 0x01);
}
//**************************************
//????
//**************************************
int GetData(uchar REG_Address)
{
char H,L;
H=Single_ReadI2C(REG_Address);
L=Single_ReadI2C(REG_Address+1);
return (H<<8)+L; //????
}
//**************************************
//?1602???10???
//**************************************
void Display10BitData(int value,uchar x,uchar y)
{
value/=64; //???10???
lcd_printf(dis, value); //??????
DisplayListChar(x,y,dis,4); //???,?,????,????
}
//*********************************************************
void MMPU(void)
{
delay(500); //????
InitLcd(); //?????
InitMPU6050(); //???MPU6050
delay(150);
while(1)
{
Display10BitData(GetData(ACCEL_XOUT_H),2,0); //??X????
Display10BitData(GetData(ACCEL_YOUT_H),7,0); //??Y????
Display10BitData(GetData(ACCEL_ZOUT_H),12,0); //??Z????
Display10BitData(GetData(GYRO_XOUT_H),2,1); //??X????
Display10BitData(GetData(GYRO_YOUT_H),7,1); //??Y????
Display10BitData(GetData(GYRO_ZOUT_H),12,1); //??Z????
delay(500);
}
}