-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRTOS_private.h
172 lines (144 loc) · 4.38 KB
/
RTOS_private.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* RTOS_private.h
*
* Created on: 14 Sep 2019
* Author: Yahia
*/
#ifndef RTOS_PRIVATE_H_
#define RTOS_PRIVATE_H_
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Macro expressions */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define NULL 0
#define LowestPriority (MaxTaskNum - 1)
#define ThereWasARunningTask (RunningTask != (LowestPriority+1))
#define TaskSwitching (NonCompleted_Task_index != 0)
#define NoTaskIsReady (RunningFlag == 0)
#define NoRunningTask (RunningTask = (LowestPriority+1))
#ifndef OSTaskStateNoTask
#define OSTaskStateNoTask 4
#endif
#ifndef OSTaskPendOnWaiting
#define OSTaskPendOnWaiting 3
#endif
#ifndef MutServiceID
#define MutServiceID 'M'
#endif
#ifndef EventServiceID
#define EventServiceID 'E'
#endif
#ifndef MutReady
#define MutReady 0
#endif
#ifndef MutTaken
#define MutTaken 1
#endif
#ifndef NewTick
#define NewTick 0
#endif
#ifndef TaskIsOver
#define TaskIsOver 1
#endif
#ifndef MutexReleased
#define MutexReleased 2
#endif
#define SchedulerOn 1
#define SchedulerOff 0
/* OS_Handler
* Function Description: Handle new timer tick
This function is called by the timer handler
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
void OS_Handler(void);
/* CheckPendingTasks
* Function Description: Check the pend on values in the TCBs of pend tasks
This function is called at the beginning of starting OS function
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
static void CheckPendingTasks(void);
/* CheckPriority
* Function Description: Check priority of a specific task
This function is called by OS
* Parameters(In): Prior --> Priority of the task.
* Parameters(Out): None.
* Return Value: 1 --> if the priority exists
0 --> if the priority doesn't exist
* */
static uint8 CheckPriority(uint8 Prior);
/* DeleteFromPeriodicQueue
* Function Description: Delete task from TCB array
This function is called by the OS
* Parameters(In): Index --> Index of the task in the TCB array.
* Parameters(Out): None.
* Return Value: None.
* */
static void DeleteFromPeriodicQueue(uint8 Index);
/* StartScheduling
* Function Description: Scheduling on the tasks
This function is called by OS
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
static void StartScheduling(void);
/* UpdateReleaseTime
* Function Description: Update the release time of the tasks
This function is called by OS in the beginning of timer handler
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
static void UpdateReleaseTime(void);
/* AddTaskToPeriodicQueue
* Function Description: Adding Task to TCB array
This function is called by OS
* Parameters(In): PtrToTaskStruct --> Pointer to task's TCB.
* Parameters(Out): None.
* Return Value: None.
* */
static void AddTaskToPeriodicQueue(TCB* PtrToTaskStruct);
/* SaveContext
* Function Description: Saving context of the interrupted task
This function is called by OS in the case of context switching
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
static void SaveContext(void);
/* RestoreContext
* Function Description: Restoring context of the interrupted task
This function is called by OS after handling context switching context switching
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
static void RestoreContext(void);
/* Scheduler
* Function Description: Scheduler function
This function is called by OS
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
void Scheduler(void);
/* InitiatePeriodicQueue
* Function Description: Initialise TCB array
This function is called by RTOS_Init
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
static void InitiatePeriodicQueue(void);
/* InitiatePeriodInitiateMutexicQueue
* Function Description: Initialise mutex array
This function is called by RTOS_Init
* Parameters(In): None.
* Parameters(Out): None.
* Return Value: None.
* */
void InitiateMutex(void);
#endif /* RTOS_PRIVATE_H_ */