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/>.
23 #include "common/axis.h"
25 #include "config/config_master.h"
26 #include "config/feature.h"
28 #include "drivers/sensor.h"
29 #include "drivers/pwm_esc_detect.h"
30 #include "drivers/pwm_mapping.h"
31 #include "drivers/pwm_output.h"
32 #include "drivers/serial.h"
34 #include "fc/rc_controls.h"
36 #include "flight/failsafe.h"
37 #include "flight/mixer.h"
38 #include "flight/pid.h"
40 #include "hardware_revision.h"
44 #include "io/serial.h"
46 #include "sensors/battery.h"
47 #include "sensors/sensors.h"
48 #include "sensors/compass.h"
50 #include "telemetry/telemetry.h"
52 #define CURRENTOFFSET 2500 // ACS712/714-30A - 0A = 2.5V
53 #define CURRENTSCALE -667 // ACS712/714-30A - 66.666 mV/A inverted mode
55 #define BRUSHED_MOTORS_PWM_RATE 32000 // 32kHz
57 // alternative defaults settings for AlienFlight targets
58 void targetConfiguration(void)
60 compassConfigMutable()->mag_align
= CW90_DEG
;
62 serialConfigMutable()->portConfigs
[2].functionMask
= FUNCTION_RX_SERIAL
;
63 batteryMetersConfigMutable()->current
.offset
= CURRENTOFFSET
;
64 batteryMetersConfigMutable()->current
.scale
= CURRENTSCALE
;
66 if (hardwareMotorType
== MOTOR_BRUSHED
) {
67 motorConfigMutable()->motorPwmProtocol
= PWM_TYPE_BRUSHED
;
68 motorConfigMutable()->motorPwmRate
= BRUSHED_MOTORS_PWM_RATE
;
70 if (hardwareRevision
== AFF4_REV_1
) {
71 rxConfigMutable()->serialrx_provider
= SERIALRX_SPEKTRUM2048
;
72 rxConfigMutable()->spektrum_sat_bind
= 5;
73 rxConfigMutable()->spektrum_sat_bind_autoreset
= 1;
75 rxConfigMutable()->serialrx_provider
= SERIALRX_SBUS
;
76 featureConfigMutable()->enabledFeatures
|= (FEATURE_TX_PROF_SEL
| FEATURE_CURRENT_METER
| FEATURE_VBAT
| FEATURE_TELEMETRY
);
79 pidProfileMutable()->bank_mc
.pid
[ROLL
].P
= 53;
80 pidProfileMutable()->bank_mc
.pid
[ROLL
].I
= 45;
81 pidProfileMutable()->bank_mc
.pid
[ROLL
].D
= 52;
82 pidProfileMutable()->bank_mc
.pid
[PITCH
].P
= 53;
83 pidProfileMutable()->bank_mc
.pid
[PITCH
].I
= 45;
84 pidProfileMutable()->bank_mc
.pid
[PITCH
].D
= 52;
85 pidProfileMutable()->bank_mc
.pid
[YAW
].P
= 64;
86 pidProfileMutable()->bank_mc
.pid
[YAW
].D
= 18;
88 *primaryMotorMixerMutable(0) = (motorMixer_t
){ 1.0f
, -0.414178f
, 1.0f
, -1.0f
}; // REAR_R
89 *primaryMotorMixerMutable(1) = (motorMixer_t
){ 1.0f
, -0.414178f
, -1.0f
, 1.0f
}; // FRONT_R
90 *primaryMotorMixerMutable(2) = (motorMixer_t
){ 1.0f
, 0.414178f
, 1.0f
, 1.0f
}; // REAR_L
91 *primaryMotorMixerMutable(3) = (motorMixer_t
){ 1.0f
, 0.414178f
, -1.0f
, -1.0f
}; // FRONT_L
92 *primaryMotorMixerMutable(4) = (motorMixer_t
){ 1.0f
, -1.0f
, -0.414178f
, -1.0f
}; // MIDFRONT_R
93 *primaryMotorMixerMutable(5) = (motorMixer_t
){ 1.0f
, 1.0f
, -0.414178f
, 1.0f
}; // MIDFRONT_L
94 *primaryMotorMixerMutable(6) = (motorMixer_t
){ 1.0f
, -1.0f
, 0.414178f
, 1.0f
}; // MIDREAR_R
95 *primaryMotorMixerMutable(7) = (motorMixer_t
){ 1.0f
, 1.0f
, 0.414178f
, -1.0f
}; // MIDREAR_L