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

Run-once tasks: the kernel returns from Start() once all tasks have completed. More...

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

Go to the source code of this file.

Classes

class  MyTask< _AccessMode >

Enumerations

enum  { TASK_STACK_SIZE = 256 }

Functions

static void RunOnce ()
void RunExample ()

Variables

static volatile uint8_t g_TaskSwitch = 0
static stk::Kernel< stk::KERNEL_DYNAMIC, 4, stk::sched::SwitchStrategyRoundRobin, stk::PlatformDefault > g_Kernel
static MyTask< stk::ACCESS_PRIVILEGED > g_Task1 (Led::RED)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task2 (Led::ORANGE)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task3 (Led::GREEN)
static MyTask< stk::ACCESS_PRIVILEGED > g_Task4 (Led::BLUE)

Detailed Description

Run-once tasks: the kernel returns from Start() once all tasks have completed.

Definition in file once/example.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TASK_STACK_SIZE 

Definition at line 33 of file once/example.cpp.

33{ TASK_STACK_SIZE = 256 };
#define TASK_STACK_SIZE

Function Documentation

◆ RunExample()

void RunExample ( void )

Definition at line 90 of file once/example.cpp.

91{
92 using namespace stk;
93
94 Led::InitAll(false);
95
96 g_Kernel.Initialize();
97
98 // repeat 3 times
99 for (int32_t i = 0; i < 3; ++i)
100 {
101 RunOnce();
102 }
103
104 // switched on all LEDs when execution ends
105 Led::InitAll(true);
106
107 while (true) {}
108}
Namespace of STK package.
static void InitAll(bool init_state)
Definition led.h:40
static stk_kernel_t * g_Kernel
static void RunOnce()

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

Here is the call graph for this function:

◆ RunOnce()

void RunOnce ( )
static
Examples
once/example.cpp.

Definition at line 77 of file once/example.cpp.

78{
79 g_Kernel.AddTask(&g_Task1);
80 g_Kernel.AddTask(&g_Task2);
81 g_Kernel.AddTask(&g_Task3);
82 g_Kernel.AddTask(&g_Task4);
83
84 g_TaskSwitch = 0;
85
86 // note: kernel will exit from Start() once all tasks exit (complete their work)
87 g_Kernel.Start();
88}
static volatile uint8_t g_TaskSwitch
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, g_Task4, and g_TaskSwitch.

Referenced by RunExample().

Here is the caller graph for this function:

Variable Documentation

◆ g_Kernel

◆ g_Task1

Examples
once/example.cpp, and sleep/example.cpp.

Referenced by RunCycle(), and RunOnce().

◆ g_Task2

◆ g_Task3

◆ g_Task4

◆ g_TaskSwitch

volatile uint8_t g_TaskSwitch = 0
static
Examples
once/example.cpp.

Definition at line 27 of file once/example.cpp.

Referenced by MyTask< _AccessMode >::Run(), and RunOnce().