Split features into a separate module
This commit is contained in:
parent
a303509920
commit
a257210b56
1
Makefile
1
Makefile
|
@ -385,6 +385,7 @@ COMMON_SRC = \
|
|||
common/typeconversion.c \
|
||||
config/config.c \
|
||||
config/config_eeprom.c \
|
||||
config/feature.c \
|
||||
fc/runtime_config.c \
|
||||
drivers/adc.c \
|
||||
drivers/buf_writer.c \
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
#include "config/config.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "blackbox.h"
|
||||
#include "blackbox_io.h"
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#ifndef DEFAULT_RX_FEATURE
|
||||
#define DEFAULT_RX_FEATURE FEATURE_RX_PARALLEL_PWM
|
||||
|
@ -97,11 +98,15 @@ void targetConfiguration(master_t *config);
|
|||
|
||||
master_t masterConfig; // master config struct with data independent from profiles
|
||||
profile_t *currentProfile;
|
||||
static uint32_t activeFeaturesLatch = 0;
|
||||
|
||||
static uint8_t currentControlRateProfileIndex = 0;
|
||||
controlRateConfig_t *currentControlRateProfile;
|
||||
|
||||
|
||||
void intFeatureClearAll(master_t *config);
|
||||
void intFeatureSet(uint32_t mask, master_t *config);
|
||||
void intFeatureClear(uint32_t mask, master_t *config);
|
||||
|
||||
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
||||
{
|
||||
accelerometerTrims->values.pitch = 0;
|
||||
|
@ -372,10 +377,6 @@ uint16_t getCurrentMinthrottle(void)
|
|||
return masterConfig.escAndServoConfig.minthrottle;
|
||||
}
|
||||
|
||||
static void intFeatureClearAll(master_t *config);
|
||||
static void intFeatureSet(uint32_t mask, master_t *config);
|
||||
static void intFeatureClear(uint32_t mask, master_t *config);
|
||||
|
||||
// Default settings
|
||||
void createDefaultConfig(master_t *config)
|
||||
{
|
||||
|
@ -872,56 +873,6 @@ void changeControlRateProfile(uint8_t profileIndex)
|
|||
activateControlRateConfig();
|
||||
}
|
||||
|
||||
void latchActiveFeatures()
|
||||
{
|
||||
activeFeaturesLatch = masterConfig.enabledFeatures;
|
||||
}
|
||||
|
||||
bool featureConfigured(uint32_t mask)
|
||||
{
|
||||
return masterConfig.enabledFeatures & mask;
|
||||
}
|
||||
|
||||
bool feature(uint32_t mask)
|
||||
{
|
||||
return activeFeaturesLatch & mask;
|
||||
}
|
||||
|
||||
void featureSet(uint32_t mask)
|
||||
{
|
||||
intFeatureSet(mask, &masterConfig);
|
||||
}
|
||||
|
||||
static void intFeatureSet(uint32_t mask, master_t *config)
|
||||
{
|
||||
config->enabledFeatures |= mask;
|
||||
}
|
||||
|
||||
void featureClear(uint32_t mask)
|
||||
{
|
||||
intFeatureClear(mask, &masterConfig);
|
||||
}
|
||||
|
||||
static void intFeatureClear(uint32_t mask, master_t *config)
|
||||
{
|
||||
config->enabledFeatures &= ~(mask);
|
||||
}
|
||||
|
||||
void featureClearAll()
|
||||
{
|
||||
intFeatureClearAll(&masterConfig);
|
||||
}
|
||||
|
||||
static void intFeatureClearAll(master_t *config)
|
||||
{
|
||||
config->enabledFeatures = 0;
|
||||
}
|
||||
|
||||
uint32_t featureMask(void)
|
||||
{
|
||||
return masterConfig.enabledFeatures;
|
||||
}
|
||||
|
||||
void beeperOffSet(uint32_t mask)
|
||||
{
|
||||
masterConfig.beeper_off_flags |= mask;
|
||||
|
|
|
@ -55,13 +55,6 @@ typedef enum {
|
|||
FEATURE_SOFTSPI = 1 << 26,
|
||||
} features_e;
|
||||
|
||||
void latchActiveFeatures(void);
|
||||
bool featureConfigured(uint32_t mask);
|
||||
bool feature(uint32_t mask);
|
||||
void featureSet(uint32_t mask);
|
||||
void featureClear(uint32_t mask);
|
||||
void featureClearAll(void);
|
||||
uint32_t featureMask(void);
|
||||
void beeperOffSet(uint32_t mask);
|
||||
void beeperOffSetAll(uint8_t beeperCount);
|
||||
void beeperOffClear(uint32_t mask);
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#include "common/color.h"
|
||||
#include "common/axis.h"
|
||||
|
||||
#include "drivers/sensor.h"
|
||||
#include "drivers/accgyro.h"
|
||||
#include "drivers/compass.h"
|
||||
#include "drivers/system.h"
|
||||
#include "drivers/timer.h"
|
||||
#include "drivers/pwm_rx.h"
|
||||
#include "drivers/serial.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
#include "sensors/gyro.h"
|
||||
#include "sensors/compass.h"
|
||||
#include "sensors/acceleration.h"
|
||||
#include "sensors/barometer.h"
|
||||
#include "sensors/boardalignment.h"
|
||||
#include "sensors/battery.h"
|
||||
|
||||
#include "io/beeper.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/gimbal.h"
|
||||
#include "io/escservo.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/rc_curves.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/vtx.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
|
||||
#include "telemetry/telemetry.h"
|
||||
|
||||
#include "flight/mixer.h"
|
||||
#include "flight/pid.h"
|
||||
#include "flight/imu.h"
|
||||
#include "flight/failsafe.h"
|
||||
#include "flight/altitudehold.h"
|
||||
#include "flight/navigation.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
static uint32_t activeFeaturesLatch = 0;
|
||||
|
||||
void intFeatureSet(uint32_t mask, master_t *config)
|
||||
{
|
||||
config->enabledFeatures |= mask;
|
||||
}
|
||||
|
||||
void intFeatureClear(uint32_t mask, master_t *config)
|
||||
{
|
||||
config->enabledFeatures &= ~(mask);
|
||||
}
|
||||
|
||||
void intFeatureClearAll(master_t *config)
|
||||
{
|
||||
config->enabledFeatures = 0;
|
||||
}
|
||||
|
||||
void latchActiveFeatures()
|
||||
{
|
||||
activeFeaturesLatch = masterConfig.enabledFeatures;
|
||||
}
|
||||
|
||||
bool featureConfigured(uint32_t mask)
|
||||
{
|
||||
return masterConfig.enabledFeatures & mask;
|
||||
}
|
||||
|
||||
bool feature(uint32_t mask)
|
||||
{
|
||||
return activeFeaturesLatch & mask;
|
||||
}
|
||||
|
||||
void featureSet(uint32_t mask)
|
||||
{
|
||||
intFeatureSet(mask, &masterConfig);
|
||||
}
|
||||
|
||||
void featureClear(uint32_t mask)
|
||||
{
|
||||
intFeatureClear(mask, &masterConfig);
|
||||
}
|
||||
|
||||
void featureClearAll()
|
||||
{
|
||||
intFeatureClearAll(&masterConfig);
|
||||
}
|
||||
|
||||
uint32_t featureMask(void)
|
||||
{
|
||||
return masterConfig.enabledFeatures;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void latchActiveFeatures(void);
|
||||
bool featureConfigured(uint32_t mask);
|
||||
bool feature(uint32_t mask);
|
||||
void featureSet(uint32_t mask);
|
||||
void featureClear(uint32_t mask);
|
||||
void featureClearAll(void);
|
||||
uint32_t featureMask(void);
|
|
@ -87,6 +87,7 @@
|
|||
#include "config/config.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "scheduler/scheduler.h"
|
||||
#include "scheduler/scheduler_tasks.h"
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "common/maths.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "platform.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "io/escservo.h"
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
uint8_t motorCount;
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "io/beeper.h"
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#endif
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "config/config_profile.h"
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "flight/navigation.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "drivers/timer.h"
|
||||
#include "drivers/pwm_rx.h"
|
||||
|
||||
#include <common/printf.h>
|
||||
#include "common/printf.h"
|
||||
#include "common/axis.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
|
@ -77,6 +77,7 @@
|
|||
#include "config/config.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
/*
|
||||
PG_REGISTER_ARR_WITH_RESET_FN(ledConfig_t, LED_MAX_STRIP_LENGTH, ledConfigs, PG_LED_STRIP_CONFIG, 0);
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
#include "config/config_eeprom.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "common/printf.h"
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
#include "config/config_eeprom.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#ifdef USE_HARDWARE_REVISION_DETECTION
|
||||
#include "hardware_revision.h"
|
||||
|
|
|
@ -108,6 +108,7 @@
|
|||
#include "config/config_eeprom.h"
|
||||
#include "config/config_profile.h"
|
||||
#include "config/config_master.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#define LOOPTIME_SUSPEND_TIME 3 // Prevent too long busy wait times
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "drivers/pwm_rx.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/pwm.h"
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "common/maths.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "drivers/serial.h"
|
||||
#include "drivers/adc.h"
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "io/beeper.h"
|
||||
#include "sensors/boardalignment.h"
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "sensors/acceleration.h"
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "sensors/battery.h"
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
#include "sensors/battery.h"
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "telemetry/telemetry.h"
|
||||
#include "telemetry/frsky.h"
|
||||
|
|
|
@ -61,9 +61,7 @@
|
|||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/config_profile.h"
|
||||
extern profile_t *currentProfile;
|
||||
extern controlRateConfig_t *currentControlRateProfile;
|
||||
#include "config/feature.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue