Merge pull request #11189 from klutvott123/move-telemetry-displayport-init
[betaflight.git] / src / main / target / ALIENFLIGHTF4 / config.c
blob53b4d48e16e2e5a5ca3303a60b0913e813a05401
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
28 #include "common/axis.h"
30 #include "config/feature.h"
32 #include "drivers/pwm_esc_detect.h"
34 #include "config/config.h"
36 #include "flight/mixer.h"
37 #include "flight/pid.h"
39 #include "pg/rx.h"
40 #include "pg/motor.h"
42 #include "rx/rx.h"
44 #include "io/serial.h"
46 #include "telemetry/telemetry.h"
48 #include "sensors/battery.h"
50 #include "hardware_revision.h"
52 #ifdef BRUSHED_MOTORS_PWM_RATE
53 #undef BRUSHED_MOTORS_PWM_RATE
54 #endif
56 #define BRUSHED_MOTORS_PWM_RATE 32000 // 32kHz
58 // alternative defaults settings for AlienFlight targets
59 void targetConfiguration(void)
61 if (getDetectedMotorType() == MOTOR_BRUSHED) {
62 motorConfigMutable()->dev.motorPwmRate = BRUSHED_MOTORS_PWM_RATE;
63 pidConfigMutable()->pid_process_denom = 1;
66 if (hardwareRevision == AFF4_REV_1) {
67 rxConfigMutable()->serialrx_provider = SERIALRX_SPEKTRUM2048;
68 rxConfigMutable()->spektrum_sat_bind = 5;
69 rxConfigMutable()->spektrum_sat_bind_autoreset = 1;
70 } else {
71 rxConfigMutable()->serialrx_provider = SERIALRX_SBUS;
72 rxConfigMutable()->serialrx_inverted = true;
73 serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIALRX_UART)].functionMask = FUNCTION_TELEMETRY_FRSKY_HUB | FUNCTION_RX_SERIAL;
74 telemetryConfigMutable()->telemetry_inverted = false;
75 batteryConfigMutable()->voltageMeterSource = VOLTAGE_METER_ADC;
76 batteryConfigMutable()->currentMeterSource = CURRENT_METER_ADC;
77 featureConfigSet(FEATURE_TELEMETRY);
80 for (uint8_t pidProfileIndex = 0; pidProfileIndex < PID_PROFILE_COUNT; pidProfileIndex++) {
81 pidProfile_t *pidProfile = pidProfilesMutable(pidProfileIndex);
83 pidProfile->pid[PID_ROLL].P = 53;
84 pidProfile->pid[PID_ROLL].I = 45;
85 pidProfile->pid[PID_ROLL].D = 52;
86 pidProfile->pid[PID_PITCH].P = 53;
87 pidProfile->pid[PID_PITCH].I = 45;
88 pidProfile->pid[PID_PITCH].D = 52;
89 pidProfile->pid[PID_YAW].P = 64;
90 pidProfile->pid[PID_YAW].D = 18;
93 *customMotorMixerMutable(0) = (motorMixer_t){ 1.0f, -0.414178f, 1.0f, -1.0f }; // REAR_R
94 *customMotorMixerMutable(1) = (motorMixer_t){ 1.0f, -0.414178f, -1.0f, 1.0f }; // FRONT_R
95 *customMotorMixerMutable(2) = (motorMixer_t){ 1.0f, 0.414178f, 1.0f, 1.0f }; // REAR_L
96 *customMotorMixerMutable(3) = (motorMixer_t){ 1.0f, 0.414178f, -1.0f, -1.0f }; // FRONT_L
97 *customMotorMixerMutable(4) = (motorMixer_t){ 1.0f, -1.0f, -0.414178f, -1.0f }; // MIDFRONT_R
98 *customMotorMixerMutable(5) = (motorMixer_t){ 1.0f, 1.0f, -0.414178f, 1.0f }; // MIDFRONT_L
99 *customMotorMixerMutable(6) = (motorMixer_t){ 1.0f, -1.0f, 0.414178f, 1.0f }; // MIDREAR_R
100 *customMotorMixerMutable(7) = (motorMixer_t){ 1.0f, 1.0f, 0.414178f, -1.0f }; // MIDREAR_L
102 #endif