diff --git a/src/main/main.c b/src/main/main.c index df7461bcdd..0d27dea6b0 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -25,18 +25,12 @@ #include "scheduler/scheduler.h" -void main_step(void) -{ - scheduler(); - processLoopback(); -} - -#ifndef NOMAIN int main(void) { init(); while (true) { - main_step(); + scheduler(); + processLoopback(); } + return 0; } -#endif diff --git a/src/main/scheduler/scheduler.c b/src/main/scheduler/scheduler.c index 137dba6702..4ff2fda49b 100755 --- a/src/main/scheduler/scheduler.c +++ b/src/main/scheduler/scheduler.c @@ -178,7 +178,7 @@ void setTaskEnabled(cfTaskId_e taskId, bool enabled) } } -uint32_t getTaskDeltaTime(cfTaskId_e taskId) +timeDelta_t getTaskDeltaTime(cfTaskId_e taskId) { if (taskId == TASK_SELF) { return currentTask->taskLatestDeltaTime; diff --git a/src/main/scheduler/scheduler.h b/src/main/scheduler/scheduler.h index ea12cd6fca..e84ca3822c 100644 --- a/src/main/scheduler/scheduler.h +++ b/src/main/scheduler/scheduler.h @@ -39,12 +39,12 @@ typedef struct { const char * taskName; const char * subTaskName; bool isEnabled; - timeUs_t desiredPeriod; uint8_t staticPriority; + timeDelta_t desiredPeriod; + timeDelta_t latestDeltaTime; timeUs_t maxExecutionTime; timeUs_t totalExecutionTime; timeUs_t averageExecutionTime; - timeUs_t latestDeltaTime; } cfTaskInfo_t; typedef enum { @@ -118,23 +118,23 @@ typedef enum { } cfTaskId_e; typedef struct { - /* Configuration */ + // Configuration const char * taskName; const char * subTaskName; bool (*checkFunc)(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs); void (*taskFunc)(timeUs_t currentTimeUs); - uint32_t desiredPeriod; // target period of execution + timeDelta_t desiredPeriod; // target period of execution const uint8_t staticPriority; // dynamicPriority grows in steps of this size, shouldn't be zero - /* Scheduling */ + // Scheduling uint16_t dynamicPriority; // measurement of how old task was last executed, used to avoid task starvation uint16_t taskAgeCycles; + timeDelta_t taskLatestDeltaTime; timeUs_t lastExecutedAt; // last time of invocation timeUs_t lastSignaledAt; // time of invocation event for event-driven tasks - uint32_t taskLatestDeltaTime; #ifndef SKIP_TASK_STATISTICS - /* Statistics */ + // Statistics timeUs_t movingSumExecutionTime; // moving sum over 32 samples timeUs_t maxExecutionTime; timeUs_t totalExecutionTime; // total time consumed by task since boot @@ -148,7 +148,7 @@ void getCheckFuncInfo(cfCheckFuncInfo_t *checkFuncInfo); void getTaskInfo(cfTaskId_e taskId, cfTaskInfo_t *taskInfo); void rescheduleTask(cfTaskId_e taskId, uint32_t newPeriodMicros); void setTaskEnabled(cfTaskId_e taskId, bool newEnabledState); -uint32_t getTaskDeltaTime(cfTaskId_e taskId); +timeDelta_t getTaskDeltaTime(cfTaskId_e taskId); void schedulerSetCalulateTaskStatistics(bool calculateTaskStatistics); void schedulerResetTaskStatistics(cfTaskId_e taskId);