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 "drivers/exti.h"
22 #include "drivers/sensor.h"
23 #include "drivers/accgyro_mpu.h"
25 #ifndef MPU_I2C_INSTANCE
26 #define MPU_I2C_INSTANCE I2C_DEVICE
29 #define GYRO_LPF_256HZ 0
30 #define GYRO_LPF_188HZ 1
31 #define GYRO_LPF_98HZ 2
32 #define GYRO_LPF_42HZ 3
33 #define GYRO_LPF_20HZ 4
34 #define GYRO_LPF_10HZ 5
35 #define GYRO_LPF_5HZ 6
36 #define GYRO_LPF_NONE 7
45 typedef struct gyroDev_s
{
46 sensorGyroInitFuncPtr init
; // initialize function
47 sensorGyroReadFuncPtr read
; // read 3 axis data function
48 sensorGyroReadDataFuncPtr temperature
; // read temperature if available
49 sensorGyroInterruptStatusFuncPtr intStatus
;
50 sensorGyroUpdateFuncPtr update
;
51 extiCallbackRec_t exti
;
53 float scale
; // scalefactor
54 int16_t gyroADCRaw
[XYZ_AXIS_COUNT
];
55 int32_t gyroZero
[XYZ_AXIS_COUNT
];
56 int32_t gyroADC
[XYZ_AXIS_COUNT
]; // gyro data after calibration and alignment
58 gyroRateKHz_e gyroRateKHz
;
59 uint8_t mpuDividerDrops
;
60 volatile bool dataReady
;
61 sensor_align_e gyroAlign
;
62 mpuDetectionResult_t mpuDetectionResult
;
63 const extiConfig_t
*mpuIntExtiConfig
;
64 mpuConfiguration_t mpuConfiguration
;
67 typedef struct accDev_s
{
68 sensorAccInitFuncPtr init
; // initialize function
69 sensorAccReadFuncPtr read
; // read 3 axis data function
72 int16_t ADCRaw
[XYZ_AXIS_COUNT
];
73 char revisionCode
; // a revision code for the sensor, if known
74 sensor_align_e accAlign
;
75 mpuDetectionResult_t mpuDetectionResult
;
76 mpuConfiguration_t mpuConfiguration
;