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.h File Reference
#include "../driver/led.h"
Include dependency graph for critical_section/example.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void RunExample ()

Function Documentation

◆ RunExample()

void RunExample ( )

Definition at line 129 of file blinky-trustzone-ns/example.cpp.

130{
131 using namespace stk;
132
133 uint8_t key[4] = {0};
134 NSC_GetKey(key, 4);
135
136 // Note: using ACCESS_PRIVILEGED as Cortex-M3+ may not allow writing to GPIO from a less secure user thread.
137 static MyTask<ACCESS_USER> task1(LED_RED);
138 static MyTask<ACCESS_USER> task2(LED_ORANGE);
139 static MyTask<ACCESS_USER> task3(LED_GREEN); // you can set to ACCESS_PRIVILEGED too, see NSC_bsp_Led_SwitchOnExclusive on secure side, but for smooth performance on RP2350 let background thread handle GPIO
140 static MyTask<ACCESS_USER> task4(LED_BLUE);
141
142 static tz::nsec::Kernel kernel;
143
144 kernel.Initialize(0);
145
146 // Register threads (tasks).
147 kernel.AddTask(&task1);
148 kernel.AddTask(&task2);
149 kernel.AddTask(&task3);
150 kernel.AddTask(&task4);
151
152 // Start scheduler (it will start threads added by AddTask), execution in main() will be blocked on this line.
153 kernel.Start();
154
155 // Return back to Secure binary. Note: kernel.Start() will exit only if Secure side initialized Kernel instance
156 // with KERNEL_DYNAMIC mode and when all tasks exited on both sides.
157 NSC_OnExitNs();
158}
@ LED_ORANGE
Definition led.h:18
@ LED_GREEN
Definition led.h:17
@ LED_BLUE
Definition led.h:20
@ LED_RED
Definition led.h:19
Namespace of STK package.
void NSC_OnExitNs(void)
uint32_t NSC_GetKey(uint8_t key[], uint32_t size)