SikendeRTOS
RTOS for ARM Cortex M3+ SoCs designed and written from scratch
OS.h File Reference

Functions for OS. More...

#include "OSConfig.h"
#include "cpu_vars.h"
Include dependency graph for OS.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Sema4
 
struct  MailBox
 

Typedefs

typedef struct Sema4 Sema4Type
 
typedef struct MailBox MailBoxType
 

Functions

void OS_Init (void)
 initialize operating system, disable interrupts until OS_Launch initialize OS controlled I/O: serial, ADC, systick, LaunchPad I/O and timers More...
 
void OS_InitSemaphore (Sema4Type *semaPt, INT32 value)
 Initialize semaphore to given value. More...
 
void OS_Wait (Sema4Type *semaPt)
 semaphore value decrement More...
 
void OS_Signal (Sema4Type *semaPt)
 This function(Spinlock) will signal that a mutual exclusion is taking place in a function. More...
 
void OS_bWait (Sema4Type *semaPt)
 Wait on semaphore, binary. More...
 
void OS_bSignal (Sema4Type *semaPt)
 Signal semaphore to be free, set to 1. More...
 
void OS_ASM_Signal (Sema4Type *semaPt)
 Spinlock semaphore signal using ARM exclusion. More...
 
void OS_ASM_Wait (Sema4Type *semaPt)
 Spinlock semaphore wait using ARM exclusion. More...
 
INT8 OS_AddThread (void(*task)(void), INT32U priority)
 This function decides next thread to run, now uses priority scheduler. More...
 
INT32U OS_IdThread (void)
 Get current thread ID. More...
 
INT8 OS_AddPeriodicThread (void(*task)(void), INT32U period, INT32U priority)
 Adds periodic background thread. Cannot spin, sleep, die, rest, etc. cause it's ISR, depends on hardware for number of tasks possible No ID for this thread, must have mid-high priority to run properly. More...
 
INT8 OS_AddSW1Task (void(*task)(void), INT32U priority)
 This function adds a thread to run and its priority when a button is pressed. More...
 
INT8 OS_AddSW2Task (void(*task)(void), INT32U priority)
 This function adds a thread to run and its priority when a button is pressed. More...
 
void OS_Sleep (INT32U sleepTime)
 This function puts a thread to sleep. More...
 
void OS_Kill (void)
 This function kill/deletes current thread from schedule. More...
 
void OS_Suspend (void)
 This function suspends current thread by forcing context switch call. More...
 
void OS_Fifo_Init (void)
 
INT8 OS_Fifo_Put (FIFO_t data)
 
FIFO_t OS_Fifo_Get (void)
 
INT32U OS_Fifo_Size (void)
 Gets current size of FiFo. More...
 
void OS_MailBox_Init (void)
 Initialize mailbox for OS. More...
 
void OS_MailBox_Send (INT32U data)
 This function will be called from a foreground thread It will spin/block if the MailBox contains data not yet received. More...
 
INT32U OS_MailBox_Recv (void)
 This function will be called from a foreground thread It will spin/block if the MailBox is empty. More...
 
INT32U OS_Time (void)
 
INT32U OS_TimeDifference (INT32U start, INT32U stop)
 
void OS_ClearMsTime (void)
 
INT32U OS_ReadMsTime (void)
 
void OS_Launch (INT32U theTimeSlice)
 This function starts the scheduler and enables interrupts. More...
 

Detailed Description

Functions for OS.

Definition in file OS.h.

Typedef Documentation

◆ MailBoxType

typedef struct MailBox MailBoxType

Definition at line 32 of file OS.h.

◆ Sema4Type

typedef struct Sema4 Sema4Type

Definition at line 20 of file OS.h.

Function Documentation

◆ OS_AddPeriodicThread()

INT8 OS_AddPeriodicThread ( void(*)(void)  task,
INT32U  period,
INT32U  priority 
)

Adds periodic background thread. Cannot spin, sleep, die, rest, etc. cause it's ISR, depends on hardware for number of tasks possible No ID for this thread, must have mid-high priority to run properly.

OS_AddPeriodicThread Add new thread to OS that runs periodically, uses Timer4

Parameters
tasktask to run for thread
stackSizesize of stack
prioritypriority of thread
Returns
success: 1, fail: 0

OS_AddPeriodicThread

Parameters
tasktask to run in background
period
priority5-0 only, else you'll break OS :(
Returns
successful - 1, Fail - 0

Definition at line 593 of file OS.c.

Here is the call graph for this function:

◆ OS_AddSW1Task()

INT8 OS_AddSW1Task ( void(*)(void)  task,
INT32U  priority 
)

This function adds a thread to run and its priority when a button is pressed.

OS_AddSW1Task Add thread to button PF4

Parameters
tasktask to run for thread
prioritypriority of thread
Returns
success: 1, fail: 0

OS_AddSW1Task

Parameters
taskfunction/thread to run when button pressed
priority
Returns
success or fail

Definition at line 626 of file OS.c.

Here is the call graph for this function:

◆ OS_AddSW2Task()

INT8 OS_AddSW2Task ( void(*)(void)  task,
INT32U  priority 
)

This function adds a thread to run and its priority when a button is pressed.

OS_AddSW1Task Add thread to button PF0

Parameters
tasktask to run for thread
prioritypriority of thread
Returns
success: 1, fail: 0

OS_AddSW2Task

Parameters
taskfunction/thread to run when button pressed
priority
Returns
success or fail

Definition at line 638 of file OS.c.

Here is the call graph for this function:

◆ OS_AddThread()

INT8 OS_AddThread ( void(*)(void)  task,
INT32U  priority 
)

This function decides next thread to run, now uses priority scheduler.

OS_AddThread Add new thread to OS, Linked List style

Parameters
tasktask to run for thread
stackSizesize of stack
prioritypriority of thread
Returns
success: 1, fail: 0

OS_AddThread

Parameters
task
stackSize
priority
Returns
1-success, 0-fail

Definition at line 386 of file OS.c.

Here is the caller graph for this function:

◆ OS_ASM_Signal()

void OS_ASM_Signal ( Sema4Type semaPt)

Spinlock semaphore signal using ARM exclusion.

OS_ASM_Signal

Here is the caller graph for this function:

◆ OS_ASM_Wait()

void OS_ASM_Wait ( Sema4Type semaPt)

Spinlock semaphore wait using ARM exclusion.

OS_ASM_Signal

Here is the caller graph for this function:

◆ OS_bSignal()

void OS_bSignal ( Sema4Type semaPt)

Signal semaphore to be free, set to 1.

OS_bSignal

Signal semaphore to be free, set to 1.

OS_bSignal

Parameters
semaPtsemaphore passed in

Definition at line 514 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_bWait()

void OS_bWait ( Sema4Type semaPt)

Wait on semaphore, binary.

OS_bWait

Parameters
semaPtpointer to semaphore

Wait on semaphore, binary.

OS_bWait

Parameters
semaPtsemaphore passed in

Definition at line 499 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_ClearMsTime()

void OS_ClearMsTime ( void  )

OS_ClearMsTime clear ms time counter

OS_ClearMsTime The following function clears the period time, resets counter

Returns
1 if success

OS_ClearMsTime Clear ms time

Definition at line 760 of file OS.c.

Here is the caller graph for this function:

◆ OS_Fifo_Get()

FIFO_t OS_Fifo_Get ( void  )

OS_Fifo_Get Get data from thread

Returns
data

OS_Fifo_Get Retrieves data from OS Fifo

Returns
1 for success, 0 for fail

Definition at line 676 of file OS.c.

Here is the call graph for this function:

◆ OS_Fifo_Init()

void OS_Fifo_Init ( void  )

OS_Fifo_Init Initialize OS Fifo, size must be power of 2, inits semaphores

OS_Fifo_Init Initializes Fifo to be empty, ignored for lab 2, divisible by 2

Definition at line 646 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_Fifo_Put()

INT8 OS_Fifo_Put ( FIFO_t  data)

OS_Fifo_Put Put data to Fifo

Parameters
datadata to put in Fifo
Returns
success: 1, fail: 0

OS_Fifo_Put Adds data to FiFo

Parameters
data
Returns
success - 1, Fail - 0

Definition at line 659 of file OS.c.

◆ OS_Fifo_Size()

INT32U OS_Fifo_Size ( void  )

Gets current size of FiFo.

OS_Fifo_Size Get number of items in FiFo

Returns
size of Fifo

OS_Fifo_Size

Returns
size of current FIFO buffer

Definition at line 691 of file OS.c.

◆ OS_IdThread()

INT32U OS_IdThread ( void  )

Get current thread ID.

OS_Id return ID of current thread

Returns
ID of thread

OS_IdThread

Returns
id of thread

Definition at line 448 of file OS.c.

◆ OS_Init()

void OS_Init ( void  )

initialize operating system, disable interrupts until OS_Launch initialize OS controlled I/O: serial, ADC, systick, LaunchPad I/O and timers

OS_Init Initializes operating system, disables interrupts until OS_Launch Initializes all I/O and interthread communication

OS_Init

Definition at line 188 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_InitSemaphore()

void OS_InitSemaphore ( Sema4Type semaPt,
INT32  value 
)

Initialize semaphore to given value.

OS_InitSemaphore Initializes semaphore to default value sent

Parameters
semaPtpointer to semaphore
valuevalue of semaphore

OS_InitSemaphore

Parameters
semaPtsemaphore ptr

Definition at line 456 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_Kill()

void OS_Kill ( void  )

This function kill/deletes current thread from schedule.

OS_Kill kills current thread

OS_Kill

Definition at line 542 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_Launch()

void OS_Launch ( INT32U  theTimeSlice)

This function starts the scheduler and enables interrupts.

OS_Launch Start OS, setup SysTick

Parameters
theTimeSliceTime between context switches

OS_Launch

Parameters
theTimeSliceperiod of round robin scheduler

Definition at line 285 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_MailBox_Init()

void OS_MailBox_Init ( void  )

Initialize mailbox for OS.

OS_MailBox_Init

Initialize mailbox for OS.

OS_MailBox_Init

Definition at line 701 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_MailBox_Recv()

INT32U OS_MailBox_Recv ( void  )

This function will be called from a foreground thread It will spin/block if the MailBox is empty.

OS_MailBox_Recv Get data from Mailbox

Returns
data

OS_MailBox_Recv Remove mail from the mailbox

Returns
data from Mailbox

Definition at line 729 of file OS.c.

Here is the call graph for this function:

◆ OS_MailBox_Send()

void OS_MailBox_Send ( INT32U  data)

This function will be called from a foreground thread It will spin/block if the MailBox contains data not yet received.

OS_MailBox_Send Puts data in mailbox

Parameters
data

OS_MailBox_Send Enter mail into the Mailbox

Parameters
datadata to put into mailbox

Definition at line 715 of file OS.c.

Here is the call graph for this function:

◆ OS_ReadMsTime()

INT32U OS_ReadMsTime ( void  )

OS_ReadMsTime return time (ms)

Returns
time in ms

OS_MsTime

Returns
time in ms

Definition at line 767 of file OS.c.

Here is the caller graph for this function:

◆ OS_Signal()

void OS_Signal ( Sema4Type semaPt)

This function(Spinlock) will signal that a mutual exclusion is taking place in a function.

OS_Signal Clear Semaphore, Increment

OS_Signal

Parameters
semaPt

Definition at line 483 of file OS.c.

Here is the call graph for this function:

◆ OS_Sleep()

void OS_Sleep ( INT32U  sleepTime)

This function puts a thread to sleep.

OS_Sleep Put current thread to sleep then yield

Parameters
sleepTimeamount of time to sleep (ms)

OS_Sleep

Parameters
sleepTimetime to put thread to sleep

Definition at line 528 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_Suspend()

void OS_Suspend ( void  )

This function suspends current thread by forcing context switch call.

OS_Suspend Suspends current thread

OS_Suspend

Definition at line 343 of file OS.c.

Here is the caller graph for this function:

◆ OS_Time()

INT32U OS_Time ( void  )

OS_Time Returns time in 12.5ns

OS_Time

Returns
OS time in 1/BUS_CLK increments

Definition at line 740 of file OS.c.

◆ OS_TimeDifference()

INT32U OS_TimeDifference ( INT32U  start,
INT32U  stop 
)

OS_TimeDifference Return difference between time

Parameters
startstart time
stopstop time
Returns
time difference

OS_TimeDifference

Parameters
start
stop
Returns
time difference

Definition at line 749 of file OS.c.

◆ OS_Wait()

void OS_Wait ( Sema4Type semaPt)

semaphore value decrement

OS_Wait Wait on semaphore, if busy yield

Parameters
semaPtpointer to semaphore

OS_Wait

Parameters
semaPtpointer to semaphore
Returns
none

Definition at line 468 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function: