Merge pull request #11494 from haslinghuis/dshot_gpio
[betaflight.git] / src / main / config / config.h
blob4d7fff7ad56831ef23efe20e3c41cd85eeaf07b9
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <stdint.h>
24 #include <stdbool.h>
26 #include "pg/pg.h"
28 #define MAX_NAME_LENGTH 16u
30 typedef enum {
31 CONFIGURATION_STATE_DEFAULTS_BARE = 0,
32 CONFIGURATION_STATE_DEFAULTS_CUSTOM,
33 CONFIGURATION_STATE_CONFIGURED,
34 } configurationState_e;
36 typedef struct pilotConfig_s {
37 char name[MAX_NAME_LENGTH + 1];
38 char displayName[MAX_NAME_LENGTH + 1];
39 } pilotConfig_t;
41 PG_DECLARE(pilotConfig_t, pilotConfig);
43 typedef struct systemConfig_s {
44 uint8_t pidProfileIndex;
45 uint8_t activeRateProfile;
46 uint8_t debug_mode;
47 uint8_t task_statistics;
48 uint8_t rateProfile6PosSwitch;
49 uint8_t cpu_overclock;
50 uint8_t powerOnArmingGraceTime; // in seconds
51 char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER) + 1];
52 uint8_t hseMhz; // Only used for F4 and G4 targets
53 uint8_t configurationState; // The state of the configuration (defaults / configured)
54 uint8_t enableStickArming; // boolean that determines whether stick arming can be used
55 } systemConfig_t;
57 PG_DECLARE(systemConfig_t, systemConfig);
59 struct pidProfile_s;
60 extern struct pidProfile_s *currentPidProfile;
62 void initEEPROM(void);
63 bool resetEEPROM(bool useCustomDefaults);
64 bool readEEPROM(void);
65 void writeEEPROM(void);
66 void writeUnmodifiedConfigToEEPROM(void);
67 void ensureEEPROMStructureIsValid(void);
69 void saveConfigAndNotify(void);
70 void validateAndFixGyroConfig(void);
72 void setConfigDirty(void);
73 bool isConfigDirty(void);
75 uint8_t getCurrentPidProfileIndex(void);
76 void changePidProfile(uint8_t pidProfileIndex);
77 void changePidProfileFromCellCount(uint8_t cellCount);
79 uint8_t getCurrentControlRateProfileIndex(void);
80 void changeControlRateProfile(uint8_t profileIndex);
82 bool canSoftwareSerialBeUsed(void);
84 uint16_t getCurrentMinthrottle(void);
86 void resetConfig(void);
87 void targetConfiguration(void);
88 void targetValidateConfiguration(void);
90 bool isSystemConfigured(void);
91 void setRebootRequired(void);
92 bool getRebootRequired(void);