Minor conditional-compilation fixes. (#8484)

Minor conditional-compilation fixes.
This commit is contained in:
Michael Keller 2019-07-04 09:07:41 +12:00 committed by GitHub
commit cd260821c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 22 deletions

View File

@ -4868,6 +4868,7 @@ static bool strToPin(char *pch, ioTag_t *tag)
return false;
}
#ifdef USE_DMA
static void printDma(void)
{
cliPrintLinefeed();
@ -4891,6 +4892,7 @@ static void printDma(void)
}
}
}
#endif
#ifdef USE_DMA_SPEC
@ -5274,6 +5276,7 @@ static void cliDmaopt(char *cmdline)
}
#endif // USE_DMA_SPEC
#ifdef USE_DMA
static void cliDma(char* cmdline)
{
int len = strlen(cmdline);
@ -5289,6 +5292,8 @@ static void cliDma(char* cmdline)
cliShowParseError();
#endif
}
#endif
static void cliResource(char *cmdline)
{
@ -5318,10 +5323,12 @@ static void cliResource(char *cmdline)
cliPrintLinefeed();
}
#if defined(USE_DMA)
pch = strtok_r(NULL, " ", &saveptr);
if (strcasecmp(pch, "all") == 0) {
cliDma("show");
}
#endif
return;
}
@ -5972,11 +5979,15 @@ const clicmd_t cmdTable[] = {
CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", "[nosave]", cliDefaults),
CLI_COMMAND_DEF("diff", "list configuration changes from default", "[master|profile|rates|hardware|all] {defaults|bare}", cliDiff),
#ifdef USE_RESOURCE_MGMT
#ifdef USE_DMA
#ifdef USE_DMA_SPEC
CLI_COMMAND_DEF("dma", "show/set DMA assignments", "<> | <device> <index> list | <device> <index> [<option>|none] | list | show", cliDma),
#else
CLI_COMMAND_DEF("dma", "show DMA assignments", "show", cliDma),
#endif
#endif
#endif
#ifdef USE_DSHOT_TELEMETRY
CLI_COMMAND_DEF("dshot_telemetry_info", "disply dshot telemetry info and stats", NULL, cliDshotTelemetryInfo),

View File

@ -26,7 +26,6 @@
#include "platform.h"
#ifdef USE_PWM_OUTPUT
#include "drivers/time.h"
#include "drivers/io.h"
@ -781,4 +780,5 @@ void beeperPwmInit(const ioTag_t tag, uint16_t frequency)
}
}
#endif // USE_BEEPER
#endif
#endif //USE_PWM_OUTPUT

View File

@ -407,6 +407,7 @@ void pwmRxInit(const pwmConfig_t *pwmConfig)
#define FIRST_PWM_PORT 0
#ifdef USE_PWM_OUTPUT
void ppmAvoidPWMTimerClash(TIM_TypeDef *pwmTimer)
{
pwmOutputPort_t *motors = pwmGetMotors();
@ -419,6 +420,7 @@ void ppmAvoidPWMTimerClash(TIM_TypeDef *pwmTimer)
return;
}
}
#endif
void ppmRxInit(const ppmConfig_t *ppmConfig)
{
@ -432,7 +434,9 @@ void ppmRxInit(const ppmConfig_t *ppmConfig)
return;
}
#ifdef USE_PWM_OUTPUT
ppmAvoidPWMTimerClash(timer->tim);
#endif
port->mode = INPUT_MODE_PPM;
port->timerHardware = timer;

View File

@ -557,17 +557,22 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
// INVERTED
motorRangeMin = motorOutputLow;
motorRangeMax = deadbandMotor3dLow;
#ifdef USE_DSHOT
if (isMotorProtocolDshot()) {
motorOutputMin = motorOutputLow;
motorOutputRange = deadbandMotor3dLow - motorOutputLow;
} else {
} else
#endif
{
motorOutputMin = deadbandMotor3dLow;
motorOutputRange = motorOutputLow - deadbandMotor3dLow;
}
if (motorOutputMixSign != -1) {
reversalTimeUs = currentTimeUs;
}
motorOutputMixSign = -1;
rcThrottlePrevious = rcCommand[THROTTLE];
throttle = rcCommand3dDeadBandLow - rcCommand[THROTTLE];
currentThrottleInputRange = rcCommandThrottleRange3dLow;
@ -590,17 +595,23 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
// INVERTED_TO_DEADBAND
motorRangeMin = motorOutputLow;
motorRangeMax = deadbandMotor3dLow;
#ifdef USE_DSHOT
if (isMotorProtocolDshot()) {
motorOutputMin = motorOutputLow;
motorOutputRange = deadbandMotor3dLow - motorOutputLow;
} else {
} else
#endif
{
motorOutputMin = deadbandMotor3dLow;
motorOutputRange = motorOutputLow - deadbandMotor3dLow;
}
if (motorOutputMixSign != -1) {
reversalTimeUs = currentTimeUs;
}
motorOutputMixSign = -1;
throttle = 0;
currentThrottleInputRange = rcCommandThrottleRange3dLow;
} else {
@ -720,9 +731,11 @@ static void applyMixToMotors(float motorMix[MAX_SUPPORTED_MOTORS], motorMixer_t
}
#endif
if (failsafeIsActive()) {
#ifdef USE_DSHOT
if (isMotorProtocolDshot()) {
motorOutput = (motorOutput < motorRangeMin) ? disarmMotorOutput : motorOutput; // Prevent getting into special reserved range
}
#endif
motorOutput = constrain(motorOutput, disarmMotorOutput, motorRangeMax);
} else {
motorOutput = constrain(motorOutput, motorRangeMin, motorRangeMax);
@ -940,9 +953,8 @@ FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs, uint8_t vbatPidCompensa
float convertExternalToMotor(uint16_t externalValue)
{
uint16_t motorValue;
switch ((int)isMotorProtocolDshot()) {
#ifdef USE_DSHOT
case true:
if (isMotorProtocolDshot()) {
externalValue = constrain(externalValue, PWM_RANGE_MIN, PWM_RANGE_MAX);
if (featureIsEnabled(FEATURE_3D)) {
@ -956,13 +968,11 @@ float convertExternalToMotor(uint16_t externalValue)
} else {
motorValue = (externalValue == PWM_RANGE_MIN) ? DSHOT_CMD_MOTOR_STOP : scaleRange(externalValue, PWM_RANGE_MIN + 1, PWM_RANGE_MAX, DSHOT_MIN_THROTTLE, DSHOT_MAX_THROTTLE);
}
break;
case false:
}
else
#endif
default:
{
motorValue = externalValue;
break;
}
return (float)motorValue;
@ -971,9 +981,8 @@ float convertExternalToMotor(uint16_t externalValue)
uint16_t convertMotorToExternal(float motorValue)
{
uint16_t externalValue;
switch ((int)isMotorProtocolDshot()) {
#ifdef USE_DSHOT
case true:
if (isMotorProtocolDshot()) {
if (featureIsEnabled(FEATURE_3D)) {
if (motorValue == DSHOT_CMD_MOTOR_STOP || motorValue < DSHOT_MIN_THROTTLE) {
externalValue = PWM_RANGE_MID;
@ -985,12 +994,11 @@ uint16_t convertMotorToExternal(float motorValue)
} else {
externalValue = (motorValue < DSHOT_MIN_THROTTLE) ? PWM_RANGE_MIN : scaleRange(motorValue, DSHOT_MIN_THROTTLE, DSHOT_MAX_THROTTLE, PWM_RANGE_MIN + 1, PWM_RANGE_MAX);
}
break;
case false:
}
else
#endif
default:
{
externalValue = motorValue;
break;
}
return externalValue;

View File

@ -226,9 +226,11 @@ void initActiveBoxIds(void)
BME(BOX3D);
}
#ifdef USE_DSHOT
if (isMotorProtocolDshot()) {
BME(BOXFLIPOVERAFTERCRASH);
}
#endif
if (featureIsEnabled(FEATURE_SERVO_TILT)) {
BME(BOXCAMSTAB);

View File

@ -424,11 +424,6 @@ bool pwmAreMotorsEnabled(void) {
return pwmMotorsEnabled;
}
bool isMotorProtocolDshot(void)
{
return false;
}
void pwmWriteMotor(uint8_t index, float value) {
motorsPwm[index] = value - idlePulse;
}

View File

@ -266,6 +266,10 @@
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
#endif
#if !defined(USE_PWM_OUTPUT)
#undef USE_SERIAL_4WAY_BLHELI_INTERFACE // implementation requires USE_PWM_OUTPUT to find motor outputs.
#endif
#if !defined(USE_LED_STRIP)
#undef USE_LED_STRIP_STATUS_MODE
#endif