Improve unittest build system (#13554)
[betaflight.git] / src / test / unit / scheduler_stubs.c
blob227edc0d6802fb67804ee7f440fed414ed0a7311
1 /*
2 * This file is part of Betaflight.
4 * Betaflight is free software. You can redistribute this software
5 * and/or modify this software under the terms of the GNU General
6 * Public License as published by the Free Software Foundation,
7 * either version 3 of the License, or (at your option) any later
8 * version.
10 * Betaflight is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this software.
19 * If not, see <http://www.gnu.org/licenses/>.
22 #include "pg/pg.h"
23 #include "pg/pg_ids.h"
25 #include "scheduler/scheduler.h"
26 #include "scheduler_stubs.h"
28 PG_REGISTER_WITH_RESET_TEMPLATE(schedulerConfig_t, schedulerConfig, PG_SCHEDULER_CONFIG, 0);
30 PG_RESET_TEMPLATE(schedulerConfig_t, schedulerConfig,
31 .rxRelaxDeterminism = 25,
32 .osdRelaxDeterminism = 25,
35 #define TEST_GYRO_SAMPLE_HZ 8000
37 void taskGyroSample(timeUs_t);
38 void taskFiltering(timeUs_t);
39 void taskMainPidLoop(timeUs_t);
40 void taskUpdateAccelerometer(timeUs_t);
41 void taskHandleSerial(timeUs_t);
42 void taskUpdateBatteryVoltage(timeUs_t);
43 bool rxUpdateCheck(timeUs_t, timeDelta_t);
44 void taskUpdateRxMain(timeUs_t);
45 void imuUpdateAttitude(timeUs_t);
46 void dispatchProcess(timeUs_t);
47 bool osdUpdateCheck(timeUs_t, timeDelta_t);
48 void osdUpdate(timeUs_t);
50 task_attribute_t task_attributes[TASK_COUNT] = {
51 [TASK_SYSTEM] = {
52 .taskName = "SYSTEM",
53 .taskFunc = taskSystemLoad,
54 .desiredPeriodUs = TASK_PERIOD_HZ(10),
55 .staticPriority = TASK_PRIORITY_MEDIUM_HIGH,
57 [TASK_GYRO] = {
58 .taskName = "GYRO",
59 .taskFunc = taskGyroSample,
60 .desiredPeriodUs = TASK_PERIOD_HZ(TEST_GYRO_SAMPLE_HZ),
61 .staticPriority = TASK_PRIORITY_REALTIME,
63 [TASK_FILTER] = {
64 .taskName = "FILTER",
65 .taskFunc = taskFiltering,
66 .desiredPeriodUs = TASK_PERIOD_HZ(4000),
67 .staticPriority = TASK_PRIORITY_REALTIME,
69 [TASK_PID] = {
70 .taskName = "PID",
71 .taskFunc = taskMainPidLoop,
72 .desiredPeriodUs = TASK_PERIOD_HZ(4000),
73 .staticPriority = TASK_PRIORITY_REALTIME,
75 [TASK_ACCEL] = {
76 .taskName = "ACCEL",
77 .taskFunc = taskUpdateAccelerometer,
78 .desiredPeriodUs = TASK_PERIOD_HZ(1000),
79 .staticPriority = TASK_PRIORITY_MEDIUM,
81 [TASK_ATTITUDE] = {
82 .taskName = "ATTITUDE",
83 .taskFunc = imuUpdateAttitude,
84 .desiredPeriodUs = TASK_PERIOD_HZ(100),
85 .staticPriority = TASK_PRIORITY_MEDIUM,
87 [TASK_RX] = {
88 .taskName = "RX",
89 .checkFunc = rxUpdateCheck,
90 .taskFunc = taskUpdateRxMain,
91 .desiredPeriodUs = TASK_PERIOD_HZ(50),
92 .staticPriority = TASK_PRIORITY_HIGH,
94 [TASK_SERIAL] = {
95 .taskName = "SERIAL",
96 .taskFunc = taskHandleSerial,
97 .desiredPeriodUs = TASK_PERIOD_HZ(100),
98 .staticPriority = TASK_PRIORITY_LOW,
100 [TASK_DISPATCH] = {
101 .taskName = "DISPATCH",
102 .taskFunc = dispatchProcess,
103 .desiredPeriodUs = TASK_PERIOD_HZ(1000),
104 .staticPriority = TASK_PRIORITY_HIGH,
106 [TASK_BATTERY_VOLTAGE] = {
107 .taskName = "BATTERY_VOLTAGE",
108 .taskFunc = taskUpdateBatteryVoltage,
109 .desiredPeriodUs = TASK_PERIOD_HZ(50),
110 .staticPriority = TASK_PRIORITY_MEDIUM,
112 [TASK_OSD] = {
113 .taskName = "OSD",
114 .checkFunc = osdUpdateCheck,
115 .taskFunc = osdUpdate,
116 .desiredPeriodUs = TASK_PERIOD_HZ(12),
117 .staticPriority = TASK_PRIORITY_LOW,