SikendeRTOS
RTOS for ARM Cortex M3+ SoCs designed and written from scratch
OS.h
Go to the documentation of this file.
1
5#ifndef __OS_H
6#define __OS_H
7
8
9#include "OSConfig.h"
10#include "cpu_vars.h"
11
12
16struct Sema4{
17 INT32 Value; // 0 is free, >0 not free I think
19};
20typedef struct Sema4 Sema4Type;
21
22
27struct MailBox{
31};
32typedef struct MailBox MailBoxType;
33
34
39void OS_Init(void);
40
41
47void OS_InitSemaphore(Sema4Type *semaPt, INT32 value);
48
49
54void OS_Wait(Sema4Type *semaPt);
55
56
60void OS_Signal(Sema4Type *semaPt);
61
62
67void OS_bWait(Sema4Type *semaPt);
68
69
70
74void OS_bSignal(Sema4Type *semaPt);
75
76
81
82
83
87void OS_ASM_Wait(Sema4Type *semaPt);
88
89
97INT8 OS_AddThread(void(*task)(void), INT32U priority);
98
99
104INT32U OS_IdThread(void);
105
106
114INT8 OS_AddPeriodicThread(void(*task)(void), INT32U period, INT32U priority);
115
116
117
124INT8 OS_AddSW1Task(void(*task)(void), INT32U priority);
125
126
133INT8 OS_AddSW2Task(void(*task)(void), INT32U priority);
134
135
140void OS_Sleep(INT32U sleepTime);
141
142
143
147void OS_Kill(void);
148
149
150
154void OS_Suspend(void);
155
156
157
161void OS_Fifo_Init(void);
162
163
164
171
172
173
178FIFO_t OS_Fifo_Get(void);
179
180
181
186INT32U OS_Fifo_Size(void);
187
188
192void OS_MailBox_Init(void);
193
194
200
201
207
208
212INT32U OS_Time(void);
213
214
222
223
227void OS_ClearMsTime(void);
228
229
235
236
241void OS_Launch(INT32U theTimeSlice);
242
243
248void OS_ClearMsTime(void);
249
250
251
252
253
254#endif // _OS_H_
int8_t INT8
Definition: cpu_vars.h:17
int32_t INT32
Definition: cpu_vars.h:19
uint32_t INT32U
Definition: cpu_vars.h:15
void OS_Signal(Sema4Type *semaPt)
This function(Spinlock) will signal that a mutual exclusion is taking place in a function.
Definition: OS.c:483
INT8 OS_AddPeriodicThread(void(*task)(void), INT32U period, INT32U priority)
Adds periodic background thread. Cannot spin, sleep, die, rest, etc. cause it's ISR,...
Definition: OS.c:593
void OS_bWait(Sema4Type *semaPt)
Wait on semaphore, binary.
Definition: OS.c:499
void OS_Suspend(void)
This function suspends current thread by forcing context switch call.
Definition: OS.c:343
INT32U OS_Fifo_Size(void)
Gets current size of FiFo.
Definition: OS.c:691
INT8 OS_AddThread(void(*task)(void), INT32U priority)
This function decides next thread to run, now uses priority scheduler.
Definition: OS.c:386
INT8 OS_Fifo_Put(FIFO_t data)
Definition: OS.c:659
INT32U OS_IdThread(void)
Get current thread ID.
Definition: OS.c:448
void OS_MailBox_Init(void)
Initialize mailbox for OS.
Definition: OS.c:701
void OS_Fifo_Init(void)
Definition: OS.c:646
INT32U OS_ReadMsTime(void)
Definition: OS.c:767
void OS_Kill(void)
This function kill/deletes current thread from schedule.
Definition: OS.c:542
void OS_MailBox_Send(INT32U data)
This function will be called from a foreground thread It will spin/block if the MailBox contains data...
Definition: OS.c:715
INT32U OS_MailBox_Recv(void)
This function will be called from a foreground thread It will spin/block if the MailBox is empty.
Definition: OS.c:729
INT32U OS_TimeDifference(INT32U start, INT32U stop)
Definition: OS.c:749
void OS_bSignal(Sema4Type *semaPt)
Signal semaphore to be free, set to 1.
Definition: OS.c:514
void OS_Wait(Sema4Type *semaPt)
semaphore value decrement
Definition: OS.c:468
INT8 OS_AddSW2Task(void(*task)(void), INT32U priority)
This function adds a thread to run and its priority when a button is pressed.
Definition: OS.c:638
INT32U OS_Time(void)
Definition: OS.c:740
void OS_Launch(INT32U theTimeSlice)
This function starts the scheduler and enables interrupts.
Definition: OS.c:285
void OS_Sleep(INT32U sleepTime)
This function puts a thread to sleep.
Definition: OS.c:528
INT8 OS_AddSW1Task(void(*task)(void), INT32U priority)
This function adds a thread to run and its priority when a button is pressed.
Definition: OS.c:626
void OS_Init(void)
initialize operating system, disable interrupts until OS_Launch initialize OS controlled I/O: serial,...
Definition: OS.c:188
void OS_ClearMsTime(void)
Definition: OS.c:760
void OS_InitSemaphore(Sema4Type *semaPt, INT32 value)
Initialize semaphore to given value.
Definition: OS.c:456
void OS_ASM_Wait(Sema4Type *semaPt)
Spinlock semaphore wait using ARM exclusion.
void OS_ASM_Signal(Sema4Type *semaPt)
Spinlock semaphore signal using ARM exclusion.
FIFO_t OS_Fifo_Get(void)
Definition: OS.c:676
Configuration setup for OS.
INT32 FIFO_t
Definition: OSConfig.h:42
Contains CPU/Compilter variables.
Definition: OS.h:27
Sema4Type Full
Definition: OS.h:29
Sema4Type Empty
Definition: OS.h:28
INT32U data
Definition: OS.h:30
Definition: OS.h:16
struct Tcb * blockThreads
Definition: OS.h:18
INT32 Value
Definition: OS.h:17
Definition: OS.c:48