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"
49 #include "telemetry/telemetry.h"
51 #define CURRENTOFFSET 2500 // ACS712/714-30A - 0A = 2.5V
52 #define CURRENTSCALE -667 // ACS712/714-30A - 66.666 mV/A inverted mode
54 #define BRUSHED_MOTORS_PWM_RATE 32000 // 32kHz
56 // alternative defaults settings for AlienFlight targets
57 void targetConfiguration(void)
59 serialConfigMutable()->portConfigs
[2].functionMask
= FUNCTION_RX_SERIAL
;
60 batteryMetersConfigMutable()->current
.offset
= CURRENTOFFSET
;
61 batteryMetersConfigMutable()->current
.scale
= CURRENTSCALE
;
63 if (hardwareMotorType
== MOTOR_BRUSHED
) {
64 motorConfigMutable()->motorPwmProtocol
= PWM_TYPE_BRUSHED
;
65 motorConfigMutable()->motorPwmRate
= BRUSHED_MOTORS_PWM_RATE
;
67 if (hardwareRevision
== AFF4_REV_1
) {
68 rxConfigMutable()->serialrx_provider
= SERIALRX_SPEKTRUM2048
;
69 rxConfigMutable()->spektrum_sat_bind
= 5;
70 rxConfigMutable()->spektrum_sat_bind_autoreset
= 1;
72 rxConfigMutable()->serialrx_provider
= SERIALRX_SBUS
;
73 serialConfigMutable()->portConfigs
[3].functionMask
= FUNCTION_TELEMETRY_FRSKY
;
74 featureConfigMutable()->enabledFeatures
|= (FEATURE_TX_PROF_SEL
| FEATURE_CURRENT_METER
| FEATURE_VBAT
| FEATURE_TELEMETRY
);
77 pidProfileMutable()->bank_mc
.pid
[ROLL
].P
= 53;
78 pidProfileMutable()->bank_mc
.pid
[ROLL
].I
= 45;
79 pidProfileMutable()->bank_mc
.pid
[ROLL
].D
= 52;
80 pidProfileMutable()->bank_mc
.pid
[PITCH
].P
= 53;
81 pidProfileMutable()->bank_mc
.pid
[PITCH
].I
= 45;
82 pidProfileMutable()->bank_mc
.pid
[PITCH
].D
= 52;
83 pidProfileMutable()->bank_mc
.pid
[YAW
].P
= 64;
84 pidProfileMutable()->bank_mc
.pid
[YAW
].D
= 18;
86 *primaryMotorMixerMutable(0) = (motorMixer_t
){ 1.0f
, -0.414178f
, 1.0f
, -1.0f
}; // REAR_R
87 *primaryMotorMixerMutable(1) = (motorMixer_t
){ 1.0f
, -0.414178f
, -1.0f
, 1.0f
}; // FRONT_R
88 *primaryMotorMixerMutable(2) = (motorMixer_t
){ 1.0f
, 0.414178f
, 1.0f
, 1.0f
}; // REAR_L
89 *primaryMotorMixerMutable(3) = (motorMixer_t
){ 1.0f
, 0.414178f
, -1.0f
, -1.0f
}; // FRONT_L
90 *primaryMotorMixerMutable(4) = (motorMixer_t
){ 1.0f
, -1.0f
, -0.414178f
, -1.0f
}; // MIDFRONT_R
91 *primaryMotorMixerMutable(5) = (motorMixer_t
){ 1.0f
, 1.0f
, -0.414178f
, 1.0f
}; // MIDFRONT_L
92 *primaryMotorMixerMutable(6) = (motorMixer_t
){ 1.0f
, -1.0f
, 0.414178f
, 1.0f
}; // MIDREAR_R
93 *primaryMotorMixerMutable(7) = (motorMixer_t
){ 1.0f
, 1.0f
, 0.414178f
, -1.0f
}; // MIDREAR_L