mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
Added delay before sending Dshot commands to avoid read errors.
This commit is contained in:
parent
ab53b178ca
commit
d4b1c06bf8
3 changed files with 32 additions and 21 deletions
|
@ -2456,6 +2456,7 @@ static void cliDshotProg(char *cmdline)
|
||||||
char *pch = strtok_r(cmdline, " ", &saveptr);
|
char *pch = strtok_r(cmdline, " ", &saveptr);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int escIndex = 0;
|
int escIndex = 0;
|
||||||
|
bool firstCommand = true;
|
||||||
while (pch != NULL) {
|
while (pch != NULL) {
|
||||||
switch (pos) {
|
switch (pos) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -2466,12 +2467,19 @@ static void cliDshotProg(char *cmdline)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pwmDisableMotors();
|
{
|
||||||
|
|
||||||
int command = atoi(pch);
|
int command = atoi(pch);
|
||||||
if (command >= 0 && command < DSHOT_MIN_THROTTLE) {
|
if (command >= 0 && command < DSHOT_MIN_THROTTLE) {
|
||||||
|
if (firstCommand) {
|
||||||
|
pwmDisableMotors();
|
||||||
|
|
||||||
if (command == DSHOT_CMD_ESC_INFO) {
|
if (command == DSHOT_CMD_ESC_INFO) {
|
||||||
delay(5); // Wait for potential ESC telemetry transmission to finish
|
delay(5); // Wait for potential ESC telemetry transmission to finish
|
||||||
|
} else {
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
firstCommand = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command != DSHOT_CMD_ESC_INFO) {
|
if (command != DSHOT_CMD_ESC_INFO) {
|
||||||
|
@ -2494,6 +2502,7 @@ static void cliDshotProg(char *cmdline)
|
||||||
} else {
|
} else {
|
||||||
cliPrintLinef("Invalid command, range 1 to %d.", DSHOT_MIN_THROTTLE - 1);
|
cliPrintLinef("Invalid command, range 1 to %d.", DSHOT_MIN_THROTTLE - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,6 +265,7 @@ void tryArm(void)
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (isMotorProtocolDshot() && isModeActivationConditionPresent(BOXFLIPOVERAFTERCRASH)) {
|
if (isMotorProtocolDshot() && isModeActivationConditionPresent(BOXFLIPOVERAFTERCRASH)) {
|
||||||
pwmDisableMotors();
|
pwmDisableMotors();
|
||||||
|
delay(1);
|
||||||
|
|
||||||
if (!IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
|
if (!IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
|
||||||
flipOverAfterCrashMode = false;
|
flipOverAfterCrashMode = false;
|
||||||
|
|
|
@ -365,6 +365,7 @@ void beeperUpdate(timeUs_t currentTimeUs)
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (!areMotorsRunning() && beeperConfig()->dshotForward && currentBeeperEntry->mode == BEEPER_RX_SET) {
|
if (!areMotorsRunning() && beeperConfig()->dshotForward && currentBeeperEntry->mode == BEEPER_RX_SET) {
|
||||||
pwmDisableMotors();
|
pwmDisableMotors();
|
||||||
|
delay(1);
|
||||||
|
|
||||||
pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_BEEP3);
|
pwmWriteDshotCommand(ALL_MOTORS, getMotorCount(), DSHOT_CMD_BEEP3);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue