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/>.
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"
43 DYN_NOTCH_RANGE_HIGH
= 0,
44 DYN_NOTCH_RANGE_MEDIUM
,
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
{
54 uint32_t targetLooptime
;
55 float gyroADCf
[XYZ_AXIS_COUNT
];
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
;
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
;
79 uint16_t kalman_sharpness
;
80 uint8_t kalmanEnabled
;
83 PG_DECLARE(gyroConfig_t
, gyroConfig
);
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);