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.c File Reference

SuperTinyKernel RTOS via CMSIS RTOS2 wrapper example program. More...

#include <stdio.h>
#include "cmsis_os2.h"
#include "RTE_Components.h"
#include "stk_config.h"
Include dependency graph for blinky_c-cmsis-rtos2/example.c:

Go to the source code of this file.

Classes

struct  phases_t

Functions

void Switch_On (unsigned char led)
void Switch_Off (unsigned char led)
void signal_func (osThreadId_t tid)
void phaseA (void *argument)
void phaseB (void *argument)
void phaseC (void *argument)
void phaseD (void *argument)
void clock (void *argument)
void app_main (void *argument)
void app_run ()

Variables

osThreadId_t tid_phaseA
osThreadId_t tid_phaseB
osThreadId_t tid_phaseC
osThreadId_t tid_phaseD
osThreadId_t tid_clock
struct phases_t g_phases

Detailed Description

SuperTinyKernel RTOS via CMSIS RTOS2 wrapper example program.

Definition in file blinky_c-cmsis-rtos2/example.c.

Function Documentation

◆ app_main()

void app_main ( void * argument)

Definition at line 148 of file blinky_c-cmsis-rtos2/example.c.

148 {
149
150 tid_phaseA = osThreadNew(phaseA, NULL, NULL);
151 tid_phaseB = osThreadNew(phaseB, NULL, NULL);
152 tid_phaseC = osThreadNew(phaseC, NULL, NULL);
153 tid_phaseD = osThreadNew(phaseD, NULL, NULL);
154 tid_clock = osThreadNew(clock, NULL, NULL);
155
156 osThreadFlagsSet(tid_phaseA, 0x0001); /* set signal to phaseA thread */
157
159}
osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)
uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags)
#define osWaitForever
Wait forever timeout value.
Definition cmsis_os2.h:258
osStatus_t osDelay(uint32_t ticks)
void phaseD(void *argument)
osThreadId_t tid_phaseC
void phaseA(void *argument)
osThreadId_t tid_phaseB
void phaseC(void *argument)
void clock(void *argument)
osThreadId_t tid_clock
osThreadId_t tid_phaseD
void phaseB(void *argument)
osThreadId_t tid_phaseA

References clock(), osDelay(), osThreadFlagsSet(), osThreadNew(), osWaitForever, phaseA(), phaseB(), phaseC(), phaseD(), tid_clock, tid_phaseA, tid_phaseB, tid_phaseC, and tid_phaseD.

Here is the call graph for this function:

◆ app_run()

void app_run ( )

Definition at line 162 of file blinky_c-cmsis-rtos2/example.c.

166{
167 // System Initialization
168 SystemCoreClockUpdate();
169
170 // Init LEDs
171 Led_InitAll(false);
172
173 // ...
174
175 osKernelInitialize(); // Initialize CMSIS-RTOS
176 osThreadNew(app_main, NULL, NULL); // Create application main thread
178 osKernelStart(); // Start thread execution
179 }
180
181 while(1);
182}
void Led_InitAll(bool state)
Definition c_wrapper.cpp:27
osKernelState_t osKernelGetState(void)
osStatus_t osKernelStart(void)
osStatus_t osKernelInitialize(void)
@ osKernelReady
Ready.
Definition cmsis_os2.h:169
void app_main(void *argument)

References app_main(), Led_InitAll(), osKernelGetState(), osKernelInitialize(), osKernelReady, osKernelStart(), and osThreadNew().

Here is the call graph for this function:

◆ clock()

void clock ( void * argument)
Examples
blinky_c-cmsis-rtos2/example.c.

Definition at line 138 of file blinky_c-cmsis-rtos2/example.c.

138 {
139 for (;;) {
140 osThreadFlagsWait(0x0100, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0100 */
141 osDelay(80); /* delay 80ms */
142 }
143}
#define osFlagsWaitAny
Wait for any flag (default).
Definition cmsis_os2.h:261
uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout)

References osDelay(), osFlagsWaitAny, osThreadFlagsWait(), and osWaitForever.

Referenced by app_main().

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

◆ phaseA()

void phaseA ( void * argument)
Examples
blinky_c-cmsis-rtos2/example.c, blinky_c-cyabs_rtos/example.c, blinky_c-freertos/example.c, and blinky_c-threadx/example.c.

Definition at line 82 of file blinky_c-cmsis-rtos2/example.c.

82 {
83 for (;;) {
84 osThreadFlagsWait(0x0001, osFlagsWaitAny ,osWaitForever); /* wait for an event flag 0x0001 */
85 Switch_On(0);
86 g_phases.phaseA = 1;
87 signal_func(tid_phaseB); /* call common signal function */
88 g_phases.phaseA = 0;
89 Switch_Off(0);
90 }
91}
void Switch_Off(unsigned char led)
void Switch_On(unsigned char led)
struct phases_t g_phases
void signal_func(osThreadId_t tid)

References g_phases, osFlagsWaitAny, osThreadFlagsWait(), osWaitForever, signal_func(), Switch_Off(), Switch_On(), and tid_phaseB.

Referenced by __attribute__(), app_main(), app_main(), and app_main().

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

