mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Add arming disabled check if RPM filter enabled but DSHOT telemetry not working
If the RPM filter is enabled, requires all motors to have received a valid DSHOT telemetry frame before arming is allowed. Otherwise sets the arming disabled reason `ARMING_DISABLED_RPMFILTER`.
This commit is contained in:
parent
8404a6670b
commit
89ceb70b3c
5 changed files with 33 additions and 1 deletions
|
@ -146,6 +146,7 @@ typedef struct {
|
||||||
volatile bool isInput;
|
volatile bool isInput;
|
||||||
volatile bool hasTelemetry;
|
volatile bool hasTelemetry;
|
||||||
uint16_t dshotTelemetryValue;
|
uint16_t dshotTelemetryValue;
|
||||||
|
bool dshotTelemetryActive;
|
||||||
#ifdef USE_HAL_DRIVER
|
#ifdef USE_HAL_DRIVER
|
||||||
LL_TIM_OC_InitTypeDef ocInitStruct;
|
LL_TIM_OC_InitTypeDef ocInitStruct;
|
||||||
LL_TIM_IC_InitTypeDef icInitStruct;
|
LL_TIM_IC_InitTypeDef icInitStruct;
|
||||||
|
@ -253,6 +254,7 @@ bool pwmDshotCommandIsProcessing(void);
|
||||||
uint8_t pwmGetDshotCommand(uint8_t index);
|
uint8_t pwmGetDshotCommand(uint8_t index);
|
||||||
bool pwmDshotCommandOutputIsEnabled(uint8_t motorCount);
|
bool pwmDshotCommandOutputIsEnabled(uint8_t motorCount);
|
||||||
uint16_t getDshotTelemetry(uint8_t index);
|
uint16_t getDshotTelemetry(uint8_t index);
|
||||||
|
bool isDshotTelemetryActive(uint8_t index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ void pwmStartDshotMotorUpdate(uint8_t motorCount)
|
||||||
}
|
}
|
||||||
if (value != 0xffff) {
|
if (value != 0xffff) {
|
||||||
dmaMotors[i].dshotTelemetryValue = value;
|
dmaMotors[i].dshotTelemetryValue = value;
|
||||||
|
dmaMotors[i].dshotTelemetryActive = true;
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
DEBUG_SET(DEBUG_DSHOT_RPM_TELEMETRY, i, value);
|
DEBUG_SET(DEBUG_DSHOT_RPM_TELEMETRY, i, value);
|
||||||
}
|
}
|
||||||
|
@ -246,5 +247,10 @@ void pwmStartDshotMotorUpdate(uint8_t motorCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDshotTelemetryActive(uint8_t index)
|
||||||
|
{
|
||||||
|
return dmaMotors[index].dshotTelemetryActive;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,6 +56,8 @@
|
||||||
#if defined(USE_GYRO_DATA_ANALYSE)
|
#if defined(USE_GYRO_DATA_ANALYSE)
|
||||||
#include "sensors/gyroanalyse.h"
|
#include "sensors/gyroanalyse.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "sensors/rpm_filter.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
#include "fc/controlrate_profile.h"
|
#include "fc/controlrate_profile.h"
|
||||||
#include "fc/core.h"
|
#include "fc/core.h"
|
||||||
|
@ -291,6 +293,26 @@ void updateArmingStatus(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_RPM_FILTER
|
||||||
|
// USE_RPM_FILTER will only be set if USE_DSHOT and USE_DSHOT_TELEMETRY are defined
|
||||||
|
// If dshot_bidir is anabled and any motor isn't providing telemetry, then disable arming
|
||||||
|
if (motorConfig()->dev.useDshotTelemetry
|
||||||
|
&& (rpmFilterConfig()->gyro_rpm_notch_harmonics || rpmFilterConfig()->dterm_rpm_notch_harmonics)) {
|
||||||
|
bool dshotTelemetryActive = true;
|
||||||
|
for (uint8_t i = 0; i < getMotorCount(); i++) {
|
||||||
|
if (!isDshotTelemetryActive(i)) {
|
||||||
|
dshotTelemetryActive = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!dshotTelemetryActive) {
|
||||||
|
setArmingDisabled(ARMING_DISABLED_RPMFILTER);
|
||||||
|
} else {
|
||||||
|
unsetArmingDisabled(ARMING_DISABLED_RPMFILTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (IS_RC_MODE_ACTIVE(BOXPARALYZE)) {
|
if (IS_RC_MODE_ACTIVE(BOXPARALYZE)) {
|
||||||
setArmingDisabled(ARMING_DISABLED_PARALYZE);
|
setArmingDisabled(ARMING_DISABLED_PARALYZE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ const char *armingDisableFlagNames[]= {
|
||||||
"PARALYZE",
|
"PARALYZE",
|
||||||
"GPS",
|
"GPS",
|
||||||
"RESCUE SW",
|
"RESCUE SW",
|
||||||
|
"RPMFILTER",
|
||||||
"ARMSWITCH",
|
"ARMSWITCH",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,8 @@ typedef enum {
|
||||||
ARMING_DISABLED_PARALYZE = (1 << 16),
|
ARMING_DISABLED_PARALYZE = (1 << 16),
|
||||||
ARMING_DISABLED_GPS = (1 << 17),
|
ARMING_DISABLED_GPS = (1 << 17),
|
||||||
ARMING_DISABLED_RESC = (1 << 18),
|
ARMING_DISABLED_RESC = (1 << 18),
|
||||||
ARMING_DISABLED_ARM_SWITCH = (1 << 19), // Needs to be the last element, since it's always activated if one of the others is active when arming
|
ARMING_DISABLED_RPMFILTER = (1 << 19),
|
||||||
|
ARMING_DISABLED_ARM_SWITCH = (1 << 20), // Needs to be the last element, since it's always activated if one of the others is active when arming
|
||||||
} armingDisableFlags_e;
|
} armingDisableFlags_e;
|
||||||
|
|
||||||
#define ARMING_DISABLE_FLAGS_COUNT (LOG2(ARMING_DISABLED_ARM_SWITCH) + 1)
|
#define ARMING_DISABLE_FLAGS_COUNT (LOG2(ARMING_DISABLED_ARM_SWITCH) + 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue