Skip to content

Commit

Permalink
Fixes betaflight#13934: Fix motor(PWM protocol) spin while fc reset. (b…
Browse files Browse the repository at this point in the history
…etaflight#13937)

* Fix motor(PWM protocol) spin while fc reset.

* move delay out to motorShutdown
  • Loading branch information
kedeng authored Oct 7, 2024
1 parent 909ab19 commit 10d5963
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/drivers/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,25 @@ static bool motorProtocolDshot = false;

void motorShutdown(void)
{
uint32_t shutdownDelayUs = 1500;
motorDevice->vTable.shutdown();
motorDevice->enabled = false;
motorDevice->motorEnableTimeMs = 0;
motorDevice->initialized = false;
delayMicroseconds(1500);

switch (motorConfig()->dev.motorPwmProtocol) {
case PWM_TYPE_STANDARD:
case PWM_TYPE_ONESHOT125:
case PWM_TYPE_ONESHOT42:
case PWM_TYPE_MULTISHOT:
// Delay 500ms will disarm esc which can prevent motor spin while reboot
shutdownDelayUs += 500 * 1000;
break;
default:
break;
}

delayMicroseconds(shutdownDelayUs);
}

void motorWriteAll(float *values)
Expand Down

0 comments on commit 10d5963

Please sign in to comment.