1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

[4.5.2] Fixes #13934: Fix motor(PWM protocol) spin while fc reset. (#13937) (#13958)

Fixes #13934: Fix motor(PWM protocol) spin while fc reset. (#13937)

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

* move delay out to motorShutdown

Co-authored-by: ke deng <degkxp@hotmail.com>
This commit is contained in:
Mark Haslinghuis 2024-10-08 23:41:52 +02:00 committed by GitHub
parent f7697e22fe
commit ad93ec30f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)