4、主程序
int main(void)
{
short Accel[3];
short Gyro[3];
float Temp;
SysTick_Init();
SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk;
USART_Config();
i2c_GPIO_Config();
MPU6050_Init();
//检测MPU6050
if (MPU6050ReadID() == 1)
{
while(1)
{
if(Task_Delay[0]==TASK_ENABLE)
{
Task_Delay[0]=1000;
}
if(Task_Delay[1]==0)
{
MPU6050ReadAcc(Accel);
printf("\加速度 %8d%8d%8d ",Accel[0],Accel[1],Accel[2]);
MPU6050ReadGyro(Gyro);
printf("陀螺仪 %8d%8d%8d ",Gyro[0],Gyro[1],Gyro[2]);
MPU6050_ReturnTemp(&Temp);
printf("温度 %8.2f",Temp);
Task_Delay[1]=500;//更新数据的频率
}
}
}
}
|