mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Remove duplication in motor enable/disable
This commit is contained in:
parent
ea896e5445
commit
3cdbaaf14d
6 changed files with 8 additions and 16 deletions
|
@ -169,9 +169,7 @@ static uint8_t loadDmaBufferProshot(motorDmaOutput_t *const motor, uint16_t pack
|
|||
|
||||
void pwmWriteMotor(uint8_t index, float value)
|
||||
{
|
||||
if (pwmMotorsEnabled) {
|
||||
pwmWrite(index, value);
|
||||
}
|
||||
pwmWrite(index, value);
|
||||
}
|
||||
|
||||
void pwmShutdownPulsesForAllMotors(uint8_t motorCount)
|
||||
|
|
|
@ -134,11 +134,11 @@ typedef void pwmCompleteWriteFunc(uint8_t motorCount); // function pointer use
|
|||
typedef struct {
|
||||
volatile timCCR_t *ccr;
|
||||
TIM_TypeDef *tim;
|
||||
float pulseScale;
|
||||
float pulseOffset;
|
||||
bool forceOverflow;
|
||||
bool enabled;
|
||||
IO_t io;
|
||||
float pulseScale;
|
||||
float pulseOffset;
|
||||
} pwmOutputPort_t;
|
||||
|
||||
typedef struct motorDevConfig_s {
|
||||
|
|
|
@ -2231,7 +2231,7 @@ static void cliDshotProg(char *cmdline)
|
|||
|
||||
break;
|
||||
default:
|
||||
motorControlEnable = false;
|
||||
pwmDisableMotors();
|
||||
|
||||
int command = atoi(pch);
|
||||
if (command >= 0 && command < DSHOT_MIN_THROTTLE) {
|
||||
|
@ -2259,7 +2259,7 @@ static void cliDshotProg(char *cmdline)
|
|||
pch = strtok_r(NULL, " ", &saveptr);
|
||||
}
|
||||
|
||||
motorControlEnable = true;
|
||||
pwmEnableMotors();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -108,7 +108,6 @@ int16_t magHold;
|
|||
|
||||
int16_t headFreeModeHold;
|
||||
|
||||
uint8_t motorControlEnable = false;
|
||||
static bool reverseMotors = false;
|
||||
static uint32_t disarmAt; // Time of automatic disarm when "Don't spin the motors when armed" is enabled and auto_disarm_delay is nonzero
|
||||
|
||||
|
@ -627,9 +626,8 @@ static void subTaskMotorUpdate(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (motorControlEnable) {
|
||||
writeMotors();
|
||||
}
|
||||
writeMotors();
|
||||
|
||||
DEBUG_SET(DEBUG_PIDLOOP, 3, micros() - startTime);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ extern int16_t magHold;
|
|||
extern bool isRXDataNew;
|
||||
extern int16_t headFreeModeHold;
|
||||
|
||||
extern uint8_t motorControlEnable;
|
||||
|
||||
typedef struct throttleCorrectionConfig_s {
|
||||
uint16_t throttle_correction_angle; // the angle when the throttle correction is maximal. in 0.1 degres, ex 225 = 22.5 ,30.0, 450 = 45.0 deg
|
||||
uint8_t throttle_correction_value; // the correction that will be applied at throttle_correction_angle.
|
||||
|
|
|
@ -137,8 +137,6 @@
|
|||
void targetPreInit(void);
|
||||
#endif
|
||||
|
||||
extern uint8_t motorControlEnable;
|
||||
|
||||
#ifdef SOFTSERIAL_LOOPBACK
|
||||
serialPort_t *loopbackPort;
|
||||
#endif
|
||||
|
@ -709,7 +707,7 @@ void init(void)
|
|||
|
||||
// Latch active features AGAIN since some may be modified by init().
|
||||
latchActiveFeatures();
|
||||
motorControlEnable = true;
|
||||
pwmEnableMotors();
|
||||
|
||||
#ifdef USE_OSD_SLAVE
|
||||
osdSlaveTasksInit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue