diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index cf86734c6e..27fb8fc073 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -45,8 +45,8 @@ static pwmOutputPort_t beeperPwm; static uint16_t freqBeep = 0; #endif -bool pwmMotorsEnabled = false; -bool isDshot = false; +static bool pwmMotorsEnabled = false; +static bool isDshot = false; static void pwmOCConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t value, uint8_t output) { @@ -395,7 +395,9 @@ void pwmWriteDshotCommand(uint8_t index, uint8_t command) for (; repeats; repeats--) { motor->requestTelemetry = true; pwmWriteDshotInt(index, command); - pwmCompleteMotorUpdate(0); + if (pwmMotorsEnabled) { + pwmCompleteDshotMotorUpdate(0); + } delay(1); } diff --git a/src/main/drivers/pwm_output.h b/src/main/drivers/pwm_output.h index 601161fe87..5c2b3cf7ce 100644 --- a/src/main/drivers/pwm_output.h +++ b/src/main/drivers/pwm_output.h @@ -125,8 +125,6 @@ typedef struct { motorDmaOutput_t *getMotorDmaOutput(uint8_t index); -extern bool pwmMotorsEnabled; - struct timerHardware_s; typedef void pwmWriteFunc(uint8_t index, float value); // function pointer used to write motors typedef void pwmCompleteWriteFunc(uint8_t motorCount); // function pointer used after motors are written diff --git a/src/main/drivers/pwm_output_dshot.c b/src/main/drivers/pwm_output_dshot.c index 3236c9cfdf..ff38430937 100644 --- a/src/main/drivers/pwm_output_dshot.c +++ b/src/main/drivers/pwm_output_dshot.c @@ -74,10 +74,6 @@ void pwmCompleteDshotMotorUpdate(uint8_t motorCount) { UNUSED(motorCount); - if (!pwmMotorsEnabled) { - return; - } - for (int i = 0; i < dmaMotorTimerCount; i++) { TIM_SetCounter(dmaMotorTimers[i].timer, 0); TIM_DMACmd(dmaMotorTimers[i].timer, dmaMotorTimers[i].timerDmaSources, ENABLE); diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 41dafd5ece..fc5f5531f9 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -469,9 +469,8 @@ void writeMotors(void) for (int i = 0; i < motorCount; i++) { pwmWriteMotor(i, motor[i]); } + pwmCompleteMotorUpdate(motorCount); } - - pwmCompleteMotorUpdate(motorCount); } static void writeAllMotors(int16_t mc) diff --git a/src/main/target/SITL/target.c b/src/main/target/SITL/target.c index 0ec676edd7..f7802a1f6a 100644 --- a/src/main/target/SITL/target.c +++ b/src/main/target/SITL/target.c @@ -374,7 +374,7 @@ int timeval_sub(struct timespec *result, struct timespec *x, struct timespec *y) // PWM part -bool pwmMotorsEnabled = false; +static bool pwmMotorsEnabled = false; static pwmOutputPort_t motors[MAX_SUPPORTED_MOTORS]; static pwmOutputPort_t servos[MAX_SUPPORTED_SERVOS];