//mpu6050,dmp初始化
//返回值0正常
// 其他失败
u8 mpu_dmp_init(void)
{
unsigned long int i;
u8 res=0;
IIC_Init(); //初始化I2C总线
for(i=0;i<4000000;i++);
if(mpu_init()==0) //初始化MPU6050
{
res=mpu_set_sensors(INV_XYZ_GYRO|INV_XYZ_ACCEL);//ÉèÖÃËùÐèÒªµÄ´«¸ÐÆ÷
if(res)return 1;
res=mpu_configure_fifo(INV_XYZ_GYRO|INV_XYZ_ACCEL);//ÉèÖÃFIFO
if(res)return 2;
res=mpu_set_sample_rate(DEFAULT_MPU_HZ); //ÉèÖòÉÑùÂÊ
if(res)return 3;
res=dmp_load_motion_driver_firmware(); //¼ÓÔØdmp¹Ì¼þ
if(res)return 4;
res=dmp_set_orientation(inv_orientation_matrix_to_scalar(gyro_orientation));//ÉèÖÃÍÓÂÝÒÇ·½Ïò
if(res)return 5;
res=dmp_enable_feature(DMP_FEATURE_6X_LP_QUAT|DMP_FEATURE_TAP| //ÉèÖÃdmp¹¦ÄÜ
DMP_FEATURE_ANDROID_ORIENT|DMP_FEATURE_SEND_RAW_ACCEL|DMP_FEATURE_SEND_CAL_GYRO|
DMP_FEATURE_GYRO_CAL);
if(res)return 6;
res=dmp_set_fifo_rate(DEFAULT_MPU_HZ); //ÉèÖÃDMPÊä³öËÙÂÊ(×î´ó²»³¬¹ý200Hz)
if(res)return 7;
res=run_self_test(); //自检
if(res)return 8;
res=mpu_set_dmp_state(1); //ʹÄÜDMP
if(res)return 9;
}else return 10;
return 0;
}
我搞MPU6050,无法通过自检。返回值是1.
请高手指教,谢谢!
|