mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
184 lines
5 KiB
C
184 lines
5 KiB
C
/*
|
|
* This file is part of Cleanflight.
|
|
*
|
|
* Cleanflight is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Cleanflight is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
|
|
#include <platform.h>
|
|
|
|
#include "scheduler/scheduler.h"
|
|
#include "scheduler/scheduler_tasks.h"
|
|
|
|
cfTask_t cfTasks[TASK_COUNT] = {
|
|
[TASK_SYSTEM] = {
|
|
.taskName = "SYSTEM",
|
|
.taskFunc = taskSystem,
|
|
.desiredPeriod = 1000000 / 10, // run every 100 ms
|
|
.staticPriority = TASK_PRIORITY_HIGH,
|
|
},
|
|
|
|
[TASK_GYROPID] = {
|
|
.taskName = "PID",
|
|
.subTaskName = "GYRO",
|
|
.taskFunc = taskMainPidLoopCheck,
|
|
.desiredPeriod = TASK_GYROPID_DESIRED_PERIOD,
|
|
.staticPriority = TASK_PRIORITY_REALTIME,
|
|
},
|
|
|
|
[TASK_ACCEL] = {
|
|
.taskName = "ACCEL",
|
|
.taskFunc = taskUpdateAccelerometer,
|
|
.desiredPeriod = 1000000 / 100, // every 10ms
|
|
.staticPriority = TASK_PRIORITY_MEDIUM,
|
|
},
|
|
|
|
[TASK_ATTITUDE] = {
|
|
.taskName = "ATTITUDE",
|
|
.taskFunc = taskUpdateAttitude,
|
|
.desiredPeriod = 1000000 / 100,
|
|
.staticPriority = TASK_PRIORITY_MEDIUM,
|
|
},
|
|
|
|
[TASK_RX] = {
|
|
.taskName = "RX",
|
|
.checkFunc = taskUpdateRxCheck,
|
|
.taskFunc = taskUpdateRxMain,
|
|
.desiredPeriod = 1000000 / 50, // If event-based scheduling doesn't work, fallback to periodic scheduling
|
|
.staticPriority = TASK_PRIORITY_HIGH,
|
|
},
|
|
|
|
[TASK_SERIAL] = {
|
|
.taskName = "SERIAL",
|
|
.taskFunc = taskHandleSerial,
|
|
.desiredPeriod = 1000000 / 100, // 100 Hz should be enough to flush up to 115 bytes @ 115200 baud
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
|
|
[TASK_BATTERY] = {
|
|
.taskName = "BATTERY",
|
|
.taskFunc = taskUpdateBattery,
|
|
.desiredPeriod = 1000000 / 50, // 50 Hz
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
|
|
#ifdef BEEPER
|
|
[TASK_BEEPER] = {
|
|
.taskName = "BEEPER",
|
|
.taskFunc = taskUpdateBeeper,
|
|
.desiredPeriod = 1000000 / 100, // 100 Hz
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
|
|
#ifdef GPS
|
|
[TASK_GPS] = {
|
|
.taskName = "GPS",
|
|
.taskFunc = taskProcessGPS,
|
|
.desiredPeriod = 1000000 / 10, // GPS usually don't go raster than 10Hz
|
|
.staticPriority = TASK_PRIORITY_MEDIUM,
|
|
},
|
|
#endif
|
|
|
|
#ifdef MAG
|
|
[TASK_COMPASS] = {
|
|
.taskName = "COMPASS",
|
|
.taskFunc = taskUpdateCompass,
|
|
.desiredPeriod = 1000000 / 10, // Compass is updated at 10 Hz
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
|
|
#ifdef BARO
|
|
[TASK_BARO] = {
|
|
.taskName = "BARO",
|
|
.taskFunc = taskUpdateBaro,
|
|
.desiredPeriod = 1000000 / 20,
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
|
|
#ifdef SONAR
|
|
[TASK_SONAR] = {
|
|
.taskName = "SONAR",
|
|
.taskFunc = taskUpdateSonar,
|
|
.desiredPeriod = 1000000 / 20,
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
|
|
#if defined(BARO) || defined(SONAR)
|
|
[TASK_ALTITUDE] = {
|
|
.taskName = "ALTITUDE",
|
|
.taskFunc = taskCalculateAltitude,
|
|
.desiredPeriod = 1000000 / 40,
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
|
|
#ifdef TRANSPONDER
|
|
[TASK_TRANSPONDER] = {
|
|
.taskName = "TRANSPONDER",
|
|
.taskFunc = taskTransponder,
|
|
.desiredPeriod = 1000000 / 250, // 250 Hz
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
|
|
#ifdef DISPLAY
|
|
[TASK_DISPLAY] = {
|
|
.taskName = "DISPLAY",
|
|
.taskFunc = taskUpdateDisplay,
|
|
.desiredPeriod = 1000000 / 10,
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
#ifdef OSD
|
|
[TASK_OSD] = {
|
|
.taskName = "OSD",
|
|
.taskFunc = taskUpdateOsd,
|
|
.desiredPeriod = 1000000 / 60, // 60 Hz
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
#ifdef TELEMETRY
|
|
[TASK_TELEMETRY] = {
|
|
.taskName = "TELEMETRY",
|
|
.taskFunc = taskTelemetry,
|
|
.desiredPeriod = 1000000 / 250, // 250 Hz
|
|
.staticPriority = TASK_PRIORITY_IDLE,
|
|
},
|
|
#endif
|
|
|
|
#ifdef LED_STRIP
|
|
[TASK_LEDSTRIP] = {
|
|
.taskName = "LEDSTRIP",
|
|
.taskFunc = taskLedStrip,
|
|
.desiredPeriod = 1000000 / 10, // 10 Hz
|
|
.staticPriority = TASK_PRIORITY_LOW,
|
|
},
|
|
#endif
|
|
|
|
#ifdef USE_BST
|
|
[TASK_BST_MASTER_PROCESS] = {
|
|
.taskName = "BST_MASTER_PROCESS",
|
|
.taskFunc = taskBstMasterProcess,
|
|
.desiredPeriod = 1000000 / 50, // 50 Hz
|
|
.staticPriority = TASK_PRIORITY_IDLE,
|
|
},
|
|
#endif
|
|
};
|