Further better use of pwmAreMotorsEnabled

This commit is contained in:
Martin Budden 2017-07-05 06:21:36 +01:00
parent 3cdbaaf14d
commit 87ae1616d6
5 changed files with 7 additions and 12 deletions

View File

@ -45,8 +45,8 @@ static pwmOutputPort_t beeperPwm;
static uint16_t freqBeep = 0; static uint16_t freqBeep = 0;
#endif #endif
bool pwmMotorsEnabled = false; static bool pwmMotorsEnabled = false;
bool isDshot = false; static bool isDshot = false;
static void pwmOCConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t value, uint8_t output) 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--) { for (; repeats; repeats--) {
motor->requestTelemetry = true; motor->requestTelemetry = true;
pwmWriteDshotInt(index, command); pwmWriteDshotInt(index, command);
pwmCompleteMotorUpdate(0); if (pwmMotorsEnabled) {
pwmCompleteDshotMotorUpdate(0);
}
delay(1); delay(1);
} }

View File

@ -125,8 +125,6 @@ typedef struct {
motorDmaOutput_t *getMotorDmaOutput(uint8_t index); motorDmaOutput_t *getMotorDmaOutput(uint8_t index);
extern bool pwmMotorsEnabled;
struct timerHardware_s; struct timerHardware_s;
typedef void pwmWriteFunc(uint8_t index, float value); // function pointer used to write motors 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 typedef void pwmCompleteWriteFunc(uint8_t motorCount); // function pointer used after motors are written

View File

@ -74,10 +74,6 @@ void pwmCompleteDshotMotorUpdate(uint8_t motorCount)
{ {
UNUSED(motorCount); UNUSED(motorCount);
if (!pwmMotorsEnabled) {
return;
}
for (int i = 0; i < dmaMotorTimerCount; i++) { for (int i = 0; i < dmaMotorTimerCount; i++) {
TIM_SetCounter(dmaMotorTimers[i].timer, 0); TIM_SetCounter(dmaMotorTimers[i].timer, 0);
TIM_DMACmd(dmaMotorTimers[i].timer, dmaMotorTimers[i].timerDmaSources, ENABLE); TIM_DMACmd(dmaMotorTimers[i].timer, dmaMotorTimers[i].timerDmaSources, ENABLE);

View File

@ -469,10 +469,9 @@ void writeMotors(void)
for (int i = 0; i < motorCount; i++) { for (int i = 0; i < motorCount; i++) {
pwmWriteMotor(i, motor[i]); pwmWriteMotor(i, motor[i]);
} }
}
pwmCompleteMotorUpdate(motorCount); pwmCompleteMotorUpdate(motorCount);
} }
}
static void writeAllMotors(int16_t mc) static void writeAllMotors(int16_t mc)
{ {

View File

@ -374,7 +374,7 @@ int timeval_sub(struct timespec *result, struct timespec *x, struct timespec *y)
// PWM part // PWM part
bool pwmMotorsEnabled = false; static bool pwmMotorsEnabled = false;
static pwmOutputPort_t motors[MAX_SUPPORTED_MOTORS]; static pwmOutputPort_t motors[MAX_SUPPORTED_MOTORS];
static pwmOutputPort_t servos[MAX_SUPPORTED_SERVOS]; static pwmOutputPort_t servos[MAX_SUPPORTED_SERVOS];