#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "queue.h"
#include "../../Inc/Scheduler/Scheduler.h"
Go to the source code of this file.
◆ WORK_QUEUE_SIZE
| #define WORK_QUEUE_SIZE 32 |
◆ WORKER_PRIORITY
| #define WORKER_PRIORITY (tskIDLE_PRIORITY + 2) |
◆ WORKER_STACK_SIZE
| #define WORKER_STACK_SIZE 1024 |
◆ SchedulerCleanup()
| void SchedulerCleanup |
( |
void |
| ) |
|
Definition at line 225 of file Scheduler.c.
225 {
226
230 }
231
232
236 }
237
238
243 }
244 }
245
247
248}
static ScheduledUpdateable scheduledTasks[MAX_SENSORS]
static QueueHandle_t workQueue
static TaskHandle_t workerTaskHandle
◆ SchedulerGetStats()
| void SchedulerGetStats |
( |
void |
| ) |
|
Definition at line 202 of file Scheduler.c.
202 {
203 UBaseType_t queueLength = uxQueueMessagesWaiting(
workQueue);
204 UBaseType_t queueSpaces = uxQueueSpacesAvailable(
workQueue);
205
206
207
208
209
210
212 TaskStatus_t taskStatus;
214
215
216 }
217
219
220
221 }
222}
◆ SchedulerInit()
Definition at line 80 of file Scheduler.c.
80 {
83
84
87
88 return;
89 }
90
91
94
95 return;
96 }
97
98
99
100
101 for (
int i = 0; updatableArray[i] != NULL && i <
MAX_SENSORS; i++) {
103
104 if (updateable->
hz <= 0 || updateable->
hz >
MAX_HZ) {
105
106
107 continue;
108 }
109
110
111 TickType_t period = pdMS_TO_TICKS(1000 / updateable->
hz);
112 if (period == 0) period = 1;
113
114
115 char timerName[32];
116
117
118
119 TimerHandle_t timer = xTimerCreate(
120 timerName,
121 period,
122 pdTRUE,
123 updateable,
125 );
126
127 if (timer != NULL) {
131
132
133
134 } else {
135
136 }
137 }
138
139
140}
#define WORKER_STACK_SIZE
static void workerTask(void *pvParameters)
static void updateableTimerCallback(TimerHandle_t xTimer)
◆ SchedulerResumeUpdateable()
| void SchedulerResumeUpdateable |
( |
const char * |
name | ) |
|
Definition at line 189 of file Scheduler.c.
189 {
194
195 return;
196 }
197 }
198 }
199
200}
◆ SchedulerRun()
Definition at line 142 of file Scheduler.c.
142 {
144
145
146 int started = 0;
149 started++;
150 } else {
151
152
153 }
154 }
155
156
157
158
159 vTaskStartScheduler();
160}
◆ SchedulerStop()
Definition at line 162 of file Scheduler.c.
162 {
164
165
169 }
170 }
171
172
173}
◆ SchedulerSuspendUpdateable()
| void SchedulerSuspendUpdateable |
( |
const char * |
name | ) |
|
Definition at line 176 of file Scheduler.c.
176 {
181
182 return;
183 }
184 }
185 }
186
187}
◆ updateableTimerCallback()
| static void updateableTimerCallback |
( |
TimerHandle_t |
xTimer | ) |
|
|
static |
Definition at line 59 of file Scheduler.c.
59 {
61
62 if (updateable != NULL &&
workQueue != NULL) {
65 .timestamp = xTaskGetTickCount()
66 };
67
68
69 BaseType_t xHigherPriorityTaskWoken = pdFALSE;
70 if (xQueueSendFromISR(
workQueue, &workItem, &xHigherPriorityTaskWoken) != pdTRUE) {
71
72
73 }
74
75
76 portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
77 }
78}
◆ workerTask()
| static void workerTask |
( |
void * |
pvParameters | ) |
|
|
static |
Definition at line 30 of file Scheduler.c.
30 {
32
33 while (1) {
34
35 if (xQueueReceive(
workQueue, &workItem, portMAX_DELAY) == pdTRUE) {
37
38 TickType_t startTime = xTaskGetTickCount();
39
40
44
45
46 TickType_t executionTime = xTaskGetTickCount() - startTime;
47 TickType_t maxTime = pdMS_TO_TICKS(1000 / workItem.
updateable->
hz) / 2;
48
49 if (executionTime > maxTime) {
50
51
52 }
53 }
54 }
55 }
56}
void TaskInit(Task *task, Updateable *updateable, int hz)
Initializes a task with the given sensor and update frequency.
void TaskExecute(Task *task)
Executes the task by calling the sensor's update function.
◆ scheduledTasks
◆ taskCount
◆ workerTaskHandle
| TaskHandle_t workerTaskHandle = NULL |
|
static |
◆ workQueue
| QueueHandle_t workQueue = NULL |
|
static |