College Project

Dependents:   MPU9250_SPI_Test_1201

Revision:
10:d27b3298e9e0
Parent:
9:a8733542d0fb
Child:
11:084e8ba240c1
--- a/MPU9250.cpp	Tue Jul 01 10:58:36 2014 +0000
+++ b/MPU9250.cpp	Tue Jul 01 11:09:17 2014 +0000
@@ -88,7 +88,7 @@
     
     //set_acc_scale(2);
     //set_gyro_scale(250);
-    Magnetometer_divider=2;
+    Magnetometer_Sensitivity_Scale_Factor=0.6;
     
     return 0;
 }
@@ -314,9 +314,9 @@
     ReadRegs(MPUREG_EXT_SENS_DATA_00,response,7);
     //must start your read from AK8963A register 0x03 and read seven bytes so that upon read of ST2 register 0x09 the AK8963A will unlatch the data registers for the next measurement.
     for(i=0; i<3; i++) {
-        bit_data=((int16_t)response[i*2]<<8)|response[i*2+1];
+        bit_data=((int16_t)response[i*2+1]<<8)|response[i*2];
         data=(float)bit_data;
-        Magnetometer[i]=data/Magnetometer_divider;
+        Magnetometer[i]=data*Magnetometer_Sensitivity_Scale_Factor;
     }
 }
 void mpu9250_spi::read_all(){
@@ -351,9 +351,9 @@
     }
     //Get Magnetometer value
     for(i=7; i<10; i++) {
-        bit_data=((int16_t)response[i*2]<<8)|response[i*2+1];
+        bit_data=((int16_t)response[i*2+1]<<8)|response[i*2];
         data=(float)bit_data;
-        Magnetometer[i-7]=data/Magnetometer_divider;
+        Magnetometer[i-7]=data*Magnetometer_Sensitivity_Scale_Factor;
     }
 }