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/>.
21 #include "common/axis.h"
22 #include "drivers/sensor.h"
24 #define GYRO_LPF_256HZ 0
25 #define GYRO_LPF_188HZ 1
26 #define GYRO_LPF_98HZ 2
27 #define GYRO_LPF_42HZ 3
28 #define GYRO_LPF_20HZ 4
29 #define GYRO_LPF_10HZ 5
30 #define GYRO_LPF_5HZ 6
31 #define GYRO_LPF_NONE 7
36 uint8_t gyroConfigValues
[2];
37 } gyroFilterAndRateConfig_t
;
39 typedef struct gyroDev_s
{
41 sensorGyroInitFuncPtr initFn
; // initialize function
42 sensorGyroReadFuncPtr readFn
; // read 3 axis data function
43 sensorGyroReadDataFuncPtr temperatureFn
; // read temperature if available
44 sensorGyroInterruptStatusFuncPtr intStatusFn
;
45 sensorGyroUpdateFuncPtr updateFn
;
46 float scale
; // scalefactor
47 float gyroADCRaw
[XYZ_AXIS_COUNT
];
48 float gyroZero
[XYZ_AXIS_COUNT
];
49 uint8_t imuSensorToUse
;
50 uint8_t lpf
; // Configuration value: Hardware LPF setting
51 uint32_t requestedSampleIntervalUs
; // Requested sample interval
52 volatile bool dataReady
;
53 uint32_t sampleRateIntervalUs
; // Gyro driver should set this to actual sampling rate as signaled by IRQ
54 sensor_align_e gyroAlign
;
57 typedef struct accDev_s
{
59 sensorAccInitFuncPtr initFn
; // initialize function
60 sensorAccReadFuncPtr readFn
; // read 3 axis data function
62 float ADCRaw
[XYZ_AXIS_COUNT
];
63 uint8_t imuSensorToUse
;
64 sensor_align_e accAlign
;
67 const gyroFilterAndRateConfig_t
* chooseGyroConfig(uint8_t desiredLpf
, uint16_t desiredRateHz
, const gyroFilterAndRateConfig_t
* configs
, int count
);
68 bool gyroCheckDataReady(struct gyroDev_s
*gyro
);