1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Merge pull request #7929 from etracer65/fix_dshot_command_output

Fix erroneous dshot motor frame between multiple queued dshot commands at arming
This commit is contained in:
Michael Keller 2019-04-08 22:48:23 +12:00 committed by GitHub
commit 0611a3eab6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -456,7 +456,11 @@ FAST_CODE bool pwmDshotCommandIsProcessing(void)
return false;
}
dshotCommandControl_t* command = &commandQueue[commandQueueTail];
return command->nextCommandAtUs && !command->waitingForIdle && command->repeats > 0;
// Check if this is the last command in the queue. If not then we want to
// keep sending the command instead of falling back to the motor value to
// prevent a motor command frame to slip through between the this and the next command.
const bool isLastCommand = (commandQueueTail + 1) % (DSHOT_MAX_COMMANDS + 1) == commandQueueHead;
return (command->nextCommandAtUs && !command->waitingForIdle && command->repeats > 0) || !isLastCommand;
}
FAST_CODE void pwmDshotCommandQueueUpdate(void)
@ -467,6 +471,12 @@ FAST_CODE void pwmDshotCommandQueueUpdate(void)
dshotCommandControl_t* command = &commandQueue[commandQueueTail];
if (!command->nextCommandAtUs && !command->waitingForIdle && !command->repeats) {
commandQueueTail = (commandQueueTail + 1) % (DSHOT_MAX_COMMANDS + 1);
if (pwmDshotCommandIsQueued()) {
// there's another command in the queue
dshotCommandControl_t* nextCommand = &commandQueue[commandQueueTail];
nextCommand->waitingForIdle = false;
nextCommand->nextCommandAtUs = micros() + command->delayAfterCommandUs;
}
}
}