Example application
The following example shows the ease of use of embOS.
Easy usage
The two tasks are activated and execute until they run into the delay, then suspend for the specified time and eventually continue execution.
You can write programs just as you always did, the only difference being that multiple programs run quasi-simultaneously.
#include "RTOS.h"
static OS_STACKPTR int StackHP[128], StackLP[128]; // Task stacks
static OS_TASK TCBHP, TCBLP; // Task-control-blocks
static void HPTask(void) {
while (1) {
OS_TASK_Delay(50);
}
}
static void LPTask(void) {
while (1) {
OS_TASK_Delay(200);
}
}
int main(void) {
OS_Init(); // Initialize OS
OS_InitHW(); // Initialize Hardware for OS
OS_TASK_CREATE(&TCBHP, "HP Task", 100, HPTask, StackHP);
OS_TASK_CREATE(&TCBLP, "LP Task", 50, LPTask, StackLP);
OS_Start(); // Start multitasking
return 0;
}