mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
Only wait for ESC to recognise DSHOT signal once at startup (#14408)
* Only wait for ESC to recognise DSHOT signal once at startup * Use cmpTimeMs to compare time expressed in ms
This commit is contained in:
parent
77ceea93e4
commit
dd0a37b41c
2 changed files with 15 additions and 1 deletions
|
@ -46,6 +46,7 @@ typedef uint32_t timeUs_t;
|
||||||
#define SECONDS_PER_MINUTE 60.0f
|
#define SECONDS_PER_MINUTE 60.0f
|
||||||
|
|
||||||
static inline timeDelta_t cmpTimeUs(timeUs_t a, timeUs_t b) { return (timeDelta_t)(a - b); }
|
static inline timeDelta_t cmpTimeUs(timeUs_t a, timeUs_t b) { return (timeDelta_t)(a - b); }
|
||||||
|
static inline timeDelta_t cmpTimeMs(timeMs_t a, timeMs_t b) { return (timeDelta_t)(a - b); }
|
||||||
static inline int32_t cmpTimeCycles(uint32_t a, uint32_t b) { return (int32_t)(a - b); }
|
static inline int32_t cmpTimeCycles(uint32_t a, uint32_t b) { return (int32_t)(a - b); }
|
||||||
|
|
||||||
#define FORMATTED_DATE_TIME_BUFSIZE 30
|
#define FORMATTED_DATE_TIME_BUFSIZE 30
|
||||||
|
|
|
@ -149,7 +149,20 @@ static bool allMotorsAreIdle(void)
|
||||||
|
|
||||||
bool dshotStreamingCommandsAreEnabled(void)
|
bool dshotStreamingCommandsAreEnabled(void)
|
||||||
{
|
{
|
||||||
return motorIsEnabled() && motorGetMotorEnableTimeMs() && millis() > motorGetMotorEnableTimeMs() + DSHOT_PROTOCOL_DETECTION_DELAY_MS;
|
static bool firstCommand = true;
|
||||||
|
bool goodMotorDetectDelay;
|
||||||
|
|
||||||
|
if (firstCommand) {
|
||||||
|
goodMotorDetectDelay = motorGetMotorEnableTimeMs() && (cmpTimeMs(millis(), motorGetMotorEnableTimeMs()) > DSHOT_PROTOCOL_DETECTION_DELAY_MS);
|
||||||
|
|
||||||
|
if (goodMotorDetectDelay) {
|
||||||
|
firstCommand = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
goodMotorDetectDelay = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return motorIsEnabled() && goodMotorDetectDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dshotCommandsAreEnabled(dshotCommandType_e commandType)
|
static bool dshotCommandsAreEnabled(dshotCommandType_e commandType)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue