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/>.
29 #include "drivers/pwm_output.h"
32 #include "pg/pg_ids.h"
35 #if !defined(DEFAULT_DSHOT_BITBANG)
36 #define DEFAULT_DSHOT_BITBANG DSHOT_BITBANG_AUTO
39 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
40 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
43 #if !defined(DEFAULT_DSHOT_BURST)
44 #define DEFAULT_DSHOT_BURST DSHOT_DMAR_OFF
47 #if !defined(DEFAULT_DSHOT_TELEMETRY)
48 #define DEFAULT_DSHOT_TELEMETRY DSHOT_TELEMETRY_OFF
51 PG_REGISTER_WITH_RESET_FN(motorConfig_t
, motorConfig
, PG_MOTOR_CONFIG
, 2);
53 void pgResetFn_motorConfig(motorConfig_t
*motorConfig
)
56 motorConfig
->minthrottle
= 1000;
57 motorConfig
->dev
.motorPwmRate
= BRUSHED_MOTORS_PWM_RATE
;
58 motorConfig
->dev
.motorPwmProtocol
= PWM_TYPE_BRUSHED
;
59 motorConfig
->dev
.useUnsyncedPwm
= true;
61 motorConfig
->minthrottle
= 1070;
62 motorConfig
->dev
.motorPwmRate
= BRUSHLESS_MOTORS_PWM_RATE
;
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;
74 motorConfig
->digitalIdleOffsetValue
= 550;
75 motorConfig
->kv
= 1960;
79 motorConfig
->dev
.ioTags
[0] = IO_TAG(MOTOR1_PIN
);
82 motorConfig
->dev
.ioTags
[1] = IO_TAG(MOTOR2_PIN
);
85 motorConfig
->dev
.ioTags
[2] = IO_TAG(MOTOR3_PIN
);
88 motorConfig
->dev
.ioTags
[3] = IO_TAG(MOTOR4_PIN
);
91 motorConfig
->dev
.ioTags
[4] = IO_TAG(MOTOR5_PIN
);
94 motorConfig
->dev
.ioTags
[5] = IO_TAG(MOTOR6_PIN
);
97 motorConfig
->dev
.ioTags
[6] = IO_TAG(MOTOR7_PIN
);
100 motorConfig
->dev
.ioTags
[7] = IO_TAG(MOTOR8_PIN
);
104 motorConfig
->motorPoleCount
= 14; // Most brushless motors that we use are 14 poles
106 for (int i
= 0; i
< MAX_SUPPORTED_MOTORS
; i
++) {
107 motorConfig
->dev
.motorOutputReordering
[i
] = i
;
110 #ifdef USE_DSHOT_DMAR
111 motorConfig
->dev
.useBurstDshot
= DEFAULT_DSHOT_BURST
;
114 #ifdef USE_DSHOT_TELEMETRY
115 motorConfig
->dev
.useDshotTelemetry
= DEFAULT_DSHOT_TELEMETRY
;
118 #ifdef USE_DSHOT_BITBANG
119 motorConfig
->dev
.useDshotBitbang
= DEFAULT_DSHOT_BITBANG
;
120 motorConfig
->dev
.useDshotBitbangedTimer
= DSHOT_BITBANGED_TIMER_DEFAULT
;