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/>.
28 #include "drivers/pwm_output.h"
31 #include "pg/pg_ids.h"
34 #if !defined(DEFAULT_DSHOT_BITBANG)
35 #define DEFAULT_DSHOT_BITBANG DSHOT_BITBANG_AUTO
38 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
39 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
42 #if !defined(DEFAULT_DSHOT_BURST)
43 #define DEFAULT_DSHOT_BURST DSHOT_DMAR_OFF
46 #if !defined(DEFAULT_DSHOT_TELEMETRY)
47 #define DEFAULT_DSHOT_TELEMETRY DSHOT_TELEMETRY_OFF
50 PG_REGISTER_WITH_RESET_FN(motorConfig_t
, motorConfig
, PG_MOTOR_CONFIG
, 3);
52 void pgResetFn_motorConfig(motorConfig_t
*motorConfig
)
55 motorConfig
->dev
.motorPwmRate
= BRUSHED_MOTORS_PWM_RATE
;
56 motorConfig
->dev
.motorPwmProtocol
= PWM_TYPE_BRUSHED
;
57 motorConfig
->dev
.useUnsyncedPwm
= true;
59 motorConfig
->dev
.motorPwmRate
= BRUSHLESS_MOTORS_PWM_RATE
;
61 if (motorConfig
->dev
.motorPwmProtocol
== PWM_TYPE_STANDARD
) {
62 motorConfig
->dev
.useUnsyncedPwm
= true;
64 motorConfig
->dev
.motorPwmProtocol
= PWM_TYPE_DISABLED
;
65 #elif defined(DEFAULT_MOTOR_DSHOT_SPEED)
66 motorConfig
->dev
.motorPwmProtocol
= DEFAULT_MOTOR_DSHOT_SPEED
;
68 motorConfig
->dev
.motorPwmProtocol
= PWM_TYPE_DSHOT600
;
70 #endif // BRUSHED_MOTORS
72 motorConfig
->maxthrottle
= 2000;
73 motorConfig
->mincommand
= 1000;
75 motorConfig
->motorIdle
= 700; // historical default minThrottle for brushed was 1070
77 motorConfig
->motorIdle
= 550;
78 #endif // BRUSHED_MOTORS
79 motorConfig
->kv
= 1960;
83 motorConfig
->dev
.ioTags
[0] = IO_TAG(MOTOR1_PIN
);
86 motorConfig
->dev
.ioTags
[1] = IO_TAG(MOTOR2_PIN
);
89 motorConfig
->dev
.ioTags
[2] = IO_TAG(MOTOR3_PIN
);
92 motorConfig
->dev
.ioTags
[3] = IO_TAG(MOTOR4_PIN
);
95 motorConfig
->dev
.ioTags
[4] = IO_TAG(MOTOR5_PIN
);
98 motorConfig
->dev
.ioTags
[5] = IO_TAG(MOTOR6_PIN
);
101 motorConfig
->dev
.ioTags
[6] = IO_TAG(MOTOR7_PIN
);
104 motorConfig
->dev
.ioTags
[7] = IO_TAG(MOTOR8_PIN
);
108 motorConfig
->motorPoleCount
= 14; // Most brushless motors that we use are 14 poles
110 for (int i
= 0; i
< MAX_SUPPORTED_MOTORS
; i
++) {
111 motorConfig
->dev
.motorOutputReordering
[i
] = i
;
114 #ifdef USE_DSHOT_DMAR
115 motorConfig
->dev
.useBurstDshot
= DEFAULT_DSHOT_BURST
;
118 #ifdef USE_DSHOT_TELEMETRY
119 motorConfig
->dev
.useDshotTelemetry
= DEFAULT_DSHOT_TELEMETRY
;
122 #ifdef USE_DSHOT_BITBANG
123 motorConfig
->dev
.useDshotBitbang
= DEFAULT_DSHOT_BITBANG
;
124 motorConfig
->dev
.useDshotBitbangedTimer
= DSHOT_BITBANGED_TIMER_DEFAULT
;