An implenentaion of nav-rewrite (squashed commit, November 17th).
[inav.git] / src / main / sensors / sensors.h
blob1741612f520d88d74f767af1927b504f0bfba4f8
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 typedef enum {
21 SENSOR_INDEX_GYRO = 0,
22 SENSOR_INDEX_ACC,
23 SENSOR_INDEX_BARO,
24 SENSOR_INDEX_MAG
25 } sensorIndex_e;
27 #define MAX_SENSORS_TO_DETECT (SENSOR_INDEX_MAG + 1)
29 extern uint8_t detectedSensors[MAX_SENSORS_TO_DETECT];
31 typedef struct int16_flightDynamicsTrims_s {
32 int16_t roll;
33 int16_t pitch;
34 int16_t yaw;
35 } flightDynamicsTrims_def_t;
37 typedef union {
38 int16_t raw[3];
39 flightDynamicsTrims_def_t values;
40 } flightDynamicsTrims_t;
42 #define CALIBRATING_GYRO_CYCLES 1000
43 #define CALIBRATING_ACC_CYCLES 400
44 #define CALIBRATING_BARO_CYCLES 200 // 10 seconds init_delay + 200 * 25 ms = 15 seconds before ground pressure settles
46 typedef enum {
47 SENSOR_GYRO = 1 << 0, // always present
48 SENSOR_ACC = 1 << 1,
49 SENSOR_BARO = 1 << 2,
50 SENSOR_MAG = 1 << 3,
51 SENSOR_SONAR = 1 << 4,
52 SENSOR_GPS = 1 << 5,
53 } sensors_e;
55 typedef enum {
56 ALIGN_DEFAULT = 0, // driver-provided alignment
57 CW0_DEG = 1,
58 CW90_DEG = 2,
59 CW180_DEG = 3,
60 CW270_DEG = 4,
61 CW0_DEG_FLIP = 5,
62 CW90_DEG_FLIP = 6,
63 CW180_DEG_FLIP = 7,
64 CW270_DEG_FLIP = 8
65 } sensor_align_e;
67 typedef struct sensorAlignmentConfig_s {
68 sensor_align_e gyro_align; // gyro alignment
69 sensor_align_e acc_align; // acc alignment
70 sensor_align_e mag_align; // mag alignment
71 } sensorAlignmentConfig_t;