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
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/>.
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
] = {
53 .taskFunc
= taskSystemLoad
,
54 .desiredPeriodUs
= TASK_PERIOD_HZ(10),
55 .staticPriority
= TASK_PRIORITY_MEDIUM_HIGH
,
59 .taskFunc
= taskGyroSample
,
60 .desiredPeriodUs
= TASK_PERIOD_HZ(TEST_GYRO_SAMPLE_HZ
),
61 .staticPriority
= TASK_PRIORITY_REALTIME
,
65 .taskFunc
= taskFiltering
,
66 .desiredPeriodUs
= TASK_PERIOD_HZ(4000),
67 .staticPriority
= TASK_PRIORITY_REALTIME
,
71 .taskFunc
= taskMainPidLoop
,
72 .desiredPeriodUs
= TASK_PERIOD_HZ(4000),
73 .staticPriority
= TASK_PRIORITY_REALTIME
,
77 .taskFunc
= taskUpdateAccelerometer
,
78 .desiredPeriodUs
= TASK_PERIOD_HZ(1000),
79 .staticPriority
= TASK_PRIORITY_MEDIUM
,
82 .taskName
= "ATTITUDE",
83 .taskFunc
= imuUpdateAttitude
,
84 .desiredPeriodUs
= TASK_PERIOD_HZ(100),
85 .staticPriority
= TASK_PRIORITY_MEDIUM
,
89 .checkFunc
= rxUpdateCheck
,
90 .taskFunc
= taskUpdateRxMain
,
91 .desiredPeriodUs
= TASK_PERIOD_HZ(50),
92 .staticPriority
= TASK_PRIORITY_HIGH
,
96 .taskFunc
= taskHandleSerial
,
97 .desiredPeriodUs
= TASK_PERIOD_HZ(100),
98 .staticPriority
= TASK_PRIORITY_LOW
,
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
,
114 .checkFunc
= osdUpdateCheck
,
115 .taskFunc
= osdUpdate
,
116 .desiredPeriodUs
= TASK_PERIOD_HZ(12),
117 .staticPriority
= TASK_PRIORITY_LOW
,