mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +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:
commit
0611a3eab6
1 changed files with 11 additions and 1 deletions
|
@ -456,7 +456,11 @@ FAST_CODE bool pwmDshotCommandIsProcessing(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dshotCommandControl_t* command = &commandQueue[commandQueueTail];
|
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)
|
FAST_CODE void pwmDshotCommandQueueUpdate(void)
|
||||||
|
@ -467,6 +471,12 @@ FAST_CODE void pwmDshotCommandQueueUpdate(void)
|
||||||
dshotCommandControl_t* command = &commandQueue[commandQueueTail];
|
dshotCommandControl_t* command = &commandQueue[commandQueueTail];
|
||||||
if (!command->nextCommandAtUs && !command->waitingForIdle && !command->repeats) {
|
if (!command->nextCommandAtUs && !command->waitingForIdle && !command->repeats) {
|
||||||
commandQueueTail = (commandQueueTail + 1) % (DSHOT_MAX_COMMANDS + 1);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue