/*====================================================================================================*/ void MPU9250_getData( int16_t *dataIMU ) { uint8_t tmpRead[22] = {0}; #ifdef _USE_MAG_AK8963 MPU9250_ReadRegs(MPU6500_ACCEL_XOUT_H, tmpRead, 22); #else MPU9250_ReadRegs(MPU6500_ACCEL_XOUT_H, tmpRead, 14); #endif dataIMU[0] = (Byte16(int16_t, tmpRead[6], tmpRead[7])); // Temp dataIMU[1] = (Byte16(int16_t, tmpRead[0], tmpRead[1])); // Acc.X dataIMU[2] = (Byte16(int16_t, tmpRead[2], tmpRead[3])); // Acc.Y dataIMU[3] = (Byte16(int16_t, tmpRead[4], tmpRead[5])); // Acc.Z dataIMU[4] = (Byte16(int16_t, tmpRead[8], tmpRead[9])); // Gyr.X dataIMU[5] = (Byte16(int16_t, tmpRead[10], tmpRead[11])); // Gyr.Y dataIMU[6] = (Byte16(int16_t, tmpRead[12], tmpRead[13])); // Gyr.Z #ifdef _USE_MAG_AK8963 if(!(tmpRead[14] & AK8963_STATUS_DRDY) || (tmpRead[14] & AK8963_STATUS_DOR) || (tmpRead[21] & AK8963_STATUS_HOFL)) return; dataIMU[7] = (Byte16(int16_t, tmpRead[16], tmpRead[15])); // Mag.X dataIMU[8] = (Byte16(int16_t, tmpRead[18], tmpRead[17])); // Mag.Y dataIMU[9] = (Byte16(int16_t, tmpRead[20], tmpRead[19])); // Mag.Z #endif }
/*====================================================================================================*/ void IMU_getData( IMU_DataTypeDef *pIMU ) { uint8_t tmpRead[22] = {0}; if((pIMU->MPU_GyrAcc_Enable == MPU_GyrAcc_ENABLE) && (pIMU->MPU_Mag_Enable == MPU_Mag_ENABLE)) { MPU9250_ReadRegs(MPU6500_ACCEL_XOUT_H, tmpRead, 22); // Read Gyr, Acc, Mag } else if(pIMU->MPU_GyrAcc_Enable == MPU_GyrAcc_ENABLE) { MPU9250_ReadRegs(MPU6500_ACCEL_XOUT_H, tmpRead, 14); // Read Gyr, Acc } else if(pIMU->MPU_Mag_Enable == MPU_Mag_ENABLE) { MPU9250_ReadRegs(MPU6500_EXT_SENS_DATA_00, tmpRead + 14, 8); // Read Mag } if(pIMU->MPU_GyrAcc_Enable == MPU_GyrAcc_ENABLE) { pIMU->Gyr[0] = (Byte16(int16_t, tmpRead[8], tmpRead[9])); // Gyr.X pIMU->Gyr[1] = (Byte16(int16_t, tmpRead[10], tmpRead[11])); // Gyr.Y pIMU->Gyr[2] = (Byte16(int16_t, tmpRead[12], tmpRead[13])); // Gyr.Z pIMU->Acc[0] = (Byte16(int16_t, tmpRead[0], tmpRead[1])); // Acc.X pIMU->Acc[1] = (Byte16(int16_t, tmpRead[2], tmpRead[3])); // Acc.Y pIMU->Acc[2] = (Byte16(int16_t, tmpRead[4], tmpRead[5])); // Acc.Z pIMU->ICTemp = (Byte16(int16_t, tmpRead[6], tmpRead[7])); // Temp } if(pIMU->MPU_Mag_Enable == MPU_Mag_ENABLE) { if(!(!(tmpRead[14] & AK8963_STATUS_DRDY) || (tmpRead[14] & AK8963_STATUS_DOR) || (tmpRead[21] & AK8963_STATUS_HOFL))) { pIMU->Mag[0] = (Byte16(int16_t, tmpRead[16], tmpRead[15])); // Mag.X pIMU->Mag[1] = (Byte16(int16_t, tmpRead[18], tmpRead[17])); // Mag.Y pIMU->Mag[2] = (Byte16(int16_t, tmpRead[20], tmpRead[19])); // Mag.Z } } if(pIMU->LPS_PresTemp_Enable == LPS_PresTemp_ENABLE) { // LPS25H_ReadReg(LPS25H_WHO_AM_I, ); } }
/*====================================================================================================*/ void MPU9250_Read( u8 *ReadBuf ) { MPU9250_ReadRegs(MPU6500_ACCEL_XOUT_H, ReadBuf, 14); }
/** * @brief MPU9250_Read * @note MPU9250 Read Sensors' Values * @param None * @retval None */ void MPU9250_Read( uint8_t *ReadBuf ) { MPU9250_ReadRegs(MPU6500_ACCEL_XOUT_H, ReadBuf, BYTES_TO_READ); }