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)
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/>.
26 #ifdef USE_TARGET_CONFIG
28 #include "common/axis.h"
29 #include "common/utils.h"
31 #include "drivers/io.h"
33 #include "fc/config.h"
34 #include "fc/rc_controls.h"
35 #include "fc/controlrate_profile.h"
37 #include "flight/failsafe.h"
38 #include "flight/mixer.h"
39 #include "flight/pid.h"
43 #include "sensors/acceleration.h"
44 #include "sensors/compass.h"
45 #include "sensors/gyro.h"
47 #include "pg/beeper_dev.h"
50 #include "hardware_revision.h"
52 void targetConfiguration(void)
55 // alternative defaults settings for Beebrain target
56 motorConfigMutable()->dev
.motorPwmRate
= 4000;
57 failsafeConfigMutable()->failsafe_delay
= 2;
58 failsafeConfigMutable()->failsafe_off_delay
= 0;
60 motorConfigMutable()->minthrottle
= 1049;
62 gyroConfigMutable()->gyro_hardware_lpf
= GYRO_HARDWARE_LPF_1KHZ_SAMPLE
;
63 gyroConfigMutable()->gyro_soft_lpf_hz
= 100;
64 gyroConfigMutable()->gyro_soft_notch_hz_1
= 0;
65 gyroConfigMutable()->gyro_soft_notch_hz_2
= 0;
67 /*for (int channel = 0; channel < NON_AUX_CHANNEL_COUNT; channel++) {
68 rxChannelRangeConfigsMutable(channel)->min = 1180;
69 rxChannelRangeConfigsMutable(channel)->max = 1860;
72 for (uint8_t pidProfileIndex
= 0; pidProfileIndex
< MAX_PROFILE_COUNT
; pidProfileIndex
++) {
73 pidProfile_t
*pidProfile
= pidProfilesMutable(pidProfileIndex
);
75 pidProfile
->pid
[PID_ROLL
].P
= 60;
76 pidProfile
->pid
[PID_ROLL
].I
= 70;
77 pidProfile
->pid
[PID_ROLL
].D
= 17;
78 pidProfile
->pid
[PID_PITCH
].P
= 80;
79 pidProfile
->pid
[PID_PITCH
].I
= 90;
80 pidProfile
->pid
[PID_PITCH
].D
= 18;
81 pidProfile
->pid
[PID_YAW
].P
= 200;
82 pidProfile
->pid
[PID_YAW
].I
= 45;
83 pidProfile
->pid
[PID_LEVEL
].P
= 30;
84 pidProfile
->pid
[PID_LEVEL
].D
= 30;
86 pidProfile
->dtermSetpointWeight
= 200;
87 pidProfile
->setpointRelaxRatio
= 50;
90 for (uint8_t rateProfileIndex
= 0; rateProfileIndex
< CONTROL_RATE_PROFILE_COUNT
; rateProfileIndex
++) {
91 controlRateConfig_t
*controlRateConfig
= controlRateProfilesMutable(rateProfileIndex
);
93 controlRateConfig
->rcRates
[FD_ROLL
] = 100;
94 controlRateConfig
->rcRates
[FD_PITCH
] = 100;
95 controlRateConfig
->rcRates
[FD_YAW
] = 110;
96 controlRateConfig
->rcExpo
[FD_ROLL
] = 0;
97 controlRateConfig
->rcExpo
[FD_PITCH
] = 0;
98 controlRateConfig
->rates
[FD_ROLL
] = 77;
99 controlRateConfig
->rates
[FD_PITCH
] = 77;
100 controlRateConfig
->rates
[FD_YAW
] = 80;
104 #if !defined(AFROMINI) && !defined(BEEBRAIN)
105 if (hardwareRevision
>= NAZE32_REV5
) {
106 // naze rev4 and below used opendrain to PNP for buzzer. Rev5 and above use PP to NPN.
107 beeperDevConfigMutable()->isOpenDrain
= false;
108 beeperDevConfigMutable()->isInverted
= true;
110 beeperDevConfigMutable()->isOpenDrain
= true;
111 beeperDevConfigMutable()->isInverted
= false;
112 flashConfigMutable()->csTag
= IO_TAG_NONE
;
117 if (hardwareRevision
< NAZE32_REV5
) {
118 compassConfigMutable()->interruptTag
= IO_TAG(PB12
);
123 void targetValidateConfiguration(void)
125 if (hardwareRevision
< NAZE32_REV5
&& accelerometerConfig()->acc_hardware
== ACC_ADXL345
) {
126 accelerometerConfigMutable()->acc_hardware
= ACC_NONE
;