Fix for SITL target
[betaflight.git] / src / main / fc / runtime_config.h
blob6311050c920593864a1e83a3803cf70547ba200d
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 // FIXME some of these are flight modes, some of these are general status indicators
21 typedef enum {
22 OK_TO_ARM = (1 << 0),
23 PREVENT_ARMING = (1 << 1),
24 ARMED = (1 << 2),
25 WAS_EVER_ARMED = (1 << 3)
26 } armingFlag_e;
28 extern uint8_t armingFlags;
30 #define DISABLE_ARMING_FLAG(mask) (armingFlags &= ~(mask))
31 #define ENABLE_ARMING_FLAG(mask) (armingFlags |= (mask))
32 #define ARMING_FLAG(mask) (armingFlags & (mask))
34 typedef enum {
35 ANGLE_MODE = (1 << 0),
36 HORIZON_MODE = (1 << 1),
37 MAG_MODE = (1 << 2),
38 BARO_MODE = (1 << 3),
39 GPS_HOME_MODE = (1 << 4),
40 GPS_HOLD_MODE = (1 << 5),
41 HEADFREE_MODE = (1 << 6),
42 UNUSED_MODE = (1 << 7), // old autotune
43 PASSTHRU_MODE = (1 << 8),
44 SONAR_MODE = (1 << 9),
45 FAILSAFE_MODE = (1 << 10)
46 } flightModeFlags_e;
48 extern uint16_t flightModeFlags;
50 #define DISABLE_FLIGHT_MODE(mask) disableFlightMode(mask)
51 #define ENABLE_FLIGHT_MODE(mask) enableFlightMode(mask)
52 #define FLIGHT_MODE(mask) (flightModeFlags & (mask))
54 // macro to initialize map from flightModeFlags to boxId_e. Keep it in sync with flightModeFlags_e enum.
55 // Each boxId_e is at index of flightModeFlags_e bit, value is -1 if boxId_e does not exist.
56 // It is much more memory efficient than full map (uint32_t -> uint8_t)
57 #define FLIGHT_MODE_BOXID_MAP_INITIALIZER { \
58 BOXANGLE, BOXHORIZON, BOXMAG, BOXBARO, BOXGPSHOME, BOXGPSHOLD, \
59 BOXHEADFREE, -1, BOXPASSTHRU, BOXSONAR, BOXFAILSAFE} \
60 /**/
62 typedef enum {
63 GPS_FIX_HOME = (1 << 0),
64 GPS_FIX = (1 << 1),
65 CALIBRATE_MAG = (1 << 2),
66 SMALL_ANGLE = (1 << 3),
67 FIXED_WING = (1 << 4) // set when in flying_wing or airplane mode. currently used by althold selection code
68 } stateFlags_t;
70 #define DISABLE_STATE(mask) (stateFlags &= ~(mask))
71 #define ENABLE_STATE(mask) (stateFlags |= (mask))
72 #define STATE(mask) (stateFlags & (mask))
74 extern uint8_t stateFlags;
76 uint16_t enableFlightMode(flightModeFlags_e mask);
77 uint16_t disableFlightMode(flightModeFlags_e mask);
79 bool sensors(uint32_t mask);
80 void sensorsSet(uint32_t mask);
81 void sensorsClear(uint32_t mask);
82 uint32_t sensorsMask(void);
84 void mwDisarm(void);