Merge pull request #10558 from iNavFlight/MrD_Correct-comments-on-OSD-symbols
[inav.git] / src / main / sensors / compass.h
blobc6dd78f7db5ed183a08ec0892e234ccc10851213
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include "common/axis.h"
21 #include "common/time.h"
23 #include "config/parameter_group.h"
25 #include "drivers/compass/compass.h"
27 #include "sensors/sensors.h"
29 // Type of magnetometer used/detected
30 typedef enum {
31 MAG_NONE = 0,
32 MAG_AUTODETECT,
33 MAG_HMC5883,
34 MAG_AK8975,
35 MAG_MAG3110,
36 MAG_AK8963,
37 MAG_IST8310,
38 MAG_QMC5883,
39 MAG_MPU9250,
40 MAG_IST8308,
41 MAG_LIS3MDL,
42 MAG_MSP,
43 MAG_RM3100,
44 MAG_VCM5883,
45 MAG_MLX90393,
46 MAG_FAKE,
47 MAG_MAX = MAG_FAKE
48 } magSensor_e;
50 typedef struct mag_s {
51 magDev_t dev;
52 float magADC[XYZ_AXIS_COUNT];
53 } mag_t;
55 extern mag_t mag;
57 #ifdef USE_MAG
59 typedef struct compassConfig_s {
60 int16_t mag_declination; // Get your magnetic declination from here : http://magnetic-declination.com/
61 // For example, -6deg 37min, = -637 Japan, format is [sign]dddmm (degreesminutes) default is zero.
62 sensor_align_e mag_align; // on-board mag alignment. Ignored if externally aligned via *DeciDegrees.
63 uint8_t mag_hardware; // Which mag hardware to use on boards with more than one device
64 flightDynamicsTrims_t magZero;
65 int16_t magGain[XYZ_AXIS_COUNT];
66 #ifdef USE_DUAL_MAG
67 uint8_t mag_to_use;
68 #endif
69 uint8_t magCalibrationTimeLimit; // Time for compass calibration (seconds)
70 int16_t rollDeciDegrees; // Alignment for external mag on the roll (X) axis (0.1deg)
71 int16_t pitchDeciDegrees; // Alignment for external mag on the pitch (Y) axis (0.1deg)
72 int16_t yawDeciDegrees; // Alignment for external mag on the yaw (Z) axis (0.1deg)
73 } compassConfig_t;
75 PG_DECLARE(compassConfig_t, compassConfig);
77 bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse);
78 bool compassInit(void);
79 void compassUpdate(timeUs_t currentTimeUs);
80 bool compassIsReady(void);
81 bool compassIsHealthy(void);
82 bool compassIsCalibrationComplete(void);
84 #endif