diff --git a/src/drv_pwm.c b/src/drv_pwm.c index 6a0c7e2c84..5ff9d8b311 100755 --- a/src/drv_pwm.c +++ b/src/drv_pwm.c @@ -354,7 +354,7 @@ bool pwmInit(drv_pwm_config_t *init) pwmInConfig(port, pwmCallback, numInputs); numInputs++; } else if (mask & TYPE_M) { - motors[numMotors++] = pwmOutConfig(port, 1000000 / init->motorPwmRate, PULSE_1MS); + motors[numMotors++] = pwmOutConfig(port, 1000000 / init->motorPwmRate, init->idlePulse > 0 ? init->idlePulse : PULSE_1MS); } else if (mask & TYPE_S) { servos[numServos++] = pwmOutConfig(port, 1000000 / init->servoPwmRate, PULSE_1MS); } diff --git a/src/drv_pwm.h b/src/drv_pwm.h index 728ac8eec3..491ee93b89 100755 --- a/src/drv_pwm.h +++ b/src/drv_pwm.h @@ -15,6 +15,8 @@ typedef struct drv_pwm_config_t { uint8_t adcChannel; // steal one RC input for current sensor uint16_t motorPwmRate; uint16_t servoPwmRate; + uint16_t idlePulse; // PWM value to use when initializing the driver; + // default of zero means PULSE_1MS, otherwise set to given value. Used by 3D mode. uint16_t failsafeThreshold; } drv_pwm_config_t; diff --git a/src/main.c b/src/main.c index 3b471e3c31..d5f8f5f45c 100755 --- a/src/main.c +++ b/src/main.c @@ -67,6 +67,7 @@ int main(void) pwm_params.extraServos = cfg.gimbal_flags & GIMBAL_FORWARDAUX; pwm_params.motorPwmRate = mcfg.motor_pwm_rate; pwm_params.servoPwmRate = mcfg.servo_pwm_rate; + pwm_params.idlePulse = feature(FEATURE_3D) ? mcfg.neutral3d : 0; pwm_params.failsafeThreshold = cfg.failsafe_detect_threshold; switch (mcfg.power_adc_channel) { case 1: