用SPI协议读mpu9250时,发现别人的程序上读取数据时只用了这个函数 MPU9250_ReadRegs(MPU6500_ACCEL_XOUT_H, ReadBuf, 14);
但是这只读到陀螺仪寄存器,并没有读磁力计AK8963,void IMU_Read( void )
{
u8 ReadBuf[24] = {0};
MPU9250_Read(ReadBuf);
Acc.X = (s16)Byte16(ReadBuf[0], ReadBuf[1]); // Acc_X
Acc.Y = (s16)Byte16(ReadBuf[2], ReadBuf[3]); // Acc_Y
Acc.Z = (s16)Byte16(ReadBuf[4], ReadBuf[5]); // Acc_Z
Gyr.X = (s16)Byte16(ReadBuf[8], ReadBuf[9]); // Gyr_X
Gyr.Y = (s16)Byte16(ReadBuf[10], ReadBuf[11]); // Gyr_Y
Gyr.Z = (s16)Byte16(ReadBuf[12], ReadBuf[13]); // Gyr_Z
Mag.X = (s16)Byte16(ReadBuf[15], ReadBuf[14]); // Mag_X
Mag.Y = (s16)Byte16(ReadBuf[17], ReadBuf[16]); // Mag_Y
Mag.Z = (s16)Byte16(ReadBuf[19], ReadBuf[18]); // Mag_Z
// Temp = (s16)Byte16(ReadBuf[6], ReadBuf[7]); // Temp
Acc.TrueX = Acc.X* MPU9250A_4g; // g/LSB
Acc.TrueY = Acc.Y* MPU9250A_4g; // g/LSB
Acc.TrueZ = Acc.Z* MPU9250A_4g; // g/LSB
Gyr.TrueX = Gyr.X* MPU9250G_2000dps; // dps/LSB
Gyr.TrueY = Gyr.Y* MPU9250G_2000dps; // dps/LSB
Gyr.TrueZ = Gyr.Z* MPU9250G_2000dps; // dps/LSB
Mag.TrueX = Mag.X* MPU9250M_4800uT; // uT/LSB
Mag.TrueY = Mag.Y* MPU9250M_4800uT; // uT/LSB
Mag.TrueZ = Mag.Z* MPU9250M_4800uT; // uT/LSB
}
而在计算时计算了磁力计,而且mpu6500与AK8963寄存器地址是重叠的,怎么区分; |