Added external magnetometer functionality

Dependencies:   HMC58X31 MODI2C MPU6050 MS561101BA

Dependents:   Quadcopter_mk2

Fork of FreeIMU by Yifei Teng

Revision:
9:a79af1283446
Parent:
8:cd43764b9623
Child:
13:21b275eeeda2
--- a/FreeIMU.cpp	Mon Dec 23 09:41:27 2013 +0000
+++ b/FreeIMU.cpp	Fri Jan 10 05:41:40 2014 +0000
@@ -45,8 +45,8 @@
     twoKp = twoKpDef;
     twoKi = twoKiDef;
     
-    twoKiz = twoKiDef / 6.0;
-    twoKpz = twoKpDef * 8.0;
+    twoKiz = twoKiDef / 4.0;
+    twoKpz = twoKpDef * 6.0;
     
     integralFBx = 0.0f,  integralFBy = 0.0f, integralFBz = 0.0f;
 
@@ -246,7 +246,7 @@
 */
 void FreeIMU::zeroGyro()
 {
-    const int totSamples = 8;
+    const int totSamples = 64;
     int16_t raw[11];
     float tmpOffsets[] = {0,0,0};
 
@@ -255,7 +255,7 @@
         tmpOffsets[0] += raw[3];
         tmpOffsets[1] += raw[4];
         tmpOffsets[2] += raw[5];
-        Thread::wait(2);
+        Thread::wait(3);
     }
 
     gyro_off_x = tmpOffsets[0] / totSamples;
@@ -263,7 +263,7 @@
     gyro_off_z = tmpOffsets[2] / totSamples;
 }
 
-extern bool magn_valid;
+extern volatile bool magn_valid;
 
 /**
  * Quaternion implementation of the 'DCM filter' [Mayhony et al].  Incorporates the magnetic distortion