初级会员

- 积分
- 144
- 金钱
- 144
- 注册时间
- 2017-12-14
- 在线时间
- 51 小时
|

楼主 |
发表于 2018-8-19 11:02:38
|
显示全部楼层
void Mpu9250_Init(void)
{
int result=0;
u8 ID[1];
do
{
i2cRead(0x69,0x75,1,ID);
printf("%x\r\n",ID[0]);
}while(ID[0]!=0x71);
printf("mpu通信正常");
if(!result) //返回0代表初始化成功
{
printf("mpu initialization complete......\r\n ");
//mpu_set_sensor
if(!mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL))
{
printf("mpu_set_sensor complete ......\r\n");
}
else
{
printf("mpu_set_sensor come across error ......\r\n");
}
//mpu_configure_fifo
if(!mpu_configure_fifo(INV_XYZ_GYRO | INV_XYZ_ACCEL))
{
printf("mpu_configure_fifo complete ......\r\n");
}
else
{
printf("mpu_configure_fifo come across error ......\r\n");
}
//mpu_set_sample_rate
if(!mpu_set_sample_rate(DEFAULT_MPU_HZ))
{
printf("mpu_set_sample_rate complete ......\r\n");
}
else
{
printf("mpu_set_sample_rate error ......\r\n");
}
//dmp_load_motion_driver_firmvare
if(!dmp_load_motion_driver_firmware())
{
printf("dmp_load_motion_driver_firmware complete ......\r\n");
}
else
{
printf("dmp_load_motion_driver_firmware come across error ......\r\n");
}
//dmp_set_orientation
if(!dmp_set_orientation(inv_orientation_matrix_to_scalar(gyro_orientation)))
{
printf("dmp_set_orientation complete ......\r\n");
}
else
{
printf("dmp_set_orientation come across error ......\r\n");
}
//dmp_enable_feature
if(!dmp_enable_feature(DMP_FEATURE_6X_LP_QUAT | DMP_FEATURE_TAP |
DMP_FEATURE_ANDROID_ORIENT | DMP_FEATURE_SEND_RAW_ACCEL | DMP_FEATURE_SEND_CAL_GYRO |
DMP_FEATURE_GYRO_CAL))
{
printf("dmp_enable_feature complete ......\r\n");
}
else
{
printf("dmp_enable_feature come across error ......\r\n");
}
//dmp_set_fifo_rate
if(!dmp_set_fifo_rate(DEFAULT_MPU_HZ))
{
printf("dmp_set_fifo_rate complete ......\r\n");
}
else
{
printf("dmp_set_fifo_rate come across error ......\r\n");
}
//不开自检,以水平作为零度
//开启自检以当前位置作为零度
//run_self_test();
if(!mpu_set_dmp_state(1))
{
printf("mpu_set_dmp_state complete ......\r\n");
}
else
{
printf("mpu_set_dmp_state come across error ......\r\n");
}
}else
{
printf("mpu初始化失败\r\n");
}
}
这是我的初始化代码 |
|