Added check to disable bidirectional Dshot when N-channel timers are used.

This commit is contained in:
Michael Keller 2021-07-28 00:23:30 +12:00
parent 864cf3f3b4
commit 1d555a6297
2 changed files with 15 additions and 4 deletions

View File

@ -1585,8 +1585,7 @@ static void cliSerialPassthrough(const char *cmdName, char *cmdline)
// pwmDisableMotors(); // pwmDisableMotors();
motorDisable(); motorDisable();
delay(5); delay(5);
unsigned motorsCount = getMotorCount(); for (unsigned i = 0; i < getMotorCount(); i++) {
for (unsigned i = 0; i < motorsCount; i++) {
const ioTag_t tag = motorConfig()->dev.ioTags[i]; const ioTag_t tag = motorConfig()->dev.ioTags[i];
if (tag) { if (tag) {
const timerHardware_t *timerHardware = timerGetByTag(tag); const timerHardware_t *timerHardware = timerGetByTag(tag);

View File

@ -506,8 +506,20 @@ static void validateAndFixConfig(void)
} }
#if defined(USE_DSHOT_TELEMETRY) #if defined(USE_DSHOT_TELEMETRY)
if ((!configuredMotorProtocolDshot || (motorConfig()->dev.useDshotBitbang == DSHOT_BITBANG_OFF && motorConfig()->dev.useBurstDshot == DSHOT_DMAR_ON) || systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_OFF) bool nChannelTimerUsed = false;
&& motorConfig()->dev.useDshotTelemetry) { for (unsigned i = 0; i < getMotorCount(); i++) {
const ioTag_t tag = motorConfig()->dev.ioTags[i];
if (tag) {
const timerHardware_t *timer = timerGetByTag(tag);
if (timer && timer->output & TIMER_OUTPUT_N_CHANNEL) {
nChannelTimerUsed = true;
break;
}
}
}
if ((!configuredMotorProtocolDshot || (motorConfig()->dev.useDshotBitbang == DSHOT_BITBANG_OFF && (motorConfig()->dev.useBurstDshot == DSHOT_DMAR_ON || nChannelTimerUsed)) || systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_OFF) && motorConfig()->dev.useDshotTelemetry) {
motorConfigMutable()->dev.useDshotTelemetry = false; motorConfigMutable()->dev.useDshotTelemetry = false;
} }