SRTOS
Loading...
Searching...
No Matches
task.h
Go to the documentation of this file.
1
5
6#ifndef TASK_H_
7#define TASK_H_
8
9#include "fault.h"
10#include "kernel_config.h"
11#include "mcu_macros.h"
12#include "system_funcs.h"
13#include <stddef.h>
14#include <stdint.h>
15#include <stdlib.h>
16
17
21typedef enum
22{
25} STATUS;
26
30typedef struct
31{
32 uint32_t *sp;
33 uint32_t priority;
34 uint32_t id;
35 uint32_t delayedUntil;
37} TCB;
38
42typedef struct TaskNode TaskNode;
43
49
55extern volatile uint32_t msTicks;
56
65
66
67uint32_t *initTaskStackFrame (uint32_t taskStack[], void (*taskFunc) (void));
68
83createTask (uint32_t taskStack[], void (*taskFunc) (void),
84 unsigned int priority, TCB *userAllocatedTCB,
85 TaskNode *userAllocatedTaskNode);
86
87void SysTick_Handler ();
88void PendSV_Handler ();
89void SVC_Handler ();
90void setPendSVPending ();
91
98void startScheduler ();
99
107void taskDelay (uint32_t ticksToDelay);
108
116uint32_t getCurTaskWordsAvailable ();
117
124
125#endif
Fault handling interface for SRTOS.
Core configuration parameters for SRTOS.
#define MAX_PRIORITIES
Number of unique task priority levels supported by the scheduler.
Memory-mapped register addresses and hardware access macros for the STM32F411VET6.
This struct is the Task Control Block (TCB), which is what stores a task's properties.
Definition task.h:31
uint32_t priority
Definition task.h:33
uint32_t delayedUntil
Definition task.h:35
uint32_t * sp
Definition task.h:32
uint32_t id
Definition task.h:34
uint32_t * stackFrameLowerBoundAddr
Definition task.h:36
TCB * taskTCB
Definition task.h:46
TaskNode * next
Definition task.h:47
This header files contains kernel functions that help control system behvaior.
volatile uint32_t msTicks
msTicks contains the amount of ticks that have occured since the scheduler started.
Definition task.c:10
TaskNode * readyTasksList[MAX_PRIORITIES]
This is a list of linked lists that contain the ready tasks.
Definition task.c:12
void taskDelay(uint32_t ticksToDelay)
This function will delay a task's execution for ticksToDelay ms.
Definition task.c:237
uint32_t * initTaskStackFrame(uint32_t taskStack[], void(*taskFunc)(void))
Initializes a task's stack frame.
Definition task.c:46
void startScheduler()
Start the scheduler.
Definition task.c:218
STATUS
This enum is used to indicate whether an operation was sucessful or not.
Definition task.h:22
@ STATUS_FAILURE
Definition task.h:24
@ STATUS_SUCCESS
Definition task.h:23
void PendSV_Handler()
This interrupt will be pended when a context switch is needed.
Definition task.c:166
void SVC_Handler()
This interrupt will be executed when the scheduler is started.
Definition task.c:203
void SysTick_Handler()
This interrupt handler will be called every 1 ms, checking if any tasks need to be unblocked or block...
Definition task.c:115
uint32_t getCurTaskWordsAvailable()
This function will return the minimum number of words left on the stack.
Definition task.c:503
void handleStackOverflow()
This function will be called when a stack overflow is detected. This function will only be called if ...
void setPendSVPending()
This function will be called when a context-switch is needed.
Definition task.c:231
STATUS createTask(uint32_t taskStack[], void(*taskFunc)(void), unsigned int priority, TCB *userAllocatedTCB, TaskNode *userAllocatedTaskNode)
Add a task to the scheduler's ready list.
Definition task.c:77