From cafe727f3ab831b93afea602291cc7787d76aaf6 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Thu, 23 Nov 2023 22:56:14 +0100 Subject: [PATCH] Fix Dshot telemetry (#13140) * Fix Dshot telemetry * Revert check per review --- src/main/fc/core.c | 11 +++++------ src/main/fc/runtime_config.c | 2 +- src/main/fc/runtime_config.h | 2 +- src/main/osd/osd_warnings.c | 2 +- src/main/target/common_post.h | 5 +---- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/fc/core.c b/src/main/fc/core.c index dd52b05663b..ebeea263de3 100644 --- a/src/main/fc/core.c +++ b/src/main/fc/core.c @@ -360,13 +360,12 @@ void updateArmingStatus(void) } #endif -#ifdef USE_RPM_FILTER - // USE_RPM_FILTER will only be defined if USE_DSHOT and USE_DSHOT_TELEMETRY are defined - // If the RPM filter is enabled and any motor isn't providing telemetry, then disable arming - if (isRpmFilterEnabled() && !isDshotTelemetryActive()) { - setArmingDisabled(ARMING_DISABLED_RPMFILTER); +#ifdef USE_DSHOT_TELEMETRY + // If Dshot Telemetry is enabled and any motor isn't providing telemetry, then disable arming + if (motorConfig()->dev.useDshotTelemetry && !isDshotTelemetryActive()) { + setArmingDisabled(ARMING_DISABLED_DSHOT_TELEM); } else { - unsetArmingDisabled(ARMING_DISABLED_RPMFILTER); + unsetArmingDisabled(ARMING_DISABLED_DSHOT_TELEM); } #endif diff --git a/src/main/fc/runtime_config.c b/src/main/fc/runtime_config.c index 8185ed4bd7a..fa97b266ea5 100644 --- a/src/main/fc/runtime_config.c +++ b/src/main/fc/runtime_config.c @@ -54,7 +54,7 @@ const char *armingDisableFlagNames[]= { "PARALYZE", "GPS", "RESCUE_SW", - "RPMFILTER", + "DSHOT_TELEM", "REBOOT_REQD", "DSHOT_BBANG", "NO_ACC_CAL", diff --git a/src/main/fc/runtime_config.h b/src/main/fc/runtime_config.h index c8d250bfd73..d5e8ba4727f 100644 --- a/src/main/fc/runtime_config.h +++ b/src/main/fc/runtime_config.h @@ -60,7 +60,7 @@ typedef enum { ARMING_DISABLED_PARALYZE = (1 << 17), ARMING_DISABLED_GPS = (1 << 18), ARMING_DISABLED_RESC = (1 << 19), - ARMING_DISABLED_RPMFILTER = (1 << 20), + ARMING_DISABLED_DSHOT_TELEM = (1 << 20), ARMING_DISABLED_REBOOT_REQUIRED = (1 << 21), ARMING_DISABLED_DSHOT_BITBANG = (1 << 22), ARMING_DISABLED_ACC_CALIBRATION = (1 << 23), diff --git a/src/main/osd/osd_warnings.c b/src/main/osd/osd_warnings.c index 2de7a86e60a..e8b29ebb6a3 100644 --- a/src/main/osd/osd_warnings.c +++ b/src/main/osd/osd_warnings.c @@ -338,7 +338,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr) // Add esc warnings if (ARMING_FLAG(ARMED) && osdConfig()->esc_rpm_alarm != ESC_RPM_ALARM_OFF - && (dshotTelemetryState.motorState[k].telemetryTypes & (1 << DSHOT_TELEMETRY_TYPE_eRPM)) != 0 + && isDshotMotorTelemetryActive(k) && (dshotTelemetryState.motorState[k].telemetryData[DSHOT_TELEMETRY_TYPE_eRPM] * 100 * 2 / motorConfig()->motorPoleCount) <= osdConfig()->esc_rpm_alarm) { warningText[dshotEscErrorLength++] = 'R'; } diff --git a/src/main/target/common_post.h b/src/main/target/common_post.h index 9667076519e..3733ca60f2e 100644 --- a/src/main/target/common_post.h +++ b/src/main/target/common_post.h @@ -482,6 +482,7 @@ #ifndef USE_DSHOT_TELEMETRY #undef USE_RPM_FILTER #undef USE_DSHOT_TELEMETRY_STATS +#undef USE_DYN_IDLE #endif #if !defined(USE_BOARD_INFO) @@ -568,10 +569,6 @@ extern uint8_t __config_end; #define RAM_CODE __attribute__((section(".ram_code"))) #endif -#if !defined(USE_RPM_FILTER) -#undef USE_DYN_IDLE -#endif - #ifndef USE_ITERM_RELAX #undef USE_ABSOLUTE_CONTROL #endif