mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
Merge ae6fcbf374
into e66010165e
This commit is contained in:
commit
bc12ce7cee
5 changed files with 27 additions and 2 deletions
|
@ -223,6 +223,12 @@ const char * const lookupTableOffOn[] = {
|
|||
"OFF", "ON"
|
||||
};
|
||||
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
static const char * const lookupTableDshotEdt[] = {
|
||||
"OFF", "ON", "FORCE"
|
||||
};
|
||||
#endif
|
||||
|
||||
static const char * const lookupTableCrashRecovery[] = {
|
||||
"OFF", "ON" ,"BEEP", "DISARM"
|
||||
};
|
||||
|
@ -643,6 +649,9 @@ const lookupTableEntry_t lookupTables[] = {
|
|||
#endif
|
||||
LOOKUP_TABLE_ENTRY(debugModeNames),
|
||||
LOOKUP_TABLE_ENTRY(lookupTablePwmProtocol),
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
LOOKUP_TABLE_ENTRY(lookupTableDshotEdt),
|
||||
#endif
|
||||
LOOKUP_TABLE_ENTRY(lookupTableLowpassType),
|
||||
LOOKUP_TABLE_ENTRY(lookupTableDtermLowpassType),
|
||||
LOOKUP_TABLE_ENTRY(lookupTableFailsafe),
|
||||
|
@ -955,7 +964,7 @@ const clivalue_t valueTable[] = {
|
|||
#endif
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
{ PARAM_NAME_DSHOT_BIDIR, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotTelemetry) },
|
||||
{ "dshot_edt", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotEdt) },
|
||||
{ "dshot_edt", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DSHOT_EDT }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotEdt) },
|
||||
#endif
|
||||
#ifdef USE_DSHOT_BITBANG
|
||||
{ "dshot_bitbang", VAR_UINT8 | HARDWARE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON_AUTO }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotBitbang) },
|
||||
|
|
|
@ -64,6 +64,9 @@ typedef enum {
|
|||
#endif
|
||||
TABLE_DEBUG,
|
||||
TABLE_MOTOR_PWM_PROTOCOL,
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
TABLE_DSHOT_EDT,
|
||||
#endif
|
||||
TABLE_GYRO_LPF_TYPE,
|
||||
TABLE_DTERM_LPF_TYPE,
|
||||
TABLE_FAILSAFE,
|
||||
|
|
|
@ -150,6 +150,7 @@ FAST_DATA_ZERO_INIT static float minMotorFrequencyHz;
|
|||
FAST_DATA_ZERO_INIT static float erpmToHz;
|
||||
FAST_DATA_ZERO_INIT static float dshotRpmAverage;
|
||||
FAST_DATA_ZERO_INIT static float dshotRpm[MAX_SUPPORTED_MOTORS];
|
||||
FAST_DATA_ZERO_INIT static bool edtAlwaysDecode;
|
||||
|
||||
// Lookup table for extended telemetry type decoding
|
||||
// Only contains extended telemetry types, eRPM is handled by conditional logic
|
||||
|
@ -180,6 +181,7 @@ void initDshotTelemetry(const timeUs_t looptimeUs)
|
|||
|
||||
// erpmToHz is used by bidir dshot and ESC telemetry
|
||||
erpmToHz = ERPM_PER_LSB / SECONDS_PER_MINUTE / (motorConfig()->motorPoleCount / 2.0f);
|
||||
edtAlwaysDecode = motorConfig()->dev.useDshotEdt == DSHOT_EDT_FORCE;
|
||||
|
||||
#ifdef USE_RPM_FILTER
|
||||
if (motorConfig()->dev.useDshotTelemetry) {
|
||||
|
@ -213,7 +215,7 @@ static uint32_t dshot_decode_eRPM_telemetry_value(uint16_t value)
|
|||
static void dshot_decode_telemetry_value(uint8_t motorIndex, uint32_t *pDecoded, dshotTelemetryType_t *pType)
|
||||
{
|
||||
uint16_t value = dshotTelemetryState.motorState[motorIndex].rawValue;
|
||||
bool isEdtEnabled = (dshotTelemetryState.motorState[motorIndex].telemetryTypes & DSHOT_EXTENDED_TELEMETRY_MASK) != 0;
|
||||
bool isEdtEnabled = edtAlwaysDecode || (dshotTelemetryState.motorState[motorIndex].telemetryTypes & DSHOT_EXTENDED_TELEMETRY_MASK) != 0;
|
||||
|
||||
// https://github.com/bird-sanctuary/extended-dshot-telemetry
|
||||
// Extract telemetry type field and check for eRPM conditions in one operation
|
||||
|
|
|
@ -47,6 +47,10 @@
|
|||
#define DEFAULT_DSHOT_TELEMETRY DSHOT_TELEMETRY_OFF
|
||||
#endif
|
||||
|
||||
#if !defined(DEFAULT_DSHOT_EDT)
|
||||
#define DEFAULT_DSHOT_EDT DSHOT_EDT_OFF
|
||||
#endif
|
||||
|
||||
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 3);
|
||||
|
||||
void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
||||
|
@ -112,6 +116,7 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
|||
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
motorConfig->dev.useDshotTelemetry = DEFAULT_DSHOT_TELEMETRY;
|
||||
motorConfig->dev.useDshotEdt = DEFAULT_DSHOT_EDT;
|
||||
#endif
|
||||
|
||||
#ifdef USE_DSHOT_BITBANG
|
||||
|
|
|
@ -57,6 +57,12 @@ typedef enum {
|
|||
DSHOT_TELEMETRY_ON,
|
||||
} dshotTelemetry_e;
|
||||
|
||||
typedef enum {
|
||||
DSHOT_EDT_OFF = 0,
|
||||
DSHOT_EDT_ON = 1,
|
||||
DSHOT_EDT_FORCE = 2,
|
||||
} dshotEdt_e;
|
||||
|
||||
typedef struct motorDevConfig_s {
|
||||
uint16_t motorPwmRate; // The update rate of motor outputs (50-498Hz)
|
||||
uint8_t motorProtocol; // Pwm Protocol
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue