Save commit
Small save commit for temporary branch change. Added some task definitions.
This commit is contained in:
parent
8181a13122
commit
7d00a65cd5
@ -13,18 +13,18 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "stm32f4xx_revo.h"
|
||||
|
||||
|
||||
/* Enum containing all the possible task priorities */
|
||||
typedef enum
|
||||
{
|
||||
IDLE = 0,
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
REALTIME,
|
||||
MAX_PRIORITY = 255
|
||||
PRIORITY_IDLE = 0,
|
||||
PRIORITY_LOW,
|
||||
PRIORITY_MEDIUM,
|
||||
PRIORITY_HIGH,
|
||||
PRIORITY_REALTIME,
|
||||
PRIORITY_MAX_PRIORITY = 255
|
||||
} taskPriority_t;
|
||||
|
||||
|
||||
|
@ -11,12 +11,15 @@
|
||||
#ifndef SCHEDULER_TASKS_H_
|
||||
#define SCHEDULER_TASKS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//All the task functions in the system, one for each task
|
||||
void systemTaskSystem(void);
|
||||
void systemTaskGyroPid(void);
|
||||
void systemTaskAccelerometer(void);
|
||||
void systemTaskAttitude(void);
|
||||
void systemTaskRx(void);
|
||||
bool systemTaskRxCheck(uint32_t currentDeltaTime);
|
||||
void systemTaskSerial(void);
|
||||
void systemTaskBattery(void);
|
||||
void systemTaskBaro(void);
|
||||
|
@ -92,12 +92,24 @@
|
||||
|
||||
|
||||
/* Baro */
|
||||
//#define BARO
|
||||
|
||||
|
||||
/* Compass */
|
||||
//#define COMPASS
|
||||
|
||||
|
||||
/* GPS */
|
||||
//#define GPS
|
||||
|
||||
|
||||
/* Sonar */
|
||||
//#define SONAR
|
||||
|
||||
|
||||
/* Beeper */
|
||||
//#define BEEPER
|
||||
|
||||
|
||||
|
||||
/* Define all the moter of the system, servos + extra */
|
||||
|
@ -8,8 +8,9 @@
|
||||
* -------- ---- ----------- *
|
||||
***************************************************************************/
|
||||
|
||||
#include "Scheduler/scheduler.h"
|
||||
#include "stm32f4xx_revo.h"
|
||||
#include "Scheduler/scheduler.h"
|
||||
#include "Scheduler/tasks.h"
|
||||
|
||||
|
||||
//Todo: change for several instances where 0 is used as null to the define value NULL
|
||||
@ -252,7 +253,7 @@ void scheduler(void)
|
||||
bool changeTask = false; //flag used to check if the task should be updated
|
||||
/* If a realtime task is found the bool isRealTime will be set to true
|
||||
* meaning no other tasks than realtime will be able to enter the function */
|
||||
if (taskToRun->staticPriority == REALTIME) //if it is a realtime task
|
||||
if (taskToRun->staticPriority == PRIORITY_REALTIME) //if it is a realtime task
|
||||
{
|
||||
isRealTime = true; //toggle this flag so that no non realtime task can be selected this cycle
|
||||
|
||||
|
@ -11,86 +11,129 @@
|
||||
#include "Scheduler/tasks.h"
|
||||
#include "Scheduler/scheduler.h"
|
||||
|
||||
#define GetUpdateRateHz(x) (1000000 / x) //x is the desired hz value given in micro seconds
|
||||
//initiate the values for all the tasks
|
||||
//This information needs to be changed when functionality and setting for the tasks needs to be changed
|
||||
// - Note: desiredPeriod is given in micro seconds, writing for example (1000000 / 10) means 10 hz rate
|
||||
task_t SystemTasks[TASK_COUNT] =
|
||||
{
|
||||
|
||||
[TASK_SYSTEM] =
|
||||
{
|
||||
|
||||
.taskName = "SYSTEM",
|
||||
.taskFunction = systemTaskSystem,
|
||||
.desiredPeriod = GetUpdateRateHz(10), //10 hz update rate (100 ms)
|
||||
.staticPriority = PRIORITY_HIGH,
|
||||
},
|
||||
|
||||
[TASK_GYROPID] =
|
||||
{
|
||||
|
||||
.taskName = "PID",
|
||||
.subTaskName = "GYRO",
|
||||
.taskFunction = systemTaskGyroPid,
|
||||
.desiredPeriod = GetUpdateRateHz(1000), //1000 hz update rate (1 ms)
|
||||
.staticPriority = PRIORITY_REALTIME,
|
||||
},
|
||||
|
||||
[TASK_ACCELEROMETER] =
|
||||
{
|
||||
|
||||
.taskName = "ACCELEROMTER",
|
||||
.taskFunction = systemTaskAccelerometer,
|
||||
.desiredPeriod = GetUpdateRateHz(1000), //1000 hz update rate (1 ms)
|
||||
.staticPriority = PRIORITY_MEDIUM,
|
||||
},
|
||||
|
||||
[TASK_ATTITUDE] =
|
||||
{
|
||||
|
||||
.taskName = "ATTITUDE",
|
||||
.taskFunction = systemTaskAttitude,
|
||||
.desiredPeriod = GetUpdateRateHz(100), //100 hz update rate (10 ms)
|
||||
.staticPriority = PRIORITY_MEDIUM,
|
||||
},
|
||||
|
||||
[TASK_RX] =
|
||||
{
|
||||
|
||||
.taskName = "RX",
|
||||
.taskFunction = systemTaskRx, //Event handler function, will check if a message is obtainable
|
||||
.checkEventTriggered = systemTaskRxCheck,
|
||||
.desiredPeriod = GetUpdateRateHz(50), //Standard scheduling should not be used if event based, used as fail safe
|
||||
.staticPriority = PRIORITY_HIGH,
|
||||
},
|
||||
|
||||
[TASK_SERIAL] =
|
||||
{
|
||||
|
||||
.taskName = "SERIAL",
|
||||
.taskFunction = systemTaskSerial,
|
||||
.desiredPeriod = GetUpdateRateHz(100), //100 hz update rate (10 ms)
|
||||
.staticPriority = PRIORITY_LOW,
|
||||
},
|
||||
|
||||
[TASK_BATTERY] =
|
||||
{
|
||||
|
||||
.taskName = "BATTERY",
|
||||
.taskFunction = systemTaskBattery,
|
||||
.desiredPeriod = GetUpdateRateHz(50),
|
||||
.staticPriority = PRIORITY_MEDIUM,
|
||||
},
|
||||
|
||||
#ifdef BARO
|
||||
[TASK_BARO] =
|
||||
{
|
||||
|
||||
.taskName = "BAROMETER",
|
||||
.taskFunction = systemTaskBaro,
|
||||
.desiredPeriod = GetUpdateRateHz(20),
|
||||
.staticPriority = PRIORITY_LOW,
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef COMPASS
|
||||
[TASK_COMPASS] =
|
||||
{
|
||||
|
||||
.taskName = "COMPASS",
|
||||
.taskFunction = systemTaskCompass,
|
||||
.desiredPeriod = GetUpdateRateHz(10),
|
||||
.staticPriority = PRIORITY_LOW,
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef GPS
|
||||
[TASK_GPS] =
|
||||
{
|
||||
|
||||
},
|
||||
[TASK_GPS] =
|
||||
{
|
||||
.taskName = "GPS",
|
||||
.taskFunction = systemTaskGps,
|
||||
.desiredPeriod = GetUpdateRateHz(10),
|
||||
.staticPriority = PRIORITY_MEDIUM,
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef SONAR
|
||||
[TASK_SONAR] =
|
||||
{
|
||||
|
||||
},
|
||||
[TASK_SONAR] =
|
||||
{
|
||||
.taskName = "SONAR",
|
||||
.taskFunction = systemTaskSonar,
|
||||
.desiredPeriod = GetUpdateRateHz(20),
|
||||
.staticPriority = PRIORITY_LOW,
|
||||
},
|
||||
#endif
|
||||
|
||||
#if defined(BARO) || defined(SONAR)
|
||||
[TASK_ALTITUDE] =
|
||||
{
|
||||
|
||||
},
|
||||
[TASK_ALTITUDE] =
|
||||
{
|
||||
.taskName = "ALTITUDE",
|
||||
.taskFunction = systemTaskAltitude,
|
||||
.desiredPeriod = GetUpdateRateHz(40),
|
||||
.staticPriority = PRIORITY_LOW,
|
||||
},
|
||||
#endif
|
||||
|
||||
#if BEEPER
|
||||
[TASK_BEEPER] =
|
||||
{
|
||||
|
||||
},
|
||||
[TASK_BEEPER] =
|
||||
{
|
||||
.taskName = "BEEPER",
|
||||
.taskFunction = systemTaskBeeper,
|
||||
.desiredPeriod = GetUpdateRateHz(100),
|
||||
.staticPriority = PRIORITY_LOW,
|
||||
},
|
||||
#endif
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user