Moved 'config.[ch]' into the 'config/' directory.
[betaflight.git] / src / main / target / ALIENFLIGHTNGF7 / config.c
blobc45f604f6a1c47d440bfe75ecaec433b9bebab7a
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 #include <stdbool.h>
22 #include <stdint.h>
24 #include "platform.h"
26 #ifdef USE_TARGET_CONFIG
27 #include "common/axis.h"
29 #include "config/feature.h"
31 #include "drivers/pwm_esc_detect.h"
33 #include "config/config.h"
35 #include "flight/mixer.h"
36 #include "flight/pid.h"
38 #include "pg/rx.h"
39 #include "pg/motor.h"
41 #include "rx/rx.h"
43 #include "io/serial.h"
45 #include "telemetry/telemetry.h"
47 #include "sensors/battery.h"
49 #include "hardware_revision.h"
51 #ifdef BRUSHED_MOTORS_PWM_RATE
52 #undef BRUSHED_MOTORS_PWM_RATE
53 #endif
55 #define BRUSHED_MOTORS_PWM_RATE 32000 // 32kHz
57 // alternative defaults settings for AlienFlight targets
58 void targetConfiguration(void)
60 if (getDetectedMotorType() == MOTOR_BRUSHED) {
61 motorConfigMutable()->dev.motorPwmRate = BRUSHED_MOTORS_PWM_RATE;
62 pidConfigMutable()->pid_process_denom = 1;
65 if (hardwareRevision == AFF7_REV_1) {
66 rxConfigMutable()->serialrx_provider = SERIALRX_SPEKTRUM2048;
67 rxConfigMutable()->spektrum_sat_bind = 5;
68 rxConfigMutable()->spektrum_sat_bind_autoreset = 1;
69 } else {
70 rxConfigMutable()->serialrx_provider = SERIALRX_SBUS;
71 rxConfigMutable()->serialrx_inverted = true;
72 serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIALRX_UART)].functionMask = FUNCTION_TELEMETRY_FRSKY_HUB | FUNCTION_RX_SERIAL;
73 telemetryConfigMutable()->telemetry_inverted = false;
74 batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_ADC;
75 batteryConfigMutable()->currentMeterSource = CURRENT_METER_ADC;
76 featureEnable(FEATURE_TELEMETRY);
79 for (uint8_t pidProfileIndex = 0; pidProfileIndex < PID_PROFILE_COUNT; pidProfileIndex++) {
80 pidProfile_t *pidProfile = pidProfilesMutable(pidProfileIndex);
82 pidProfile->pid[FD_ROLL].P = 53;
83 pidProfile->pid[FD_ROLL].I = 45;
84 pidProfile->pid[FD_ROLL].D = 52;
85 pidProfile->pid[FD_PITCH].P = 53;
86 pidProfile->pid[FD_PITCH].I = 45;
87 pidProfile->pid[FD_PITCH].D = 52;
88 pidProfile->pid[FD_YAW].P = 64;
89 pidProfile->pid[FD_YAW].D = 18;
92 *customMotorMixerMutable(0) = (motorMixer_t){ 1.0f, -0.414178f, 1.0f, -1.0f }; // REAR_R
93 *customMotorMixerMutable(1) = (motorMixer_t){ 1.0f, -0.414178f, -1.0f, 1.0f }; // FRONT_R
94 *customMotorMixerMutable(2) = (motorMixer_t){ 1.0f, 0.414178f, 1.0f, 1.0f }; // REAR_L
95 *customMotorMixerMutable(3) = (motorMixer_t){ 1.0f, 0.414178f, -1.0f, -1.0f }; // FRONT_L
96 *customMotorMixerMutable(4) = (motorMixer_t){ 1.0f, -1.0f, -0.414178f, -1.0f }; // MIDFRONT_R
97 *customMotorMixerMutable(5) = (motorMixer_t){ 1.0f, 1.0f, -0.414178f, 1.0f }; // MIDFRONT_L
98 *customMotorMixerMutable(6) = (motorMixer_t){ 1.0f, -1.0f, 0.414178f, 1.0f }; // MIDREAR_R
99 *customMotorMixerMutable(7) = (motorMixer_t){ 1.0f, 1.0f, 0.414178f, -1.0f }; // MIDREAR_L
101 #endif