[FLYWOOF411] add board documentation
[inav/snaewe.git] / src / main / sensors / gyro.h
blob39e04c848004422ba0ee41ee1c2d1b61e9200816
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/maths.h"
22 #include "common/vector.h"
23 #include "common/time.h"
24 #include "config/parameter_group.h"
25 #include "drivers/sensor.h"
27 typedef enum {
28 GYRO_NONE = 0,
29 GYRO_AUTODETECT,
30 GYRO_MPU6050,
31 GYRO_L3G4200D,
32 GYRO_MPU3050,
33 GYRO_L3GD20,
34 GYRO_MPU6000,
35 GYRO_MPU6500,
36 GYRO_MPU9250,
37 GYRO_BMI160,
38 GYRO_ICM20689,
39 GYRO_FAKE
40 } gyroSensor_e;
42 typedef enum {
43 DYN_NOTCH_RANGE_HIGH = 0,
44 DYN_NOTCH_RANGE_MEDIUM,
45 DYN_NOTCH_RANGE_LOW
46 } dynamicFilterRange_e;
48 #define DYN_NOTCH_RANGE_HZ_HIGH 2000
49 #define DYN_NOTCH_RANGE_HZ_MEDIUM 1333
50 #define DYN_NOTCH_RANGE_HZ_LOW 1000
52 typedef struct gyro_s {
53 bool initialized;
54 uint32_t targetLooptime;
55 float gyroADCf[XYZ_AXIS_COUNT];
56 } gyro_t;
58 extern gyro_t gyro;
60 typedef struct gyroConfig_s {
61 sensor_align_e gyro_align; // gyro alignment
62 uint8_t gyroMovementCalibrationThreshold; // people keep forgetting that moving model while init results in wrong gyro offsets. and then they never reset gyro. so this is now on by default.
63 uint8_t gyroSync; // Enable interrupt based loop
64 uint16_t looptime; // imu loop time in us
65 uint8_t gyro_lpf; // gyro LPF setting - values are driver specific, in case of invalid number, a reasonable default ~30-40HZ is chosen.
66 uint8_t gyro_soft_lpf_hz;
67 uint8_t gyro_soft_lpf_type;
68 uint8_t gyro_to_use;
69 uint16_t gyro_notch_hz;
70 uint16_t gyro_notch_cutoff;
71 uint16_t gyro_stage2_lowpass_hz;
72 uint8_t gyro_stage2_lowpass_type;
73 uint8_t dynamicGyroNotchRange;
74 uint16_t dynamicGyroNotchQ;
75 uint16_t dynamicGyroNotchMinHz;
76 uint8_t dynamicGyroNotchEnabled;
77 uint16_t kalman_q;
78 uint16_t kalman_w;
79 uint16_t kalman_sharpness;
80 uint8_t kalmanEnabled;
81 } gyroConfig_t;
83 PG_DECLARE(gyroConfig_t, gyroConfig);
85 bool gyroInit(void);
86 void gyroGetMeasuredRotationRate(fpVector3_t *imuMeasuredRotationBF);
87 void gyroUpdate(void);
88 void gyroStartCalibration(void);
89 bool gyroIsCalibrationComplete(void);
90 bool gyroReadTemperature(void);
91 int16_t gyroGetTemperature(void);
92 int16_t gyroRateDps(int axis);
93 bool gyroSyncCheckUpdate(void);