Merge pull request #10558 from iNavFlight/MrD_Correct-comments-on-OSD-symbols
[inav.git] / src / main / target / ALIENFLIGHTNGF7 / config.c
blob28d0465eaf7dd98cd1db93d4c01daf080eb69a1e
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 #include <stdbool.h>
19 #include <stdint.h>
21 #include <platform.h>
23 #include "common/axis.h"
25 #include "drivers/sensor.h"
26 #include "drivers/pwm_esc_detect.h"
27 #include "drivers/pwm_mapping.h"
28 #include "drivers/pwm_output.h"
29 #include "drivers/serial.h"
31 #include "fc/rc_controls.h"
33 #include "flight/failsafe.h"
34 #include "flight/mixer.h"
35 #include "flight/pid.h"
37 #include "rx/rx.h"
39 #include "io/serial.h"
41 #include "telemetry/telemetry.h"
43 #include "sensors/battery.h"
44 #include "sensors/sensors.h"
46 #include "config/config_master.h"
47 #include "config/feature.h"
49 #include "sensors/battery.h"
50 #include "sensors/compass.h"
52 #include "hardware_revision.h"
54 #define CURRENTOFFSET 2500 // ACS712/714-30A - 0A = 2.5V
55 #define CURRENTSCALE -667 // ACS712/714-30A - 66.666 mV/A inverted mode
57 #define BRUSHED_MOTORS_PWM_RATE 32000 // 32kHz
59 // alternative defaults settings for AlienFlight targets
60 void targetConfiguration(void)
62 compassConfigMutable()->mag_align = CW90_DEG;
64 serialConfigMutable()->portConfigs[2].functionMask = FUNCTION_RX_SERIAL;
65 batteryMetersConfigMutable()->current.offset = CURRENTOFFSET;
66 batteryMetersConfigMutable()->current.scale = CURRENTSCALE;
68 if (hardwareMotorType == MOTOR_BRUSHED) {
69 motorConfigMutable()->motorPwmRate = BRUSHED_MOTORS_PWM_RATE;
72 if (hardwareRevision == AFF7_REV_1) {
73 rxConfigMutable()->serialrx_provider = SERIALRX_SPEKTRUM2048;
74 rxConfigMutable()->spektrum_sat_bind = 5;
75 rxConfigMutable()->spektrum_sat_bind_autoreset = 1;
76 } else {
77 rxConfigMutable()->serialrx_provider = SERIALRX_SBUS;
78 featureConfigMutable()->enabledFeatures |= (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TELEMETRY);
81 pidProfileMutable()->bank_mc.pid[ROLL].P = 53;
82 pidProfileMutable()->bank_mc.pid[ROLL].I = 45;
83 pidProfileMutable()->bank_mc.pid[ROLL].D = 52;
84 pidProfileMutable()->bank_mc.pid[PITCH].P = 53;
85 pidProfileMutable()->bank_mc.pid[PITCH].I = 45;
86 pidProfileMutable()->bank_mc.pid[PITCH].D = 52;
87 pidProfileMutable()->bank_mc.pid[YAW].P = 64;
88 pidProfileMutable()->bank_mc.pid[YAW].D = 18;
90 *primaryMotorMixerMutable(0) = (motorMixer_t){ 1.0f, -0.414178f, 1.0f, -1.0f }; // REAR_R
91 *primaryMotorMixerMutable(1) = (motorMixer_t){ 1.0f, -0.414178f, -1.0f, 1.0f }; // FRONT_R
92 *primaryMotorMixerMutable(2) = (motorMixer_t){ 1.0f, 0.414178f, 1.0f, 1.0f }; // REAR_L
93 *primaryMotorMixerMutable(3) = (motorMixer_t){ 1.0f, 0.414178f, -1.0f, -1.0f }; // FRONT_L
94 *primaryMotorMixerMutable(4) = (motorMixer_t){ 1.0f, -1.0f, -0.414178f, -1.0f }; // MIDFRONT_R
95 *primaryMotorMixerMutable(5) = (motorMixer_t){ 1.0f, 1.0f, -0.414178f, 1.0f }; // MIDFRONT_L
96 *primaryMotorMixerMutable(6) = (motorMixer_t){ 1.0f, -1.0f, 0.414178f, 1.0f }; // MIDREAR_R
97 *primaryMotorMixerMutable(7) = (motorMixer_t){ 1.0f, 1.0f, 0.414178f, -1.0f }; // MIDREAR_L