AHRS

Dependencies:   Eigen

Dependents:   IndNav_QK3_T265

Revision:
16:97c12f818b94
Parent:
14:c357be9a3fc8
Child:
25:fe14dbcef82d
--- a/LSM9DS1_i2c.cpp	Wed Sep 18 09:57:53 2019 +0000
+++ b/LSM9DS1_i2c.cpp	Mon Sep 23 09:53:03 2019 +0000
@@ -125,13 +125,13 @@
     // 1 = 1.25 Hz   5 = 20 Hz
     // 2 = 2.5 Hz    6 = 40 Hz
     // 3 = 5 Hz      7 = 80 Hz
-    settings.mag.sampleRate = 4;
-    settings.mag.tempCompensationEnable = false;
+    settings.mag.sampleRate = 7;
+    settings.mag.tempCompensationEnable = true;
     // magPerformance can be any value between 0-3
     // 0 = Low power mode      2 = high performance
     // 1 = medium performance  3 = ultra-high performance
-    settings.mag.XYPerformance = 3;
-    settings.mag.ZPerformance = 3;
+    settings.mag.XYPerformance = 2;
+    settings.mag.ZPerformance = 2;
     settings.mag.lowPowerEnable = false;
     // magOperatingMode can be 0-2
     // 0 = continuous conversion
@@ -386,8 +386,7 @@
     
     for (i=0; i<128; i++)
     {
-        while (!magAvailable())
-            ;
+        while (!magAvailable());
         readMag();
         int16_t magTemp[3] = {0, 0, 0};
         magTemp[0] = mx;        
@@ -434,7 +433,15 @@
     if (settings.mag.tempCompensationEnable) tempRegValue |= (1<<7);
     tempRegValue |= (settings.mag.XYPerformance & 0x3) << 5;
     tempRegValue |= (settings.mag.sampleRate & 0x7) << 2;
-    mWriteByte(CTRL_REG1_M, tempRegValue);
+    // mWriteByte(CTRL_REG1_M, tempRegValue); 
+    // pmic 21.09.2019, settings now static
+    // use 0xC2 for temperature compensation on, Fast ODR -> 300 Hz undocumented mode high performance
+    // use 0x42 for temperature compensation off, Fast ODR -> 300 Hz undocumented mode high performance
+    // use 0xE2 for temperature compensation on, Fast ODR -> 155 Hz undocumented mode ultra high performance
+    // use 0x62 for temperature compensation off, Fast ODR -> 155 Hz undocumented mode ultra high performance
+    // use 0xA2 for temperature compensation on, Fast ODR -> 155 Hz undocumented mode medium performance
+    // use 0x22 for temperature compensation off, Fast ODR -> 155 Hz undocumented mode medium performance
+    mWriteByte(CTRL_REG1_M, 0xC2); 
     
     // CTRL_REG2_M (Default value 0x00)
     // [0][FS1][FS0][0][REBOOT][SOFT_RST][0][0]
@@ -474,7 +481,7 @@
     // [0][0][0][0][OMZ1][OMZ0][BLE][0]
     // OMZ[1:0] - Z-axis operative mode selection
     //  00:low-power mode, 01:medium performance
-    //  10:high performance, 10:ultra-high performance
+    //  10:high performance, 11:ultra-high performance
     // BLE - Big/little endian data
     tempRegValue = 0;
     tempRegValue = (settings.mag.ZPerformance & 0x3) << 2;