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_esc_detect.h"
30 #include "drivers/pwm_output.h"
33 #include "pg/pg_ids.h"
36 PG_REGISTER_WITH_RESET_FN(motorConfig_t
, motorConfig
, PG_MOTOR_CONFIG
, 1);
38 void pgResetFn_motorConfig(motorConfig_t
*motorConfig
)
41 motorConfig
->minthrottle
= 1000;
42 motorConfig
->dev
.motorPwmRate
= BRUSHED_MOTORS_PWM_RATE
;
43 motorConfig
->dev
.motorPwmProtocol
= PWM_TYPE_BRUSHED
;
44 motorConfig
->dev
.useUnsyncedPwm
= true;
46 #ifdef USE_BRUSHED_ESC_AUTODETECT
47 if (getDetectedMotorType() == MOTOR_BRUSHED
) {
48 motorConfig
->minthrottle
= 1000;
49 motorConfig
->dev
.motorPwmRate
= BRUSHED_MOTORS_PWM_RATE
;
50 motorConfig
->dev
.motorPwmProtocol
= PWM_TYPE_BRUSHED
;
51 motorConfig
->dev
.useUnsyncedPwm
= true;
53 #endif // USE_BRUSHED_ESC_AUTODETECT
55 motorConfig
->minthrottle
= 1070;
56 motorConfig
->dev
.motorPwmRate
= BRUSHLESS_MOTORS_PWM_RATE
;
57 motorConfig
->dev
.motorPwmProtocol
= PWM_TYPE_DISABLED
;
59 #endif // BRUSHED_MOTORS
61 motorConfig
->maxthrottle
= 2000;
62 motorConfig
->mincommand
= 1000;
63 motorConfig
->digitalIdleOffsetValue
= 550;
66 motorConfig
->dev
.useBurstDshot
= ENABLE_DSHOT_DMAR
;
70 for (int motorIndex
= 0; motorIndex
< MAX_SUPPORTED_MOTORS
; motorIndex
++) {
71 motorConfig
->dev
.ioTags
[motorIndex
] = timerioTagGetByUsage(TIM_USE_MOTOR
, motorIndex
);
75 motorConfig
->motorPoleCount
= 14; // Most brushes motors that we use are 14 poles
77 for (int i
= 0; i
< MAX_SUPPORTED_MOTORS
; i
++) {
78 motorConfig
->dev
.motorOutputReordering
[i
] = i
;
81 #ifdef USE_DSHOT_BITBANG
82 motorConfig
->dev
.useDshotBitbang
= DSHOT_BITBANG_DEFAULT
;
83 motorConfig
->dev
.useDshotBitbangedTimer
= DSHOT_BITBANGED_TIMER_DEFAULT
;