Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / target / NAZE / config.c
blob51a10d8bbdff7732d27bd9009787b17073942e1c
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"
29 #include "common/utils.h"
31 #include "drivers/io.h"
33 #include "config/config.h"
34 #include "fc/rc_controls.h"
35 #include "fc/controlrate_profile.h"
37 #include "flight/failsafe.h"
38 #include "flight/pid.h"
40 #include "pg/rx.h"
42 #include "rx/rx.h"
44 #include "sensors/acceleration.h"
45 #include "sensors/compass.h"
46 #include "sensors/gyro.h"
48 #include "pg/beeper_dev.h"
49 #include "pg/flash.h"
50 #include "pg/motor.h"
52 #include "hardware_revision.h"
54 void targetConfiguration(void)
56 #ifdef BEEBRAIN
57 // alternative defaults settings for Beebrain target
58 motorConfigMutable()->dev.motorPwmRate = 4000;
59 failsafeConfigMutable()->failsafe_delay = 2;
60 failsafeConfigMutable()->failsafe_off_delay = 0;
62 motorConfigMutable()->minthrottle = 1049;
64 gyroDeviceConfigMutable()->extiTag = selectMPUIntExtiConfigByHardwareRevision();
66 gyroConfigMutable()->gyro_soft_lpf_hz = 100;
67 gyroConfigMutable()->gyro_soft_notch_hz_1 = 0;
68 gyroConfigMutable()->gyro_soft_notch_hz_2 = 0;
70 /*for (int channel = 0; channel < NON_AUX_CHANNEL_COUNT; channel++) {
71 rxChannelRangeConfigsMutable(channel)->min = 1180;
72 rxChannelRangeConfigsMutable(channel)->max = 1860;
73 }*/
75 for (uint8_t pidProfileIndex = 0; pidProfileIndex < PID_PROFILE_COUNT; pidProfileIndex++) {
76 pidProfile_t *pidProfile = pidProfilesMutable(pidProfileIndex);
78 pidProfile->pid[PID_ROLL].P = 60;
79 pidProfile->pid[PID_ROLL].I = 70;
80 pidProfile->pid[PID_ROLL].D = 17;
81 pidProfile->pid[PID_PITCH].P = 80;
82 pidProfile->pid[PID_PITCH].I = 90;
83 pidProfile->pid[PID_PITCH].D = 18;
84 pidProfile->pid[PID_YAW].P = 200;
85 pidProfile->pid[PID_YAW].I = 45;
86 pidProfile->pid[PID_LEVEL].P = 30;
87 pidProfile->pid[PID_LEVEL].D = 30;
89 pidProfile->pid[PID_PITCH].F = 200;
90 pidProfile->pid[PID_ROLL].F = 200;
91 pidProfile->feedforward_transition = 50;
94 for (uint8_t rateProfileIndex = 0; rateProfileIndex < CONTROL_RATE_PROFILE_COUNT; rateProfileIndex++) {
95 controlRateConfig_t *controlRateConfig = controlRateProfilesMutable(rateProfileIndex);
97 controlRateConfig->rcRates[FD_ROLL] = 100;
98 controlRateConfig->rcRates[FD_PITCH] = 100;
99 controlRateConfig->rcRates[FD_YAW] = 110;
100 controlRateConfig->rcExpo[FD_ROLL] = 0;
101 controlRateConfig->rcExpo[FD_PITCH] = 0;
102 controlRateConfig->rates[FD_ROLL] = 77;
103 controlRateConfig->rates[FD_PITCH] = 77;
104 controlRateConfig->rates[FD_YAW] = 80;
106 #endif
108 #if !defined(AFROMINI) && !defined(BEEBRAIN)
109 if (hardwareRevision >= NAZE32_REV5) {
110 // naze rev4 and below used opendrain to PNP for buzzer. Rev5 and above use PP to NPN.
111 beeperDevConfigMutable()->isOpenDrain = false;
112 beeperDevConfigMutable()->isInverted = true;
113 } else {
114 beeperDevConfigMutable()->isOpenDrain = true;
115 beeperDevConfigMutable()->isInverted = false;
116 flashConfigMutable()->csTag = IO_TAG_NONE;
118 #endif
120 #if defined(USE_MAG) && defined(MAG_INT_EXTI)
121 if (hardwareRevision < NAZE32_REV5) {
122 compassConfigMutable()->interruptTag = IO_TAG(PB12);
124 #endif
127 void targetValidateConfiguration(void)
129 if (hardwareRevision < NAZE32_REV5 && accelerometerConfig()->acc_hardware == ACC_ADXL345) {
130 accelerometerConfigMutable()->acc_hardware = ACC_NONE;
133 #endif