1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +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 mikeller
parent fd2d1185c0
commit 2a64051a22

View file

@ -344,6 +344,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;
@ -351,7 +354,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;