Merge pull request #10558 from iNavFlight/MrD_Correct-comments-on-OSD-symbols
[inav.git] / src / main / drivers / accgyro / accgyro.h
blobc5c18cedb1d76e7e6e4f1b360058fd044adc822a
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 "platform.h"
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
33 typedef struct {
34 uint8_t gyroLpf;
35 uint16_t gyroRateHz;
36 uint8_t gyroConfigValues[2];
37 } gyroFilterAndRateConfig_t;
39 typedef struct gyroDev_s {
40 busDevice_t * busDev;
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;
55 } gyroDev_t;
57 typedef struct accDev_s {
58 busDevice_t * busDev;
59 sensorAccInitFuncPtr initFn; // initialize function
60 sensorAccReadFuncPtr readFn; // read 3 axis data function
61 uint16_t acc_1G;
62 float ADCRaw[XYZ_AXIS_COUNT];
63 uint8_t imuSensorToUse;
64 sensor_align_e accAlign;
65 } accDev_t;
67 const gyroFilterAndRateConfig_t * chooseGyroConfig(uint8_t desiredLpf, uint16_t desiredRateHz, const gyroFilterAndRateConfig_t * configs, int count);
68 bool gyroCheckDataReady(struct gyroDev_s *gyro);