◆ phaseB()

void phaseB ( void * argument)
Examples
blinky_c-cmsis-rtos2/example.c, blinky_c-cyabs_rtos/example.c, blinky_c-freertos/example.c, and blinky_c-threadx/example.c.

Definition at line 96 of file blinky_c-cmsis-rtos2/example.c.

96 {
97 for (;;) {
98 osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
99 Switch_On(1);
100 g_phases.phaseB = 1;
101 signal_func(tid_phaseC); /* call common signal function */
102 g_phases.phaseB = 0;
103 Switch_Off(1);
104 }
105}

References g_phases, osFlagsWaitAny, osThreadFlagsWait(), osWaitForever, signal_func(), Switch_Off(), Switch_On(), and tid_phaseC.

Referenced by __attribute__(), app_main(), app_main(), and app_main().

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

◆ phaseC()

void phaseC ( void * argument)
Examples
blinky_c-cmsis-rtos2/example.c, blinky_c-cyabs_rtos/example.c, blinky_c-freertos/example.c, and blinky_c-threadx/example.c.

Definition at line 110 of file blinky_c-cmsis-rtos2/example.c.

110 {
111 for (;;) {
112 osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
113 Switch_On(2);
114 g_phases.phaseC = 1;
115 signal_func(tid_phaseD); /* call common signal function */
116 g_phases.phaseC = 0;
117 Switch_Off(2);
118 }
119}

References g_phases, osFlagsWaitAny, osThreadFlagsWait(), osWaitForever, signal_func(), Switch_Off(), Switch_On(), and tid_phaseD.

Referenced by __attribute__(), app_main(), app_main(), and app_main().

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

◆ phaseD()

void phaseD ( void * argument)
Examples
blinky_c-cmsis-rtos2/example.c, blinky_c-cyabs_rtos/example.c, blinky_c-freertos/example.c, and blinky_c-threadx/example.c.

Definition at line 124 of file blinky_c-cmsis-rtos2/example.c.

124 {
125 for (;;) {
126 osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
127 Switch_On(3);
128 g_phases.phaseD = 1;
129 signal_func(tid_phaseA); /* call common signal function */
130 g_phases.phaseD = 0;
131 Switch_Off(3);
132 }
133}

References g_phases, osFlagsWaitAny, osThreadFlagsWait(), osWaitForever, signal_func(), Switch_Off(), Switch_On(), and tid_phaseA.

Referenced by __attribute__(), app_main(), app_main(), and app_main().

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

◆ signal_func()

void signal_func ( osThreadId_t tid)
Examples
blinky_c-cmsis-rtos2/example.c, blinky_c-cyabs_rtos/example.c, blinky_c-freertos/example.c, and blinky_c-threadx/example.c.

Definition at line 70 of file blinky_c-cmsis-rtos2/example.c.

70 {
71 osThreadFlagsSet(tid_clock, 0x0100); /* set signal to clock thread */
72 osDelay(500); /* delay 500ms */
73 osThreadFlagsSet(tid_clock, 0x0100); /* set signal to clock thread */
74 osDelay(500); /* delay 500ms */
75 osThreadFlagsSet(tid, 0x0001); /* set signal to thread 'thread' */
76 osDelay(500); /* delay 500ms */
77}

References osDelay(), osThreadFlagsSet(), and tid_clock.

Referenced by phaseA(), phaseA(), phaseA(), phaseB(), phaseB(), phaseB(), phaseC(), phaseC(), phaseC(), phaseD(), phaseD(), and phaseD().

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

◆ Switch_Off()

void Switch_Off ( unsigned char led)
Examples
blinky_c-cmsis-rtos2/example.c, blinky_c-cyabs_rtos/example.c, blinky_c-freertos/example.c, and blinky_c-threadx/example.c.

Definition at line 61 of file blinky_c-cmsis-rtos2/example.c.

61 {
62 //printf("LED Off: #%d\n", led);
63 Led_Set((LedId)led, false);
64}
void Led_Set(LedId led, bool state)
Definition c_wrapper.cpp:22
LedId
Definition led.h:16

References Led_Set().

Referenced by phaseA(), phaseA(), phaseA(), phaseB(), phaseB(), phaseB(), phaseC(), phaseC(), phaseC(), phaseD(), phaseD(), and phaseD().

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

◆ Switch_On()

void Switch_On ( unsigned char led)
Examples
blinky_c-cmsis-rtos2/example.c, blinky_c-cyabs_rtos/example.c, blinky_c-freertos/example.c, and blinky_c-threadx/example.c.

Definition at line 53 of file blinky_c-cmsis-rtos2/example.c.

53 {
54 //printf("LED On: #%d\n", led);
55 Led_Set((LedId)led, true);
56}

References Led_Set().

Referenced by phaseA(), phaseA(), phaseA(), phaseB(), phaseB(), phaseB(), phaseC(), phaseC(), phaseC(), phaseD(), phaseD(), and phaseD().

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

Variable Documentation

◆ g_phases

◆ tid_clock

◆ tid_phaseA

◆ tid_phaseB

◆ tid_phaseC

◆ tid_phaseD