u8 MPU9250_Init(void){ u8 res=0; IIC_Init(); MPU_Write_Byte(MPU9250_ADDR,MPU_PWR_MGMT1_REG,0X80);delay_ms(100); MPU_Write_Byte(MPU9250_ADDR,MPU_PWR_MGMT1_REG,0X00); MPU_Set_Gyro_Fsr(3); MPU_Set_Accel_Fsr(0); MPU_Set_Rate(50); MPU_Write_Byte(MPU9250_ADDR,MPU_INT_EN_REG,0X00); MPU_Write_Byte(MPU9250_ADDR,MPU_USER_CTRL_REG,0X00); MPU_Write_Byte(MPU9250_ADDR,MPU_INTBP_CFG_REG,0X80); MPU_Write_Byte(MPU9250_ADDR,MPU_DEVICE_ID_REG,0x06); res=MPU_Read_Byte(MPU9250_ADDR,MPU_DEVICE_ID_REG); if(res==MPU6500_ID) { MPU_Write_Byte(MPU9250_ADDR,MPU_PWR_MGMT1_REG,0X01); MPU_Write_Byte(MPU9250_ADDR,MPU_PWR_MGMT2_REG,0X00); MPU_Set_Rate(50); } elsereturn 1; return 0;}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>