1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

Fix tasks period calculation (#8782)

Fix tasks period calculation
This commit is contained in:
Michael Keller 2019-09-01 11:01:24 +12:00 committed by GitHub
commit e38d460acf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -348,6 +348,9 @@ FAST_CODE void scheduler(void)
if (selectedTask) {
// Found a task that should be run
selectedTask->taskLatestDeltaTime = currentTimeUs - selectedTask->lastExecutedAt;
#if defined(USE_TASK_STATISTICS)
float period = currentTimeUs - selectedTask->lastExecutedAt;
#endif
selectedTask->lastExecutedAt = currentTimeUs;
selectedTask->lastDesiredAt += (cmpTimeUs(currentTimeUs, selectedTask->lastDesiredAt) / selectedTask->desiredPeriod) * selectedTask->desiredPeriod;
selectedTask->dynamicPriority = 0;
@ -355,7 +358,6 @@ FAST_CODE void scheduler(void)
// Execute task
#if defined(USE_TASK_STATISTICS)
if (calculateTaskStatistics) {
float period = currentTimeUs - selectedTask->lastExecutedAt;
const timeUs_t currentTimeBeforeTaskCall = micros();
selectedTask->taskFunc(currentTimeBeforeTaskCall);
const timeUs_t taskExecutionTime = micros() - currentTimeBeforeTaskCall;