|
SRTOS
|
Task management and scheduler API for SRTOS. More...
#include "fault.h"#include "kernel_config.h"#include "mcu_macros.h"#include "system_funcs.h"#include <stddef.h>#include <stdint.h>#include <stdlib.h>Go to the source code of this file.
Classes | |
| struct | TCB |
| This struct is the Task Control Block (TCB), which is what stores a task's properties. More... | |
| struct | TaskNode |
Typedefs | |
| typedef struct TaskNode | TaskNode |
| This struct is used to represent a task in a linked list. | |
Enumerations | |
| enum | STATUS { STATUS_SUCCESS = 0 , STATUS_FAILURE = 1 } |
| This enum is used to indicate whether an operation was sucessful or not. More... | |
Functions | |
| uint32_t * | initTaskStackFrame (uint32_t taskStack[], void(*taskFunc)(void)) |
| Initializes a task's stack frame. | |
| STATUS | createTask (uint32_t taskStack[], void(*taskFunc)(void), unsigned int priority, TCB *userAllocatedTCB, TaskNode *userAllocatedTaskNode) |
| Add a task to the scheduler's ready list. | |
| void | SysTick_Handler () |
| This interrupt handler will be called every 1 ms, checking if any tasks need to be unblocked or blocked, and whether a context switch is needed. | |
| void | PendSV_Handler () |
| This interrupt will be pended when a context switch is needed. | |
| void | SVC_Handler () |
| This interrupt will be executed when the scheduler is started. | |
| void | setPendSVPending () |
| This function will be called when a context-switch is needed. | |
| void | startScheduler () |
| Start the scheduler. | |
| void | taskDelay (uint32_t ticksToDelay) |
| This function will delay a task's execution for ticksToDelay ms. | |
| uint32_t | getCurTaskWordsAvailable () |
| This function will return the minimum number of words left on the stack. | |
| void | handleStackOverflow () |
| This function will be called when a stack overflow is detected. This function will only be called if no other definitions are found. The user is recommended to define this themselves. | |
Variables | |
| volatile uint32_t | msTicks |
| msTicks contains the amount of ticks that have occured since the scheduler started. | |
| TaskNode * | readyTasksList [MAX_PRIORITIES] |
| This is a list of linked lists that contain the ready tasks. | |
Task management and scheduler API for SRTOS.
This header files provides all task control functions for SRTOS users.
Provides user-level functions to manage tasks.
Definition in file task.h.
| typedef struct TaskNode TaskNode |
| enum STATUS |
This enum is used to indicate whether an operation was sucessful or not.
| Enumerator | |
|---|---|
| STATUS_SUCCESS | |
| STATUS_FAILURE | |
Definition at line 21 of file task.h.
| STATUS createTask | ( | uint32_t | taskStack[], |
| void(* | taskFunc )(void), | ||
| unsigned int | priority, | ||
| TCB * | userAllocatedTCB, | ||
| TaskNode * | userAllocatedTaskNode ) |
Add a task to the scheduler's ready list.
| taskStack | The user-defined array of size STACK_SIZE |
| taskAddress | The address of the task function |
| priority | The task's priority which must be between 0 and MAX_PRIORITIES - 1, inclusive |
| userAllocatedTCB | The address of the task's TCB allocated by the user |
| userAllocatedTaskNode | The address of the task's TaskNode allocated by the user |
Definition at line 77 of file task.c.
| uint32_t getCurTaskWordsAvailable | ( | ) |
This function will return the minimum number of words left on the stack.
Definition at line 503 of file task.c.
| void handleStackOverflow | ( | ) |
This function will be called when a stack overflow is detected. This function will only be called if no other definitions are found. The user is recommended to define this themselves.
| uint32_t * initTaskStackFrame | ( | uint32_t | taskStack[], |
| void(* | taskFunc )(void) ) |
Initializes a task's stack frame.
This will populate the stack with a dummy xPSR and LR value to allow the task to begin execution. These values will be overwritten once the task starts executing. Also, this will fill the bottom of the stack with canary values so that stack overflows can be detected. The stack is also populated with usage watermarks.
| taskStack | The array created by the user |
| taskFunc | The address of the task function |
Definition at line 46 of file task.c.
| void PendSV_Handler | ( | ) |
This interrupt will be pended when a context switch is needed.
Definition at line 166 of file task.c.
| void setPendSVPending | ( | ) |
| void startScheduler | ( | ) |
Start the scheduler.
Definition at line 218 of file task.c.
| void SVC_Handler | ( | ) |
This interrupt will be executed when the scheduler is started.
Definition at line 203 of file task.c.
| void SysTick_Handler | ( | ) |
This interrupt handler will be called every 1 ms, checking if any tasks need to be unblocked or blocked, and whether a context switch is needed.
Definition at line 115 of file task.c.
| void taskDelay | ( | uint32_t | ticksToDelay | ) |
This function will delay a task's execution for ticksToDelay ms.
This function will move the current task to the blocked list for ticksToDelay ms. If there are no other tasks available to execute, the idleTask will execute.
| ticksToDelay | The number of milliseconds to delay a task's execution. |
Definition at line 237 of file task.c.
|
extern |
|
extern |