diff --git a/src/main/drivers/motor.c b/src/main/drivers/motor.c index c51bd56107..ec3a9bd9a4 100644 --- a/src/main/drivers/motor.c +++ b/src/main/drivers/motor.c @@ -73,7 +73,7 @@ void motorWriteAll(float *values) #endif } -int motorCount(void) +int motorDeviceCount(void) { return motorDevice->count; } diff --git a/src/main/drivers/motor.h b/src/main/drivers/motor.h index 52f3ca2014..2cb334b50e 100644 --- a/src/main/drivers/motor.h +++ b/src/main/drivers/motor.h @@ -83,6 +83,7 @@ uint16_t motorConvertToExternal(float motorValue); struct motorDevConfig_s; // XXX Shouldn't be needed once pwm_output* is really cleaned up. void motorDevInit(const struct motorDevConfig_s *motorConfig, uint16_t idlePulse, uint8_t motorCount); +int motorDeviceCount(void); bool checkMotorProtocolEnabled(const motorDevConfig_t *motorConfig, bool *protocolIsDshot); bool isMotorProtocolDshot(void); bool isMotorProtocolEnabled(void); diff --git a/src/main/drivers/pwm_output_dshot_shared.c b/src/main/drivers/pwm_output_dshot_shared.c index 1c2efdce82..32dc0cd4d1 100644 --- a/src/main/drivers/pwm_output_dshot_shared.c +++ b/src/main/drivers/pwm_output_dshot_shared.c @@ -46,6 +46,7 @@ #include "drivers/dshot.h" #include "drivers/dshot_dpwm.h" #include "drivers/dshot_command.h" +#include "drivers/motor.h" #include "pwm_output_dshot_shared.h" @@ -264,12 +265,16 @@ bool isDshotMotorTelemetryActive(uint8_t motorIndex) bool isDshotTelemetryActive(void) { - for (unsigned i = 0; i < dshotPwmDevice.count; i++) { - if (!isDshotMotorTelemetryActive(i)) { - return false; + const unsigned motorCount = motorDeviceCount(); + if (motorCount) { + for (unsigned i = 0; i < motorCount; i++) { + if (!isDshotMotorTelemetryActive(i)) { + return false; + } } + return true; } - return true; + return false; } #ifdef USE_DSHOT_TELEMETRY_STATS