mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 03:20:00 +03:00
Add user option to force DSHOT EDT decoding always on
This commit is contained in:
parent
acbab53d13
commit
d5f8526ae6
5 changed files with 17 additions and 1 deletions
|
@ -956,6 +956,7 @@ const clivalue_t valueTable[] = {
|
||||||
#ifdef USE_DSHOT_TELEMETRY
|
#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) },
|
{ 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_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotEdt) },
|
||||||
|
{ "dshot_edt_always_decode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotEdtAlwaysDecode) },
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_DSHOT_BITBANG
|
#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) },
|
{ "dshot_bitbang", VAR_UINT8 | HARDWARE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON_AUTO }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotBitbang) },
|
||||||
|
|
|
@ -150,6 +150,7 @@ FAST_DATA_ZERO_INIT static float minMotorFrequencyHz;
|
||||||
FAST_DATA_ZERO_INIT static float erpmToHz;
|
FAST_DATA_ZERO_INIT static float erpmToHz;
|
||||||
FAST_DATA_ZERO_INIT static float dshotRpmAverage;
|
FAST_DATA_ZERO_INIT static float dshotRpmAverage;
|
||||||
FAST_DATA_ZERO_INIT static float dshotRpm[MAX_SUPPORTED_MOTORS];
|
FAST_DATA_ZERO_INIT static float dshotRpm[MAX_SUPPORTED_MOTORS];
|
||||||
|
FAST_DATA_ZERO_INIT static dshotEdtAlwaysDecode_e edtAlwaysDecode;
|
||||||
|
|
||||||
// Lookup table for extended telemetry type decoding
|
// Lookup table for extended telemetry type decoding
|
||||||
// Only contains extended telemetry types, eRPM is handled by conditional logic
|
// 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 is used by bidir dshot and ESC telemetry
|
||||||
erpmToHz = ERPM_PER_LSB / SECONDS_PER_MINUTE / (motorConfig()->motorPoleCount / 2.0f);
|
erpmToHz = ERPM_PER_LSB / SECONDS_PER_MINUTE / (motorConfig()->motorPoleCount / 2.0f);
|
||||||
|
edtAlwaysDecode = motorConfig()->dev.useDshotEdtAlwaysDecode == DSHOT_EDT_ALWAYS_DECODE_ON;
|
||||||
|
|
||||||
#ifdef USE_RPM_FILTER
|
#ifdef USE_RPM_FILTER
|
||||||
if (motorConfig()->dev.useDshotTelemetry) {
|
if (motorConfig()->dev.useDshotTelemetry) {
|
||||||
|
@ -214,6 +216,7 @@ static void dshot_decode_telemetry_value(uint8_t motorIndex, uint32_t *pDecoded,
|
||||||
{
|
{
|
||||||
uint16_t value = dshotTelemetryState.motorState[motorIndex].rawValue;
|
uint16_t value = dshotTelemetryState.motorState[motorIndex].rawValue;
|
||||||
bool isEdtEnabled = (dshotTelemetryState.motorState[motorIndex].telemetryTypes & DSHOT_EXTENDED_TELEMETRY_MASK) != 0;
|
bool isEdtEnabled = (dshotTelemetryState.motorState[motorIndex].telemetryTypes & DSHOT_EXTENDED_TELEMETRY_MASK) != 0;
|
||||||
|
isEdtEnabled |= edtAlwaysDecode;
|
||||||
|
|
||||||
// https://github.com/bird-sanctuary/extended-dshot-telemetry
|
// https://github.com/bird-sanctuary/extended-dshot-telemetry
|
||||||
// Extract telemetry type field and check for eRPM conditions in one operation
|
// Extract telemetry type field and check for eRPM conditions in one operation
|
||||||
|
|
|
@ -47,7 +47,11 @@
|
||||||
#define DEFAULT_DSHOT_TELEMETRY DSHOT_TELEMETRY_OFF
|
#define DEFAULT_DSHOT_TELEMETRY DSHOT_TELEMETRY_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 3);
|
#if !defined(DEFAULT_DSHOT_EDT_ALWAYS_DECODE)
|
||||||
|
#define DEFAULT_DSHOT_EDT_ALWAYS_DECODE DSHOT_EDT_ALWAYS_DECODE_OFF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 4);
|
||||||
|
|
||||||
void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
||||||
{
|
{
|
||||||
|
@ -112,6 +116,7 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
||||||
|
|
||||||
#ifdef USE_DSHOT_TELEMETRY
|
#ifdef USE_DSHOT_TELEMETRY
|
||||||
motorConfig->dev.useDshotTelemetry = DEFAULT_DSHOT_TELEMETRY;
|
motorConfig->dev.useDshotTelemetry = DEFAULT_DSHOT_TELEMETRY;
|
||||||
|
motorConfig->dev.useDshotEdtAlwaysDecode = DEFAULT_DSHOT_EDT_ALWAYS_DECODE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_DSHOT_BITBANG
|
#ifdef USE_DSHOT_BITBANG
|
||||||
|
|
|
@ -57,6 +57,11 @@ typedef enum {
|
||||||
DSHOT_TELEMETRY_ON,
|
DSHOT_TELEMETRY_ON,
|
||||||
} dshotTelemetry_e;
|
} dshotTelemetry_e;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DSHOT_EDT_ALWAYS_DECODE_OFF,
|
||||||
|
DSHOT_EDT_ALWAYS_DECODE_ON,
|
||||||
|
} dshotEdtAlwaysDecode_e;
|
||||||
|
|
||||||
typedef struct motorDevConfig_s {
|
typedef struct motorDevConfig_s {
|
||||||
uint16_t motorPwmRate; // The update rate of motor outputs (50-498Hz)
|
uint16_t motorPwmRate; // The update rate of motor outputs (50-498Hz)
|
||||||
uint8_t motorProtocol; // Pwm Protocol
|
uint8_t motorProtocol; // Pwm Protocol
|
||||||
|
@ -65,6 +70,7 @@ typedef struct motorDevConfig_s {
|
||||||
uint8_t useBurstDshot;
|
uint8_t useBurstDshot;
|
||||||
uint8_t useDshotTelemetry;
|
uint8_t useDshotTelemetry;
|
||||||
uint8_t useDshotEdt;
|
uint8_t useDshotEdt;
|
||||||
|
uint8_t useDshotEdtAlwaysDecode;
|
||||||
ioTag_t ioTags[MAX_SUPPORTED_MOTORS];
|
ioTag_t ioTags[MAX_SUPPORTED_MOTORS];
|
||||||
uint8_t motorTransportProtocol;
|
uint8_t motorTransportProtocol;
|
||||||
uint8_t useDshotBitbang;
|
uint8_t useDshotBitbang;
|
||||||
|
|
|
@ -43,6 +43,7 @@ PG_RESET_TEMPLATE(motorConfig_t, motorConfig,
|
||||||
.useBurstDshot = 0,
|
.useBurstDshot = 0,
|
||||||
.useDshotTelemetry = 0,
|
.useDshotTelemetry = 0,
|
||||||
.useDshotEdt = 0,
|
.useDshotEdt = 0,
|
||||||
|
.useDshotEdtAlwaysDecode = 0,
|
||||||
.ioTags = {IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE},
|
.ioTags = {IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE},
|
||||||
.motorTransportProtocol = 0,
|
.motorTransportProtocol = 0,
|
||||||
.useDshotBitbang = 0,
|
.useDshotBitbang = 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue