SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
example.cpp File Reference

Sleep demo: tasks wake up after different sleep times. More...

#include <stk.h>
#include "example.h"
Include dependency graph for sleep/example.cpp:

Go to the source code of this file.

Classes

class  MyTask< _AccessMode >

Enumerations

enum  { TASK_STACK_SIZE = 256 }

Functions

static void RunCycle ()
void RunExample ()

Variables

static stk::Kernel< stk::KERNEL_DYNAMIC|(1 ? stk::KERNEL_TICKLESS :0), 4, stk::sched::SwitchStrategyRR, stk::PlatformDefault > g_Kernel
static MyTask< stk::ACCESS_PRIVILEGED > g_Task1 (0)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task2 (1)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task3 (2)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task4 (3)

Detailed Description

Sleep demo: tasks wake up after different sleep times.

Definition in file sleep/example.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TASK_STACK_SIZE 

Definition at line 31 of file sleep/example.cpp.

31{ TASK_STACK_SIZE = 256 };
#define TASK_STACK_SIZE

Function Documentation

◆ RunCycle()

void RunCycle ( )
static
Examples
sleep/example.cpp.

Definition at line 62 of file sleep/example.cpp.

63{
64 g_Kernel.AddTask(&g_Task1);
65 g_Kernel.AddTask(&g_Task2);
66 g_Kernel.AddTask(&g_Task3);
67 g_Kernel.AddTask(&g_Task4);
68
69 g_Kernel.Start();
70}
static stk_kernel_t * g_Kernel
static MyTask< stk::ACCESS_PRIVILEGED > g_Task3(Led::GREEN)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task1(Led::RED)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task4(Led::BLUE)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task2(Led::ORANGE)

References g_Kernel, g_Task1, g_Task2, g_Task3, and g_Task4.

Referenced by RunExample().

Here is the caller graph for this function:

◆ RunExample()

void RunExample ( void )

Definition at line 72 of file sleep/example.cpp.

73{
74 Led::InitAll(false);
75
76 g_Kernel.Initialize();
77
78 for (int i = 0; i < 4; ++i)
79 {
80 RunCycle();
81 }
82
83 // switch on all leds
84 Led::InitAll(true);
85
86 while (true) {}
87}
static void InitAll(bool init_state)
Definition led.h:40
static void RunCycle()

References g_Kernel, bsp::Led::InitAll(), and RunCycle().

Here is the call graph for this function:

Variable Documentation

◆ g_Kernel

◆ g_Task1

MyTask< stk::ACCESS_PRIVILEGED > g_Task1(0) ( 0 )
static

◆ g_Task2

MyTask< stk::ACCESS_PRIVILEGED > g_Task2(1) ( 1 )

◆ g_Task3

MyTask< stk::ACCESS_PRIVILEGED > g_Task3(2) ( 2 )

◆ g_Task4

MyTask< stk::ACCESS_PRIVILEGED > g_Task4(3) ( 3 )