diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index e4e04cbaa8..736b36d4cf 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -35,7 +35,7 @@ static pwmCompleteWriteFuncPtr pwmCompleteWritePtr = NULL; static pwmOutputPort_t servos[MAX_SUPPORTED_SERVOS]; #endif -static bool pwmMotorsEnabled = true; +bool pwmMotorsEnabled = true; static void pwmOCConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t value, uint8_t output) { diff --git a/src/main/drivers/pwm_output.h b/src/main/drivers/pwm_output.h index 4aa48905ae..02187844be 100644 --- a/src/main/drivers/pwm_output.h +++ b/src/main/drivers/pwm_output.h @@ -75,6 +75,8 @@ typedef struct { #endif } motorDmaOutput_t; +extern bool pwmMotorsEnabled; + struct timerHardware_s; typedef void(*pwmWriteFuncPtr)(uint8_t index, uint16_t value); // function pointer used to write motors typedef void(*pwmCompleteWriteFuncPtr)(uint8_t motorCount); // function pointer used after motors are written diff --git a/src/main/drivers/pwm_output_hal.c b/src/main/drivers/pwm_output_hal.c index 5e3dd4a05c..d81d027422 100644 --- a/src/main/drivers/pwm_output_hal.c +++ b/src/main/drivers/pwm_output_hal.c @@ -35,7 +35,7 @@ static pwmCompleteWriteFuncPtr pwmCompleteWritePtr = NULL; static pwmOutputPort_t servos[MAX_SUPPORTED_SERVOS]; #endif -static bool pwmMotorsEnabled = true; +bool pwmMotorsEnabled = true; static void pwmOCConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t value, uint8_t output) { diff --git a/src/main/drivers/pwm_output_stm32f3xx.c b/src/main/drivers/pwm_output_stm32f3xx.c index 72fc09043f..18c57facdf 100644 --- a/src/main/drivers/pwm_output_stm32f3xx.c +++ b/src/main/drivers/pwm_output_stm32f3xx.c @@ -59,6 +59,11 @@ uint8_t getTimerIndex(TIM_TypeDef *timer) void pwmWriteDigital(uint8_t index, uint16_t value) { + + if (!pwmMotorsEnabled) { + return; + } + motorDmaOutput_t * const motor = &dmaMotors[index]; uint16_t packet = (value << 1) | 0; // Here goes telemetry bit (false for now) @@ -85,6 +90,10 @@ void pwmWriteDigital(uint8_t index, uint16_t value) void pwmCompleteDigitalMotorUpdate(uint8_t motorCount) { UNUSED(motorCount); + + if (!pwmMotorsEnabled) { + return; + } for (int i = 0; i < dmaMotorTimerCount; i++) { TIM_SetCounter(dmaMotorTimers[i].timer, 0); diff --git a/src/main/drivers/pwm_output_stm32f4xx.c b/src/main/drivers/pwm_output_stm32f4xx.c index 10e841f853..62693d80db 100644 --- a/src/main/drivers/pwm_output_stm32f4xx.c +++ b/src/main/drivers/pwm_output_stm32f4xx.c @@ -58,6 +58,10 @@ uint8_t getTimerIndex(TIM_TypeDef *timer) void pwmWriteDigital(uint8_t index, uint16_t value) { + if (!pwmMotorsEnabled) { + return; + } + motorDmaOutput_t * const motor = &dmaMotors[index]; uint16_t packet = (value << 1) | 0; // Here goes telemetry bit (false for now) @@ -84,6 +88,10 @@ void pwmWriteDigital(uint8_t index, uint16_t value) void pwmCompleteDigitalMotorUpdate(uint8_t motorCount) { UNUSED(motorCount); + + if (!pwmMotorsEnabled) { + return; + } for (int i = 0; i < dmaMotorTimerCount; i++) { TIM_SetCounter(dmaMotorTimers[i].timer, 0); diff --git a/src/main/drivers/pwm_output_stm32f7xx.c b/src/main/drivers/pwm_output_stm32f7xx.c index e7db17f738..8ecf46e119 100644 --- a/src/main/drivers/pwm_output_stm32f7xx.c +++ b/src/main/drivers/pwm_output_stm32f7xx.c @@ -57,6 +57,11 @@ uint8_t getTimerIndex(TIM_TypeDef *timer) void pwmWriteDigital(uint8_t index, uint16_t value) { + + if (!pwmMotorsEnabled) { + return; + } + motorDmaOutput_t * const motor = &dmaMotors[index]; uint16_t packet = (value << 1) | 0; // Here goes telemetry bit (false for now) @@ -87,6 +92,10 @@ void pwmCompleteDigitalMotorUpdate(uint8_t motorCount) { UNUSED(motorCount); + if (!pwmMotorsEnabled) { + return; + } + for (uint8_t i = 0; i < dmaMotorTimerCount; i++) { //TIM_SetCounter(dmaMotorTimers[i].timer, 0); //TIM_DMACmd(dmaMotorTimers[i].timer, dmaMotorTimers[i].timerDmaSources, ENABLE);