SuperTinyKernel™ RTOS 1.06.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
STK CMSIS RTOS2 API

CMSIS RTOS2 interface for C++ API of SuperTinyKernel RTOS. More...

Classes

struct  osVersion_t
 Version information. More...
struct  osThreadAttr_t
 Attributes structure for thread. More...
struct  osTimerAttr_t
 Attributes structure for timer. More...
struct  osEventFlagsAttr_t
 Attributes structure for event flags. More...
struct  osMutexAttr_t
 Attributes structure for mutex. More...
struct  osSemaphoreAttr_t
 Attributes structure for semaphore. More...
struct  osMemoryPoolAttr_t
 Attributes structure for memory pool. More...
struct  osMessageQueueAttr_t
 Attributes structure for message queue. More...

Macros

#define osWaitForever   0xFFFFFFFFU
 Wait forever timeout value.
#define osFlagsWaitAny   0x00000000U
 Wait for any flag (default).
#define osFlagsWaitAll   0x00000001U
 Wait for all flags.
#define osFlagsNoClear   0x00000002U
 Do not clear flags which have been specified to wait for.
#define osFlagsError   0x80000000U
 Error indicator.
#define osFlagsErrorUnknown   0xFFFFFFFFU
 osError (-1).
#define osFlagsErrorTimeout   0xFFFFFFFEU
 osErrorTimeout (-2).
#define osFlagsErrorResource   0xFFFFFFFDU
 osErrorResource (-3).
#define osFlagsErrorParameter   0xFFFFFFFCU
 osErrorParameter (-4).
#define osFlagsErrorISR   0xFFFFFFFAU
 osErrorISR (-6).
#define osFlagsErrorSafetyClass   0xFFFFFFF9U
 osErrorSafetyClass (-7).
#define osThreadDetached   0x00000000U
 Thread created in detached mode (default).
#define osThreadJoinable   0x00000001U
 Thread created in joinable mode.
#define osThreadUnprivileged   0x00000002U
 Thread runs in unprivileged mode.
#define osThreadPrivileged   0x00000004U
 Thread runs in privileged mode.
#define osThreadZone_Pos   8U
 MPU protected zone position.
#define osThreadZone_Msk   (0x3FUL << osThreadZone_Pos)
 MPU protected zone mask.
#define osThreadZone_Valid   (0x80UL << osThreadZone_Pos)
 MPU protected zone valid flag.
#define osThreadZone(n)
 MPU zone value in attribute bit field format.
#define osThreadProcessor(n)
 Thread processor number for SMP systems.
#define osMutexRecursive   0x00000001U
 Recursive mutex.
#define osMutexPrioInherit   0x00000002U
 Priority inherit protocol.
#define osMutexRobust   0x00000008U
 Robust mutex.
#define osSafetyClass_Pos   16U
 Safety class position.
#define osSafetyClass_Msk   (0x0FUL << osSafetyClass_Pos)
 Safety class mask.
#define osSafetyClass_Valid   (0x10UL << osSafetyClass_Pos)
 Safety class valid flag.
#define osSafetyClass(n)
 Safety class.
#define osSafetyWithSameClass   0x00000001U
 Objects with same safety class.
#define osSafetyWithLowerClass   0x00000002U
 Objects with lower safety class.
#define osErrorId   0xFFFFFFFFU
 osError (-1).
#define TZ_MODULEID_T

Typedefs

typedef void(* osThreadFunc_t) (void *argument)
 Entry point of a thread.
typedef void(* osTimerFunc_t) (void *argument)
 Timer callback function.
typedef void * osThreadId_t
typedef void * osTimerId_t
typedef void * osEventFlagsId_t
typedef void * osMutexId_t
typedef void * osSemaphoreId_t
typedef void * osMemoryPoolId_t
typedef void * osMessageQueueId_t
typedef uint32_t TZ_ModuleId_t

Enumerations

enum  osKernelState_t {
  osKernelInactive = 0 ,
  osKernelReady = 1 ,
  osKernelRunning = 2 ,
  osKernelLocked = 3 ,
  osKernelSuspended = 4 ,
  osKernelError = -1 ,
  osKernelReserved = 0x7FFFFFFF
}
 Kernel state. More...
enum  osThreadState_t {
  osThreadInactive = 0 ,
  osThreadReady = 1 ,
  osThreadRunning = 2 ,
  osThreadBlocked = 3 ,
  osThreadTerminated = 4 ,
  osThreadError = -1 ,
  osThreadReserved = 0x7FFFFFFF
}
 Thread state. More...
enum  osPriority_t {
  osPriorityNone = 0 ,
  osPriorityIdle = 1 ,
  osPriorityLow = 8 ,
  osPriorityLow1 = 8+1 ,
  osPriorityLow2 = 8+2 ,
  osPriorityLow3 = 8+3 ,
  osPriorityLow4 = 8+4 ,
  osPriorityLow5 = 8+5 ,
  osPriorityLow6 = 8+6 ,
  osPriorityLow7 = 8+7 ,
  osPriorityBelowNormal = 16 ,
  osPriorityBelowNormal1 = 16+1 ,
  osPriorityBelowNormal2 = 16+2 ,
  osPriorityBelowNormal3 = 16+3 ,
  osPriorityBelowNormal4 = 16+4 ,
  osPriorityBelowNormal5 = 16+5 ,
  osPriorityBelowNormal6 = 16+6 ,
  osPriorityBelowNormal7 = 16+7 ,
  osPriorityNormal = 24 ,
  osPriorityNormal1 = 24+1 ,
  osPriorityNormal2 = 24+2 ,
  osPriorityNormal3 = 24+3 ,
  osPriorityNormal4 = 24+4 ,
  osPriorityNormal5 = 24+5 ,
  osPriorityNormal6 = 24+6 ,
  osPriorityNormal7 = 24+7 ,
  osPriorityAboveNormal = 32 ,
  osPriorityAboveNormal1 = 32+1 ,
  osPriorityAboveNormal2 = 32+2 ,
  osPriorityAboveNormal3 = 32+3 ,
  osPriorityAboveNormal4 = 32+4 ,
  osPriorityAboveNormal5 = 32+5 ,
  osPriorityAboveNormal6 = 32+6 ,
  osPriorityAboveNormal7 = 32+7 ,
  osPriorityHigh = 40 ,
  osPriorityHigh1 = 40+1 ,
  osPriorityHigh2 = 40+2 ,
  osPriorityHigh3 = 40+3 ,
  osPriorityHigh4 = 40+4 ,
  osPriorityHigh5 = 40+5 ,
  osPriorityHigh6 = 40+6 ,
  osPriorityHigh7 = 40+7 ,
  osPriorityRealtime = 48 ,
  osPriorityRealtime1 = 48+1 ,
  osPriorityRealtime2 = 48+2 ,
  osPriorityRealtime3 = 48+3 ,
  osPriorityRealtime4 = 48+4 ,
  osPriorityRealtime5 = 48+5 ,
  osPriorityRealtime6 = 48+6 ,
  osPriorityRealtime7 = 48+7 ,
  osPriorityISR = 56 ,
  osPriorityError = -1 ,
  osPriorityReserved = 0x7FFFFFFF
}
 Priority values. More...
enum  osTimerType_t {
  osTimerOnce = 0 ,
  osTimerPeriodic = 1
}
 Timer type. More...
enum  osStatus_t {
  osOK = 0 ,
  osError = -1 ,
  osErrorTimeout = -2 ,
  osErrorResource = -3 ,
  osErrorParameter = -4 ,
  osErrorNoMemory = -5 ,
  osErrorISR = -6 ,
  osErrorSafetyClass = -7 ,
  osStatusReserved = 0x7FFFFFFF
}
 Status code values returned by CMSIS-RTOS functions. More...

Functions

osStatus_t osKernelInitialize (void)
osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size)
osKernelState_t osKernelGetState (void)
osStatus_t osKernelStart (void)
int32_t osKernelLock (void)
int32_t osKernelUnlock (void)
int32_t osKernelRestoreLock (int32_t lock)
uint32_t osKernelSuspend (void)
void osKernelResume (uint32_t sleep_ticks)
osStatus_t osKernelProtect (uint32_t safety_class)
osStatus_t osKernelDestroyClass (uint32_t safety_class, uint32_t mode)
uint32_t osKernelGetTickCount (void)
uint32_t osKernelGetTickFreq (void)
uint32_t osKernelGetSysTimerCount (void)
uint64_t osKernelGetSysTimerCount64 (void)
uint32_t osKernelGetSysTimerFreq (void)
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)
const char * osThreadGetName (osThreadId_t thread_id)
uint32_t osThreadGetClass (osThreadId_t thread_id)
uint32_t osThreadGetZone (osThreadId_t thread_id)
osThreadId_t osThreadGetId (void)
osThreadState_t osThreadGetState (osThreadId_t thread_id)
uint32_t osThreadGetStackSize (osThreadId_t thread_id)
uint32_t osThreadGetStackSpace (osThreadId_t thread_id)
osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority)
osPriority_t osThreadGetPriority (osThreadId_t thread_id)
osStatus_t osThreadYield (void)
osStatus_t osThreadSuspend (osThreadId_t thread_id)
osStatus_t osThreadResume (osThreadId_t thread_id)
osStatus_t osThreadDetach (osThreadId_t thread_id)
osStatus_t osThreadJoin (osThreadId_t thread_id)
void osThreadExit (void)
 Terminate execution of current running thread.
osStatus_t osThreadTerminate (osThreadId_t thread_id)
osStatus_t osThreadFeedWatchdog (uint32_t ticks)
osStatus_t osThreadProtectPrivileged (void)
osStatus_t osThreadSuspendClass (uint32_t safety_class, uint32_t mode)
osStatus_t osThreadResumeClass (uint32_t safety_class, uint32_t mode)
osStatus_t osThreadTerminateZone (uint32_t zone)
osStatus_t osThreadSetAffinityMask (osThreadId_t thread_id, uint32_t affinity_mask)
uint32_t osThreadGetAffinityMask (osThreadId_t thread_id)
uint32_t osThreadGetCount (void)
uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items)
uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags)
uint32_t osThreadFlagsClear (uint32_t flags)
uint32_t osThreadFlagsGet (void)
uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout)
osStatus_t osDelay (uint32_t ticks)
osStatus_t osDelayUntil (uint32_t ticks)
osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)
const char * osTimerGetName (osTimerId_t timer_id)
osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks)
osStatus_t osTimerStop (osTimerId_t timer_id)
uint32_t osTimerIsRunning (osTimerId_t timer_id)
osStatus_t osTimerDelete (osTimerId_t timer_id)
osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr)
const char * osEventFlagsGetName (osEventFlagsId_t ef_id)
uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags)
uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags)
uint32_t osEventFlagsGet (osEventFlagsId_t ef_id)
uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout)
osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id)
osMutexId_t osMutexNew (const osMutexAttr_t *attr)
const char * osMutexGetName (osMutexId_t mutex_id)
osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout)
osStatus_t osMutexRelease (osMutexId_t mutex_id)
osThreadId_t osMutexGetOwner (osMutexId_t mutex_id)
osStatus_t osMutexDelete (osMutexId_t mutex_id)
osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
const char * osSemaphoreGetName (osSemaphoreId_t semaphore_id)
osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout)
osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id)
uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id)
osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id)
osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr)
const char * osMemoryPoolGetName (osMemoryPoolId_t mp_id)
void * osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout)
osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block)
uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id)
uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id)
uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id)
uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id)
osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id)
osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr)
const char * osMessageQueueGetName (osMessageQueueId_t mq_id)
osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout)
osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout)
uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id)
uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id)
uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id)
uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id)
osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id)
osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id)
uint32_t osWatchdogAlarm_Handler (osThreadId_t thread_id)
void osZoneSetup_Callback (uint32_t zone)
void osFaultResume (void)
 Resume normal operation when exiting exception faults.

Detailed Description

CMSIS RTOS2 interface for C++ API of SuperTinyKernel RTOS.

Maps the CMSIS RTOS2 C API (cmsis_os2.h) onto the STK C++ API.

Supported:

  • Kernel management (osKernelInitialize / Start / GetState / GetInfo / GetTickCount / GetTickFreq / GetSysTimerCount / GetSysTimerFreq / Lock / Unlock / RestoreLock)
  • Thread management (osThreadNew / Delete / Yield / Delay / osDelay / GetId / GetName / GetState / GetPriority / SetPriority / GetStackSize / GetStackSpace / GetCount / Terminate / Suspend / Resume, Join, Detach)
  • Thread flags (osThreadFlagsSet / Clear / Get / Wait)
  • Event flags (osEventFlagsNew / Delete / Set / Clear / Get / Wait)
  • Mutex (osMutexNew / Delete / Acquire / Release / GetOwner)
  • Semaphore (osSemaphoreNew / Delete / Acquire / Release / GetCount)
  • Timer (osTimerNew / Delete / Start / Stop / IsRunning)
  • Message Queue (osMessageQueueNew / Delete / Put / Get / GetCapacity / GetMsgSize / GetCount / GetSpace / Reset)
  • Memory Pool (osMemoryPoolNew / Delete / Alloc / Free / GetCapacity / GetBlockSize / GetCount / GetSpace / GetName)

Design notes:

  • All objects are heap-allocated with operator new/delete. For a fully static deployment, replace with a static object-pool allocator.
  • The wrapper owns one global Kernel instance (g_StkKernel). Call osKernelInitialize() before any other API, then osKernelStart().
  • The kernel is configured with KERNEL_DYNAMIC | KERNEL_SYNC and SwitchStrategyFP32 (32 fixed-priority levels). osThread priority values (osPriorityIdle=1 .. osPriorityISR=56) are linearly mapped to STK priority levels 0..31.
  • CMSIS osWaitForever (0xFFFFFFFF) is translated to STK WAIT_INFINITE.
  • Timeout values in CMSIS are in ticks; STK Sleep/Delay also take ticks, so no conversion is required.
  • Thread flags and event flags are backed by stk::sync::EventFlags, STK's native 32-bit multi-flag synchronization primitive.
  • Message queues are backed by stk::sync::MessageQueue, STK's native fixed-capacity, fixed-message-size ring-buffer with integrated blocking semantics (Put/Get with configurable timeouts, ISR-safe TryPut/TryGet).

Limitations / deviations from the specification:

  • Priority inheritance (osMutexPrioInherit): ignored, always supported.
  • Robust mutex (osMutexRobust): will assert as unsafe code.
  • Recursive mutex (osMutexRecursive): ignored, always recursive by default.

Macro Definition Documentation

◆ osErrorId

#define osErrorId   0xFFFFFFFFU

osError (-1).

Definition at line 294 of file cmsis_os2.h.

◆ osFlagsError

#define osFlagsError   0x80000000U

Error indicator.

Definition at line 254 of file cmsis_os2.h.

Referenced by osEventFlagsClear(), osEventFlagsSet(), osEventFlagsWait(), and osThreadFlagsSet().

◆ osFlagsErrorISR

#define osFlagsErrorISR   0xFFFFFFFAU

osErrorISR (-6).

Definition at line 259 of file cmsis_os2.h.

Referenced by osThreadFlagsWait(), and StkFlagsResultToCmsis().

◆ osFlagsErrorParameter

#define osFlagsErrorParameter   0xFFFFFFFCU

osErrorParameter (-4).

Definition at line 258 of file cmsis_os2.h.

Referenced by osEventFlagsClear(), osEventFlagsSet(), osEventFlagsWait(), osThreadFlagsSet(), and StkFlagsResultToCmsis().

◆ osFlagsErrorResource

#define osFlagsErrorResource   0xFFFFFFFDU

osErrorResource (-3).

Definition at line 257 of file cmsis_os2.h.

◆ osFlagsErrorSafetyClass

#define osFlagsErrorSafetyClass   0xFFFFFFF9U

osErrorSafetyClass (-7).

Definition at line 260 of file cmsis_os2.h.

◆ osFlagsErrorTimeout

#define osFlagsErrorTimeout   0xFFFFFFFEU

osErrorTimeout (-2).

Definition at line 256 of file cmsis_os2.h.

Referenced by StkFlagsResultToCmsis().

◆ osFlagsErrorUnknown

#define osFlagsErrorUnknown   0xFFFFFFFFU

osError (-1).

Definition at line 255 of file cmsis_os2.h.

Referenced by osThreadFlagsClear(), osThreadFlagsWait(), and StkFlagsResultToCmsis().

◆ osFlagsNoClear

#define osFlagsNoClear   0x00000002U

Do not clear flags which have been specified to wait for.

Definition at line 251 of file cmsis_os2.h.

Referenced by CmsisFlagsOptionsToStk().

◆ osFlagsWaitAll

#define osFlagsWaitAll   0x00000001U

Wait for all flags.

Definition at line 250 of file cmsis_os2.h.

Referenced by CmsisFlagsOptionsToStk().

◆ osFlagsWaitAny

#define osFlagsWaitAny   0x00000000U

Wait for any flag (default).

Definition at line 249 of file cmsis_os2.h.

◆ osMutexPrioInherit

#define osMutexPrioInherit   0x00000002U

Priority inherit protocol.

Definition at line 279 of file cmsis_os2.h.

◆ osMutexRecursive

#define osMutexRecursive   0x00000001U

Recursive mutex.

Definition at line 278 of file cmsis_os2.h.

◆ osMutexRobust

#define osMutexRobust   0x00000008U

Robust mutex.

Definition at line 280 of file cmsis_os2.h.

Referenced by osMutexNew().

◆ osSafetyClass

#define osSafetyClass ( n)
Value:
#define osSafetyClass_Pos
Safety class position.
Definition cmsis_os2.h:283
#define osSafetyClass_Msk
Safety class mask.
Definition cmsis_os2.h:284
#define osSafetyClass_Valid
Safety class valid flag.
Definition cmsis_os2.h:285

Safety class.

Definition at line 286 of file cmsis_os2.h.

286#define osSafetyClass(n) ((((n) << osSafetyClass_Pos) & osSafetyClass_Msk) | \
287 osSafetyClass_Valid)

◆ osSafetyClass_Msk

#define osSafetyClass_Msk   (0x0FUL << osSafetyClass_Pos)

Safety class mask.

Definition at line 284 of file cmsis_os2.h.

◆ osSafetyClass_Pos

#define osSafetyClass_Pos   16U

Safety class position.

Definition at line 283 of file cmsis_os2.h.

◆ osSafetyClass_Valid

#define osSafetyClass_Valid   (0x10UL << osSafetyClass_Pos)

Safety class valid flag.

Definition at line 285 of file cmsis_os2.h.

◆ osSafetyWithLowerClass

#define osSafetyWithLowerClass   0x00000002U

Objects with lower safety class.

Definition at line 291 of file cmsis_os2.h.

◆ osSafetyWithSameClass

#define osSafetyWithSameClass   0x00000001U

Objects with same safety class.

Definition at line 290 of file cmsis_os2.h.

◆ osThreadDetached

#define osThreadDetached   0x00000000U

Thread created in detached mode (default).

Definition at line 263 of file cmsis_os2.h.

◆ osThreadJoinable

#define osThreadJoinable   0x00000001U

Thread created in joinable mode.

Definition at line 264 of file cmsis_os2.h.

Referenced by osThreadNew().

◆ osThreadPrivileged

#define osThreadPrivileged   0x00000004U

Thread runs in privileged mode.

Definition at line 266 of file cmsis_os2.h.

◆ osThreadProcessor

#define osThreadProcessor ( n)
Value:
(1UL << (n))

Thread processor number for SMP systems.

Definition at line 275 of file cmsis_os2.h.

◆ osThreadUnprivileged

#define osThreadUnprivileged   0x00000002U

Thread runs in unprivileged mode.

Definition at line 265 of file cmsis_os2.h.

◆ osThreadZone

#define osThreadZone ( n)
Value:
#define osThreadZone_Msk
MPU protected zone mask.
Definition cmsis_os2.h:269
#define osThreadZone_Pos
MPU protected zone position.
Definition cmsis_os2.h:268
#define osThreadZone_Valid
MPU protected zone valid flag.
Definition cmsis_os2.h:270

MPU zone value in attribute bit field format.

Definition at line 271 of file cmsis_os2.h.

271#define osThreadZone(n) ((((n) << osThreadZone_Pos) & osThreadZone_Msk) | \
272 osThreadZone_Valid)

◆ osThreadZone_Msk

#define osThreadZone_Msk   (0x3FUL << osThreadZone_Pos)

MPU protected zone mask.

Definition at line 269 of file cmsis_os2.h.

◆ osThreadZone_Pos

#define osThreadZone_Pos   8U

MPU protected zone position.

Definition at line 268 of file cmsis_os2.h.

◆ osThreadZone_Valid

#define osThreadZone_Valid   (0x80UL << osThreadZone_Pos)

MPU protected zone valid flag.

Definition at line 270 of file cmsis_os2.h.

◆ osWaitForever

#define osWaitForever   0xFFFFFFFFU

Wait forever timeout value.

Definition at line 246 of file cmsis_os2.h.

◆ TZ_MODULEID_T

#define TZ_MODULEID_T

Definition at line 333 of file cmsis_os2.h.

Typedef Documentation

◆ osEventFlagsId_t

typedef void* osEventFlagsId_t

Event Flags ID identifies the event flags.

Definition at line 317 of file cmsis_os2.h.

◆ osMemoryPoolId_t

typedef void* osMemoryPoolId_t

Memory Pool ID identifies the memory pool.

Definition at line 326 of file cmsis_os2.h.

◆ osMessageQueueId_t

typedef void* osMessageQueueId_t

Message Queue ID identifies the message queue.

Definition at line 329 of file cmsis_os2.h.

◆ osMutexId_t

typedef void* osMutexId_t

Mutex ID identifies the mutex.

Definition at line 320 of file cmsis_os2.h.

◆ osSemaphoreId_t

typedef void* osSemaphoreId_t

Semaphore ID identifies the semaphore.

Definition at line 323 of file cmsis_os2.h.

◆ osThreadFunc_t

typedef void(* osThreadFunc_t) (void *argument)

Entry point of a thread.

Definition at line 234 of file cmsis_os2.h.

◆ osThreadId_t

typedef void* osThreadId_t

Thread ID identifies the thread.

Definition at line 311 of file cmsis_os2.h.

◆ osTimerFunc_t

typedef void(* osTimerFunc_t) (void *argument)

Timer callback function.

Definition at line 237 of file cmsis_os2.h.

◆ osTimerId_t

typedef void* osTimerId_t

Timer ID identifies the timer.

Definition at line 314 of file cmsis_os2.h.

◆ TZ_ModuleId_t

typedef uint32_t TZ_ModuleId_t

Data type that identifies secure software modules called by a process.

Definition at line 335 of file cmsis_os2.h.

Enumeration Type Documentation

◆ osKernelState_t

Kernel state.

Enumerator
osKernelInactive 

Inactive.

osKernelReady 

Ready.

osKernelRunning 

Running.

osKernelLocked 

Locked.

osKernelSuspended 

Suspended.

osKernelError 

Error.

osKernelReserved 

Prevents enum down-size compiler optimization.

Definition at line 155 of file cmsis_os2.h.

155 {
156 osKernelInactive = 0,
157 osKernelReady = 1,
158 osKernelRunning = 2,
159 osKernelLocked = 3,
161 osKernelError = -1,
162 osKernelReserved = 0x7FFFFFFF
osKernelState_t
Kernel state.
Definition cmsis_os2.h:155
@ osKernelLocked
Locked.
Definition cmsis_os2.h:159
@ osKernelError
Error.
Definition cmsis_os2.h:161
@ osKernelSuspended
Suspended.
Definition cmsis_os2.h:160
@ osKernelReady
Ready.
Definition cmsis_os2.h:157
@ osKernelRunning
Running.
Definition cmsis_os2.h:158
@ osKernelReserved
Prevents enum down-size compiler optimization.
Definition cmsis_os2.h:162
@ osKernelInactive
Inactive.
Definition cmsis_os2.h:156

◆ osPriority_t

Priority values.

Enumerator
osPriorityNone 

No priority (not initialized).

osPriorityIdle 

Reserved for Idle thread.

osPriorityLow 

Priority: low.

osPriorityLow1 

Priority: low + 1.

osPriorityLow2 

Priority: low + 2.

osPriorityLow3 

Priority: low + 3.

osPriorityLow4 

Priority: low + 4.

osPriorityLow5 

Priority: low + 5.

osPriorityLow6 

Priority: low + 6.

osPriorityLow7 

Priority: low + 7.

osPriorityBelowNormal 

Priority: below normal.

osPriorityBelowNormal1 

Priority: below normal + 1.

osPriorityBelowNormal2 

Priority: below normal + 2.

osPriorityBelowNormal3 

Priority: below normal + 3.

osPriorityBelowNormal4 

Priority: below normal + 4.

osPriorityBelowNormal5 

Priority: below normal + 5.

osPriorityBelowNormal6 

Priority: below normal + 6.

osPriorityBelowNormal7 

Priority: below normal + 7.

osPriorityNormal 

Priority: normal.

osPriorityNormal1 

Priority: normal + 1.

osPriorityNormal2 

Priority: normal + 2.

osPriorityNormal3 

Priority: normal + 3.

osPriorityNormal4 

Priority: normal + 4.

osPriorityNormal5 

Priority: normal + 5.

osPriorityNormal6 

Priority: normal + 6.

osPriorityNormal7 

Priority: normal + 7.

osPriorityAboveNormal 

Priority: above normal.

osPriorityAboveNormal1 

Priority: above normal + 1.

osPriorityAboveNormal2 

Priority: above normal + 2.

osPriorityAboveNormal3 

Priority: above normal + 3.

osPriorityAboveNormal4 

Priority: above normal + 4.

osPriorityAboveNormal5 

Priority: above normal + 5.

osPriorityAboveNormal6 

Priority: above normal + 6.

osPriorityAboveNormal7 

Priority: above normal + 7.

osPriorityHigh 

Priority: high.

osPriorityHigh1 

Priority: high + 1.

osPriorityHigh2 

Priority: high + 2.

osPriorityHigh3 

Priority: high + 3.

osPriorityHigh4 

Priority: high + 4.

osPriorityHigh5 

Priority: high + 5.

osPriorityHigh6 

Priority: high + 6.

osPriorityHigh7 

Priority: high + 7.

osPriorityRealtime 

Priority: realtime.

osPriorityRealtime1 

Priority: realtime + 1.

osPriorityRealtime2 

Priority: realtime + 2.

osPriorityRealtime3 

Priority: realtime + 3.

osPriorityRealtime4 

Priority: realtime + 4.

osPriorityRealtime5 

Priority: realtime + 5.

osPriorityRealtime6 

Priority: realtime + 6.

osPriorityRealtime7 

Priority: realtime + 7.

osPriorityISR 

Reserved for ISR deferred thread.

osPriorityError 

System cannot determine priority or illegal priority.

osPriorityReserved 

Prevents enum down-size compiler optimization.

Definition at line 177 of file cmsis_os2.h.

177 {
178 osPriorityNone = 0,
179 osPriorityIdle = 1,
180 osPriorityLow = 8,
181 osPriorityLow1 = 8+1,
182 osPriorityLow2 = 8+2,
183 osPriorityLow3 = 8+3,
184 osPriorityLow4 = 8+4,
185 osPriorityLow5 = 8+5,
186 osPriorityLow6 = 8+6,
187 osPriorityLow7 = 8+7,
196 osPriorityNormal = 24,
197 osPriorityNormal1 = 24+1,
198 osPriorityNormal2 = 24+2,
199 osPriorityNormal3 = 24+3,
200 osPriorityNormal4 = 24+4,
201 osPriorityNormal5 = 24+5,
202 osPriorityNormal6 = 24+6,
203 osPriorityNormal7 = 24+7,
212 osPriorityHigh = 40,
213 osPriorityHigh1 = 40+1,
214 osPriorityHigh2 = 40+2,
215 osPriorityHigh3 = 40+3,
216 osPriorityHigh4 = 40+4,
217 osPriorityHigh5 = 40+5,
218 osPriorityHigh6 = 40+6,
219 osPriorityHigh7 = 40+7,
220 osPriorityRealtime = 48,
221 osPriorityRealtime1 = 48+1,
222 osPriorityRealtime2 = 48+2,
223 osPriorityRealtime3 = 48+3,
224 osPriorityRealtime4 = 48+4,
225 osPriorityRealtime5 = 48+5,
226 osPriorityRealtime6 = 48+6,
227 osPriorityRealtime7 = 48+7,
228 osPriorityISR = 56,
229 osPriorityError = -1,
230 osPriorityReserved = 0x7FFFFFFF
osPriority_t
Priority values.
Definition cmsis_os2.h:177
@ osPriorityNormal7
Priority: normal + 7.
Definition cmsis_os2.h:203
@ osPriorityHigh3
Priority: high + 3.
Definition cmsis_os2.h:215
@ osPriorityBelowNormal5
Priority: below normal + 5.
Definition cmsis_os2.h:193
@ osPriorityRealtime
Priority: realtime.
Definition cmsis_os2.h:220
@ osPriorityAboveNormal
Priority: above normal.
Definition cmsis_os2.h:204
@ osPriorityHigh1
Priority: high + 1.
Definition cmsis_os2.h:213
@ osPriorityBelowNormal
Priority: below normal.
Definition cmsis_os2.h:188
@ osPriorityBelowNormal3
Priority: below normal + 3.
Definition cmsis_os2.h:191
@ osPriorityNormal2
Priority: normal + 2.
Definition cmsis_os2.h:198
@ osPriorityLow3
Priority: low + 3.
Definition cmsis_os2.h:183
@ osPriorityBelowNormal4
Priority: below normal + 4.
Definition cmsis_os2.h:192
@ osPriorityISR
Reserved for ISR deferred thread.
Definition cmsis_os2.h:228
@ osPriorityNormal1
Priority: normal + 1.
Definition cmsis_os2.h:197
@ osPriorityRealtime3
Priority: realtime + 3.
Definition cmsis_os2.h:223
@ osPriorityNormal3
Priority: normal + 3.
Definition cmsis_os2.h:199
@ osPriorityHigh2
Priority: high + 2.
Definition cmsis_os2.h:214
@ osPriorityNormal
Priority: normal.
Definition cmsis_os2.h:196
@ osPriorityBelowNormal2
Priority: below normal + 2.
Definition cmsis_os2.h:190
@ osPriorityIdle
Reserved for Idle thread.
Definition cmsis_os2.h:179
@ osPriorityHigh6
Priority: high + 6.
Definition cmsis_os2.h:218
@ osPriorityHigh5
Priority: high + 5.
Definition cmsis_os2.h:217
@ osPriorityLow4
Priority: low + 4.
Definition cmsis_os2.h:184
@ osPriorityLow7
Priority: low + 7.
Definition cmsis_os2.h:187
@ osPriorityLow
Priority: low.
Definition cmsis_os2.h:180
@ osPriorityAboveNormal6
Priority: above normal + 6.
Definition cmsis_os2.h:210
@ osPriorityHigh7
Priority: high + 7.
Definition cmsis_os2.h:219
@ osPriorityNormal5
Priority: normal + 5.
Definition cmsis_os2.h:201
@ osPriorityNone
No priority (not initialized).
Definition cmsis_os2.h:178
@ osPriorityAboveNormal4
Priority: above normal + 4.
Definition cmsis_os2.h:208
@ osPriorityLow2
Priority: low + 2.
Definition cmsis_os2.h:182
@ osPriorityRealtime6
Priority: realtime + 6.
Definition cmsis_os2.h:226
@ osPriorityNormal6
Priority: normal + 6.
Definition cmsis_os2.h:202
@ osPriorityAboveNormal2
Priority: above normal + 2.
Definition cmsis_os2.h:206
@ osPriorityBelowNormal1
Priority: below normal + 1.
Definition cmsis_os2.h:189
@ osPriorityHigh
Priority: high.
Definition cmsis_os2.h:212
@ osPriorityNormal4
Priority: normal + 4.
Definition cmsis_os2.h:200
@ osPriorityRealtime7
Priority: realtime + 7.
Definition cmsis_os2.h:227
@ osPriorityBelowNormal7
Priority: below normal + 7.
Definition cmsis_os2.h:195
@ osPriorityRealtime2
Priority: realtime + 2.
Definition cmsis_os2.h:222
@ osPriorityLow1
Priority: low + 1.
Definition cmsis_os2.h:181
@ osPriorityBelowNormal6
Priority: below normal + 6.
Definition cmsis_os2.h:194
@ osPriorityAboveNormal1
Priority: above normal + 1.
Definition cmsis_os2.h:205
@ osPriorityLow6
Priority: low + 6.
Definition cmsis_os2.h:186
@ osPriorityReserved
Prevents enum down-size compiler optimization.
Definition cmsis_os2.h:230
@ osPriorityAboveNormal3
Priority: above normal + 3.
Definition cmsis_os2.h:207
@ osPriorityLow5
Priority: low + 5.
Definition cmsis_os2.h:185
@ osPriorityAboveNormal7
Priority: above normal + 7.
Definition cmsis_os2.h:211
@ osPriorityError
System cannot determine priority or illegal priority.
Definition cmsis_os2.h:229
@ osPriorityAboveNormal5
Priority: above normal + 5.
Definition cmsis_os2.h:209
@ osPriorityRealtime4
Priority: realtime + 4.
Definition cmsis_os2.h:224
@ osPriorityRealtime1
Priority: realtime + 1.
Definition cmsis_os2.h:221
@ osPriorityHigh4
Priority: high + 4.
Definition cmsis_os2.h:216
@ osPriorityRealtime5
Priority: realtime + 5.
Definition cmsis_os2.h:225

◆ osStatus_t

enum osStatus_t

Status code values returned by CMSIS-RTOS functions.

Enumerator
osOK 

Operation completed successfully.

osError 

Unspecified RTOS error: run-time error but no other error message fits.

osErrorTimeout 

Operation not completed within the timeout period.

osErrorResource 

Resource not available.

osErrorParameter 

Parameter error.

osErrorNoMemory 

System is out of memory: it was impossible to allocate or reserve memory for the operation.

osErrorISR 

Not allowed in ISR context: the function cannot be called from interrupt service routines.

osErrorSafetyClass 

Operation denied because of safety class violation.

osStatusReserved 

Prevents enum down-size compiler optimization.

Definition at line 297 of file cmsis_os2.h.

297 {
298 osOK = 0,
299 osError = -1,
300 osErrorTimeout = -2,
301 osErrorResource = -3,
302 osErrorParameter = -4,
303 osErrorNoMemory = -5,
304 osErrorISR = -6,
305 osErrorSafetyClass = -7,
306 osStatusReserved = 0x7FFFFFFF
307} osStatus_t;
osStatus_t
Status code values returned by CMSIS-RTOS functions.
Definition cmsis_os2.h:297
@ osErrorISR
Not allowed in ISR context: the function cannot be called from interrupt service routines.
Definition cmsis_os2.h:304
@ osStatusReserved
Prevents enum down-size compiler optimization.
Definition cmsis_os2.h:306
@ osErrorResource
Resource not available.
Definition cmsis_os2.h:301
@ osErrorTimeout
Operation not completed within the timeout period.
Definition cmsis_os2.h:300
@ osOK
Operation completed successfully.
Definition cmsis_os2.h:298
@ osError
Unspecified RTOS error: run-time error but no other error message fits.
Definition cmsis_os2.h:299
@ osErrorParameter
Parameter error.
Definition cmsis_os2.h:302
@ osErrorNoMemory
System is out of memory: it was impossible to allocate or reserve memory for the operation.
Definition cmsis_os2.h:303
@ osErrorSafetyClass
Operation denied because of safety class violation.
Definition cmsis_os2.h:305

◆ osThreadState_t

Thread state.

Enumerator
osThreadInactive 

Inactive.

osThreadReady 

Ready.

osThreadRunning 

Running.

osThreadBlocked 

Blocked.

osThreadTerminated 

Terminated.

osThreadError 

Error.

osThreadReserved 

Prevents enum down-size compiler optimization.

Definition at line 166 of file cmsis_os2.h.

166 {
167 osThreadInactive = 0,
168 osThreadReady = 1,
169 osThreadRunning = 2,
170 osThreadBlocked = 3,
172 osThreadError = -1,
173 osThreadReserved = 0x7FFFFFFF
osThreadState_t
Thread state.
Definition cmsis_os2.h:166
@ osThreadBlocked
Blocked.
Definition cmsis_os2.h:170
@ osThreadRunning
Running.
Definition cmsis_os2.h:169
@ osThreadInactive
Inactive.
Definition cmsis_os2.h:167
@ osThreadReserved
Prevents enum down-size compiler optimization.
Definition cmsis_os2.h:173
@ osThreadTerminated
Terminated.
Definition cmsis_os2.h:171
@ osThreadError
Error.
Definition cmsis_os2.h:172
@ osThreadReady
Ready.
Definition cmsis_os2.h:168

◆ osTimerType_t

Timer type.

Enumerator
osTimerOnce 

One-shot timer.

osTimerPeriodic 

Repeating timer.

Definition at line 240 of file cmsis_os2.h.

240 {
241 osTimerOnce = 0,
242 osTimerPeriodic = 1
osTimerType_t
Timer type.
Definition cmsis_os2.h:240
@ osTimerPeriodic
Repeating timer.
Definition cmsis_os2.h:242
@ osTimerOnce
One-shot timer.
Definition cmsis_os2.h:241

Function Documentation

◆ osDelay()

osStatus_t osDelay ( uint32_t ticks)

Wait for Timeout (Time Delay).

Parameters
[in]tickstime ticks value
Returns
status code that indicates the execution status of the function.

Definition at line 1039 of file cmsis_os2_stk.cpp.

1040{
1041 if (IsIrqContext())
1042 return osErrorISR;
1044 return osError;
1045
1046 stk::Timeout timeout = CmsisTimeoutToStk(ticks);
1047
1048 stk::Sleep(timeout);
1049 return osOK;
1050}
static __stk_forceinline bool IsIrqContext()
static __stk_forceinline stk::Timeout CmsisTimeoutToStk(uint32_t ticks)
osKernelState_t osKernelGetState(void)
void Sleep(Timeout tick_count)
Put calling process into a sleep state.
Definition stk_helper.h:341
int32_t Timeout
Timeout time (ticks).
Definition stk_common.h:125

References CmsisTimeoutToStk(), IsIrqContext(), osError, osErrorISR, osKernelGetState(), osKernelInactive, osOK, and stk::Sleep().

Here is the call graph for this function:

◆ osDelayUntil()

osStatus_t osDelayUntil ( uint32_t ticks)

Wait until specified time.

Parameters
[in]ticksabsolute time in ticks
Returns
status code that indicates the execution status of the function.

Definition at line 1052 of file cmsis_os2_stk.cpp.

1053{
1054 if (IsIrqContext())
1055 return osErrorISR;
1057 return osError;
1058
1059 stk::SleepUntil(static_cast<stk::Ticks>(ticks));
1060 return osOK;
1061}
int64_t Ticks
Ticks value.
Definition stk_common.h:130
bool SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
Definition stk_helper.h:367

References IsIrqContext(), osError, osErrorISR, osKernelGetState(), osKernelInactive, osOK, and stk::SleepUntil().

Here is the call graph for this function:

◆ osEventFlagsClear()

uint32_t osEventFlagsClear ( osEventFlagsId_t ef_id,
uint32_t flags )

Clear the specified Event Flags.

Parameters
[in]ef_idevent flags ID obtained by osEventFlagsNew.
[in]flagsspecifies the flags that shall be cleared.
Returns
event flags before clearing or error code if highest bit set.

Definition at line 1178 of file cmsis_os2_stk.cpp.

1179{
1180 if ((ef_id == nullptr) || ((flags & osFlagsError) != 0U))
1181 return osFlagsErrorParameter;
1182
1183 uint32_t result = static_cast<StkEventFlags *>(ef_id)->m_ef.Clear(flags);
1184 return StkFlagsResultToCmsis(result);
1185}
static __stk_forceinline uint32_t StkFlagsResultToCmsis(uint32_t result)
#define osFlagsError
Error indicator.
Definition cmsis_os2.h:254
#define osFlagsErrorParameter
osErrorParameter (-4).
Definition cmsis_os2.h:258

References osFlagsError, osFlagsErrorParameter, and StkFlagsResultToCmsis().

Here is the call graph for this function:

◆ osEventFlagsDelete()

osStatus_t osEventFlagsDelete ( osEventFlagsId_t ef_id)

Delete an Event Flags object.

Parameters
[in]ef_idevent flags ID obtained by osEventFlagsNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1207 of file cmsis_os2_stk.cpp.

1208{
1209 if (IsIrqContext() || (ef_id == nullptr))
1211
1212 ObjDestroy(static_cast<StkEventFlags *>(ef_id));
1213 return osOK;
1214}
static void ObjDestroy(T *obj)

References IsIrqContext(), ObjDestroy(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osEventFlagsGet()

uint32_t osEventFlagsGet ( osEventFlagsId_t ef_id)

Get the current Event Flags.

Parameters
[in]ef_idevent flags ID obtained by osEventFlagsNew.
Returns
current event flags.

Definition at line 1187 of file cmsis_os2_stk.cpp.

1188{
1189 if (ef_id == nullptr)
1190 return 0U;
1191
1192 return static_cast<StkEventFlags *>(ef_id)->m_ef.Get();
1193}

◆ osEventFlagsGetName()

const char * osEventFlagsGetName ( osEventFlagsId_t ef_id)

Get name of an Event Flags object.

Parameters
[in]ef_idevent flags ID obtained by osEventFlagsNew.
Returns
name as null-terminated string.

Definition at line 1161 of file cmsis_os2_stk.cpp.

1162{
1163 if (ef_id == nullptr)
1164 return nullptr;
1165
1166 return static_cast<StkEventFlags *>(ef_id)->m_ef.GetTraceName();
1167}

◆ osEventFlagsNew()

osEventFlagsId_t osEventFlagsNew ( const osEventFlagsAttr_t * attr)

Create and Initialize an Event Flags object.

Parameters
[in]attrevent flags attributes; NULL: default values.
Returns
event flags ID for reference by other functions or NULL in case of error.

Definition at line 1148 of file cmsis_os2_stk.cpp.

1149{
1150 if (IsIrqContext())
1151 return nullptr;
1152
1153 const char *name = (attr != nullptr ? attr->name : nullptr);
1154 void *cb_mem = (attr != nullptr ? attr->cb_mem : nullptr);
1155 uint32_t cb_sz = (attr != nullptr ? attr->cb_size : 0U);
1156
1157 StkEventFlags *ef = PlacementNewOrHeap<StkEventFlags>(cb_mem, cb_sz, name);
1158 return static_cast<osEventFlagsId_t>(ef);
1159}
static T * PlacementNewOrHeap(void *cb_mem, size_t cb_size, Args &&...args)
void * osEventFlagsId_t
Definition cmsis_os2.h:317
uint32_t cb_size
size of provided memory for control block
Definition cmsis_os2.h:365
const char * name
name of the event flags
Definition cmsis_os2.h:362
void * cb_mem
memory for control block
Definition cmsis_os2.h:364

References osEventFlagsAttr_t::cb_mem, osEventFlagsAttr_t::cb_size, IsIrqContext(), osEventFlagsAttr_t::name, and PlacementNewOrHeap().

Here is the call graph for this function:

◆ osEventFlagsSet()

uint32_t osEventFlagsSet ( osEventFlagsId_t ef_id,
uint32_t flags )

Set the specified Event Flags.

Parameters
[in]ef_idevent flags ID obtained by osEventFlagsNew.
[in]flagsspecifies the flags that shall be set.
Returns
event flags after setting or error code if highest bit set.

Definition at line 1169 of file cmsis_os2_stk.cpp.

1170{
1171 if ((ef_id == nullptr) || ((flags & osFlagsError) != 0U))
1172 return osFlagsErrorParameter;
1173
1174 uint32_t result = static_cast<StkEventFlags *>(ef_id)->m_ef.Set(flags);
1175 return StkFlagsResultToCmsis(result);
1176}

References osFlagsError, osFlagsErrorParameter, and StkFlagsResultToCmsis().

Here is the call graph for this function:

◆ osEventFlagsWait()

uint32_t osEventFlagsWait ( osEventFlagsId_t ef_id,
uint32_t flags,
uint32_t options,
uint32_t timeout )

Wait for one or more Event Flags to become signaled.

Parameters
[in]ef_idevent flags ID obtained by osEventFlagsNew.
[in]flagsspecifies the flags to wait for.
[in]optionsspecifies flags options (osFlagsXxxx).
[in]timeoutCMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
Returns
event flags before clearing or error code if highest bit set.

Definition at line 1195 of file cmsis_os2_stk.cpp.

1197{
1198 if ((ef_id == nullptr) || ((flags & osFlagsError) != 0U))
1199 return osFlagsErrorParameter;
1200
1201 uint32_t result = static_cast<StkEventFlags *>(ef_id)->m_ef.Wait(flags,
1202 CmsisFlagsOptionsToStk(options), CmsisTimeoutToStk(timeout));
1203
1204 return StkFlagsResultToCmsis(result);
1205}
static __stk_forceinline uint32_t CmsisFlagsOptionsToStk(uint32_t options)

References CmsisFlagsOptionsToStk(), CmsisTimeoutToStk(), osFlagsError, osFlagsErrorParameter, and StkFlagsResultToCmsis().

Here is the call graph for this function:

◆ osFaultResume()

void osFaultResume ( void )

Resume normal operation when exiting exception faults.

◆ osKernelDestroyClass()

osStatus_t osKernelDestroyClass ( uint32_t safety_class,
uint32_t mode )

Destroy objects for specified safety classes.

Parameters
[in]safety_classsafety class.
[in]modesafety mode.
Returns
status code that indicates the execution status of the function.

◆ osKernelGetInfo()

osStatus_t osKernelGetInfo ( osVersion_t * version,
char * id_buf,
uint32_t id_size )

Get RTOS Kernel Information.

Parameters
[out]versionpointer to buffer for retrieving version information.
[out]id_bufpointer to buffer for retrieving kernel identification string.
[in]id_sizesize of buffer for kernel identification string.
Returns
status code that indicates the execution status of the function.

Definition at line 483 of file cmsis_os2_stk.cpp.

484{
485 if (version != nullptr)
486 {
487 version->api = STK_WRAPPER_API_VERSION;
489 }
490
491 if ((id_buf != nullptr) && (id_size > 0U))
492 {
493 const char *id = STK_WRAPPER_KERNEL_ID;
494 size_t copy_len = id_size - 1U;
495 size_t id_len = __builtin_strlen(id);
496 if (copy_len > id_len)
497 copy_len = id_len;
498
499 memcpy(id_buf, id, copy_len);
500 id_buf[copy_len] = '\0';
501 }
502
503 return osOK;
504}
#define STK_WRAPPER_KERNEL_VERSION
#define STK_WRAPPER_KERNEL_ID
#define STK_WRAPPER_API_VERSION
uint32_t api
API version (major.minor.rev: mmnnnrrrr dec).
Definition cmsis_os2.h:150
uint32_t kernel
Kernel version (major.minor.rev: mmnnnrrrr dec).
Definition cmsis_os2.h:151

References osVersion_t::api, osVersion_t::kernel, osOK, STK_WRAPPER_API_VERSION, STK_WRAPPER_KERNEL_ID, and STK_WRAPPER_KERNEL_VERSION.

◆ osKernelGetState()

osKernelState_t osKernelGetState ( void )

Get the current RTOS Kernel state.

Returns
current RTOS Kernel state.

Definition at line 506 of file cmsis_os2_stk.cpp.

507{
508 if (g_StkKernelLocked != 0U)
509 return osKernelLocked;
510
511 switch (g_StkKernel.GetState())
512 {
517 default: return osKernelError;
518 }
519}
static uint32_t g_StkKernelLocked
static StkKernel g_StkKernel
@ KSTATE_RUNNING
Initialized and running, IKernel::Start() was called successfully.
@ KSTATE_SUSPENDED
Scheduling is suspended with IKernelService::Suspend().
@ KSTATE_INACTIVE
Not ready, IKernel::Initialize() must be called.
@ KSTATE_READY
Ready to start, IKernel::Start() must be called.

References g_StkKernel, g_StkKernelLocked, stk::IKernel::KSTATE_INACTIVE, stk::IKernel::KSTATE_READY, stk::IKernel::KSTATE_RUNNING, stk::IKernel::KSTATE_SUSPENDED, osKernelError, osKernelInactive, osKernelLocked, osKernelReady, osKernelRunning, and osKernelSuspended.

Referenced by osDelay(), osDelayUntil(), osKernelGetTickCount(), osKernelGetTickFreq(), osKernelInitialize(), osKernelResume(), osKernelStart(), osKernelSuspend(), osThreadEnumerate(), osThreadGetCount(), osThreadGetId(), osThreadNew(), osThreadResume(), osThreadSuspend(), osThreadTerminate(), osThreadYield(), and osTimerNew().

Here is the caller graph for this function:

◆ osKernelGetSysTimerCount()

uint32_t osKernelGetSysTimerCount ( void )

Get the RTOS kernel system timer count.

Returns
RTOS kernel current system timer count as 32-bit value.

Definition at line 623 of file cmsis_os2_stk.cpp.

624{
625 return static_cast<uint32_t>(stk::GetSysTimerCount());
626}
Cycles GetSysTimerCount()
Get system timer count value.
Definition stk_helper.h:321

References stk::GetSysTimerCount().

Here is the call graph for this function:

◆ osKernelGetSysTimerCount64()

uint64_t osKernelGetSysTimerCount64 ( void )

Get the RTOS kernel system timer count.

Returns
RTOS kernel current system timer count as 64-bit value.

Definition at line 628 of file cmsis_os2_stk.cpp.

629{
630 return stk::GetSysTimerCount();
631}

References stk::GetSysTimerCount().

Here is the call graph for this function:

◆ osKernelGetSysTimerFreq()

uint32_t osKernelGetSysTimerFreq ( void )

Get the RTOS kernel system timer frequency.

Returns
frequency of the system timer in hertz, i.e. timer ticks per second.

Definition at line 633 of file cmsis_os2_stk.cpp.

634{
636}
uint32_t GetSysTimerFrequency()
Get system timer frequency.
Definition stk_helper.h:330

References stk::GetSysTimerFrequency().

Here is the call graph for this function:

◆ osKernelGetTickCount()

uint32_t osKernelGetTickCount ( void )

Get the RTOS kernel tick count.

Returns
RTOS kernel current tick count.

Definition at line 603 of file cmsis_os2_stk.cpp.

604{
606 return 0U;
607
608 return static_cast<uint32_t>(stk::GetTicks());
609}
Ticks GetTicks()
Get number of ticks elapsed since kernel start.
Definition stk_helper.h:274

References stk::GetTicks(), osKernelGetState(), and osKernelInactive.

Here is the call graph for this function:

◆ osKernelGetTickFreq()

uint32_t osKernelGetTickFreq ( void )

Get the RTOS kernel tick frequency.

Returns
frequency of the kernel tick in hertz, i.e. kernel ticks per second.

Definition at line 611 of file cmsis_os2_stk.cpp.

612{
614 return 1000U; // default 1 kHz
615
616 int32_t res_us = stk::GetTickResolution(); // us per tick
617 if (res_us <= 0)
618 return 1000U;
619
620 return (1000000U / static_cast<uint32_t>(res_us));
621}
uint32_t GetTickResolution()
Get number of microseconds in one tick.
Definition stk_helper.h:284

References stk::GetTickResolution(), osKernelGetState(), and osKernelInactive.

Here is the call graph for this function:

◆ osKernelInitialize()

osStatus_t osKernelInitialize ( void )

Initialize the RTOS Kernel.

Returns
status code that indicates the execution status of the function.

Definition at line 471 of file cmsis_os2_stk.cpp.

472{
473 if (IsIrqContext())
474 return osErrorISR;
475
477 return osError;
478
479 g_StkKernel.Initialize(); // default 1 ms tick resolution
480 return osOK;
481}

References g_StkKernel, IsIrqContext(), osError, osErrorISR, osKernelGetState(), osKernelInactive, and osOK.

Here is the call graph for this function:

◆ osKernelLock()

int32_t osKernelLock ( void )

Lock the RTOS Kernel scheduler.

Returns
previous lock state (1 - locked, 0 - not locked, error code if negative).

Definition at line 535 of file cmsis_os2_stk.cpp.

536{
537 if (IsIrqContext())
538 return static_cast<int32_t>(osErrorISR);
539
542 return 0;
543}
static void Enter()
Enter a critical section.

References stk::hw::CriticalSection::Enter(), g_StkKernelLocked, IsIrqContext(), and osErrorISR.

Here is the call graph for this function:

◆ osKernelProtect()

osStatus_t osKernelProtect ( uint32_t safety_class)

Protect the RTOS Kernel scheduler access.

Parameters
[in]safety_classsafety class.
Returns
status code that indicates the execution status of the function.

◆ osKernelRestoreLock()

int32_t osKernelRestoreLock ( int32_t lock)

Restore the RTOS Kernel scheduler lock state.

Parameters
[in]locklock state obtained by osKernelLock or osKernelUnlock.
Returns
new lock state (1 - locked, 0 - not locked, error code if negative).

Definition at line 557 of file cmsis_os2_stk.cpp.

558{
559 if (IsIrqContext())
560 return static_cast<int32_t>(osErrorISR);
561
562 if (lock == 1)
563 {
566 }
567 else
568 {
569 if (g_StkKernelLocked == 0U)
570 return osErrorResource;
571
574 }
575
576 return lock;
577}
static void Exit()
Exit a critical section.

References stk::hw::CriticalSection::Enter(), stk::hw::CriticalSection::Exit(), g_StkKernelLocked, IsIrqContext(), osErrorISR, and osErrorResource.

Here is the call graph for this function:

◆ osKernelResume()

void osKernelResume ( uint32_t sleep_ticks)

Resume the RTOS Kernel scheduler.

Parameters
[in]sleep_tickstime in ticks for how long the system was in sleep or power-down mode.

Definition at line 592 of file cmsis_os2_stk.cpp.

593{
594#if STK_TICKLESS_IDLE
596 return stk::IKernelService::GetInstance()->Resume(sleep_ticks);
597#else
598 // Not supported in non-tickless kernel.
599 STK_UNUSED(sleep_ticks);
600#endif
601}
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:610
static IKernelService * GetInstance()
Get CPU-local instance of the kernel service.
virtual void Resume(Timeout elapsed_ticks)=0
Resume scheduling after a prior Suspend() call.

References stk::IKernelService::GetInstance(), osKernelGetState(), osKernelInactive, stk::IKernelService::Resume(), and STK_UNUSED.

Here is the call graph for this function:

◆ osKernelStart()

osStatus_t osKernelStart ( void )

Start the RTOS Kernel scheduler.

Returns
status code that indicates the execution status of the function.

Definition at line 521 of file cmsis_os2_stk.cpp.

522{
523 if (IsIrqContext())
524 return osErrorISR;
525
527 return osError;
528
529 // Start() does not return for KERNEL_STATIC;
530 // for KERNEL_DYNAMIC it returns when all tasks exit.
531 g_StkKernel.Start();
532 return osOK;
533}

References g_StkKernel, IsIrqContext(), osError, osErrorISR, osKernelGetState(), osKernelReady, and osOK.

Here is the call graph for this function:

◆ osKernelSuspend()

uint32_t osKernelSuspend ( void )

Suspend the RTOS Kernel scheduler.

Returns
time in ticks, for how long the system can sleep or power-down.

Definition at line 579 of file cmsis_os2_stk.cpp.

580{
581#if STK_TICKLESS_IDLE
583 return 0U;
584
586#else
587 // Not supported in non-tickless kernel.
588 return 0U;
589#endif
590}
virtual Timeout Suspend()=0
Suspend scheduling.

References stk::IKernelService::GetInstance(), osKernelGetState(), osKernelInactive, and stk::IKernelService::Suspend().

Here is the call graph for this function:

◆ osKernelUnlock()

int32_t osKernelUnlock ( void )

Unlock the RTOS Kernel scheduler.

Returns
previous lock state (1 - locked, 0 - not locked, error code if negative).

Definition at line 545 of file cmsis_os2_stk.cpp.

546{
547 if (IsIrqContext())
548 return static_cast<int32_t>(osErrorISR);
549 if (g_StkKernelLocked == 0U)
550 return osErrorResource;
551
554 return 0;
555}

References stk::hw::CriticalSection::Exit(), g_StkKernelLocked, IsIrqContext(), osErrorISR, and osErrorResource.

Here is the call graph for this function:

◆ osMemoryPoolAlloc()

void * osMemoryPoolAlloc ( osMemoryPoolId_t mp_id,
uint32_t timeout )

Allocate a memory block from a Memory Pool.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
[in]timeoutCMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
Returns
address of the allocated memory block or NULL in case of no memory is available.

Definition at line 1436 of file cmsis_os2_stk.cpp.

1437{
1438 if (mp_id == nullptr)
1439 return nullptr;
1440
1441 // ISR context is only valid with timeout == 0 (NO_WAIT / TryAlloc).
1442 if (IsIrqContext() && (timeout != 0U))
1443 return nullptr;
1444
1445 return static_cast<StkMemPool *>(mp_id)->m_mpool.TimedAlloc(CmsisTimeoutToStk(timeout));
1446}

References CmsisTimeoutToStk(), and IsIrqContext().

Here is the call graph for this function:

◆ osMemoryPoolDelete()

osStatus_t osMemoryPoolDelete ( osMemoryPoolId_t mp_id)

Delete a Memory Pool object.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1491 of file cmsis_os2_stk.cpp.

1492{
1493 if (IsIrqContext() || (mp_id == nullptr))
1495
1496 ObjDestroy(static_cast<StkMemPool *>(mp_id));
1497
1498 return osOK;
1499}

References IsIrqContext(), ObjDestroy(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osMemoryPoolFree()

osStatus_t osMemoryPoolFree ( osMemoryPoolId_t mp_id,
void * block )

Return an allocated memory block back to a Memory Pool.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
[in]blockaddress of the allocated memory block to be returned to the memory pool.
Returns
status code that indicates the execution status of the function.

Definition at line 1448 of file cmsis_os2_stk.cpp.

1449{
1450 if ((mp_id == nullptr) || (block == nullptr))
1451 return osErrorParameter;
1452
1453 if (!static_cast<StkMemPool *>(mp_id)->m_mpool.Free(block))
1454 return osErrorParameter; // ptr not from this pool
1455
1456 return osOK;
1457}

References osErrorParameter, and osOK.

◆ osMemoryPoolGetBlockSize()

uint32_t osMemoryPoolGetBlockSize ( osMemoryPoolId_t mp_id)

Get memory block size in a Memory Pool.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
Returns
memory block size in bytes.

Definition at line 1467 of file cmsis_os2_stk.cpp.

1468{
1469 if (mp_id == nullptr)
1470 return 0U;
1471
1472 return static_cast<uint32_t>(static_cast<StkMemPool *>(mp_id)->m_mpool.GetBlockSize());
1473}
size_t GetBlockSize() const
Get the aligned block size used internally by the allocator.
stk::memory::BlockMemoryPool m_mpool

References stk::memory::BlockMemoryPool::GetBlockSize(), and StkMemPool::m_mpool.

Here is the call graph for this function:

◆ osMemoryPoolGetCapacity()

uint32_t osMemoryPoolGetCapacity ( osMemoryPoolId_t mp_id)

Get maximum number of memory blocks in a Memory Pool.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
Returns
maximum number of memory blocks.

Definition at line 1459 of file cmsis_os2_stk.cpp.

1460{
1461 if (mp_id == nullptr)
1462 return 0U;
1463
1464 return static_cast<StkMemPool *>(mp_id)->m_mpool.GetCapacity();
1465}

◆ osMemoryPoolGetCount()

uint32_t osMemoryPoolGetCount ( osMemoryPoolId_t mp_id)

Get number of memory blocks used in a Memory Pool.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
Returns
number of memory blocks used.

Definition at line 1475 of file cmsis_os2_stk.cpp.

1476{
1477 if (mp_id == nullptr)
1478 return 0U;
1479
1480 return static_cast<StkMemPool *>(mp_id)->m_mpool.GetUsedCount();
1481}

◆ osMemoryPoolGetName()

const char * osMemoryPoolGetName ( osMemoryPoolId_t mp_id)

Get name of a Memory Pool object.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
Returns
name as null-terminated string.

Definition at line 1428 of file cmsis_os2_stk.cpp.

1429{
1430 if (mp_id == nullptr)
1431 return nullptr;
1432
1433 return static_cast<StkMemPool *>(mp_id)->m_mpool.GetTraceName();
1434}

◆ osMemoryPoolGetSpace()

uint32_t osMemoryPoolGetSpace ( osMemoryPoolId_t mp_id)

Get number of memory blocks available in a Memory Pool.

Parameters
[in]mp_idmemory pool ID obtained by osMemoryPoolNew.
Returns
number of memory blocks available.

Definition at line 1483 of file cmsis_os2_stk.cpp.

1484{
1485 if (mp_id == nullptr)
1486 return 0U;
1487
1488 return static_cast<StkMemPool *>(mp_id)->m_mpool.GetFreeCount();
1489}

◆ osMemoryPoolNew()

osMemoryPoolId_t osMemoryPoolNew ( uint32_t block_count,
uint32_t block_size,
const osMemoryPoolAttr_t * attr )

Create and Initialize a Memory Pool object.

Parameters
[in]block_countmaximum number of memory blocks in memory pool.
[in]block_sizememory block size in bytes.
[in]attrmemory pool attributes; NULL: default values.
Returns
memory pool ID for reference by other functions or NULL in case of error.

Definition at line 1382 of file cmsis_os2_stk.cpp.

1384{
1385 // ISR context: forbidden per CMSIS spec.
1386 if (IsIrqContext())
1387 return nullptr;
1388
1389 // Zero capacity or zero block size are meaningless.
1390 if ((block_count == 0U) || (block_size == 0U))
1391 return nullptr;
1392
1393 const char *name = (attr != nullptr ? attr->name : nullptr);
1394 void *cb_mem = (attr != nullptr ? attr->cb_mem : nullptr);
1395 uint32_t cb_sz = (attr != nullptr ? attr->cb_size : 0U);
1396 void *mp_mem = (attr != nullptr ? attr->mp_mem : nullptr);
1397 uint32_t mp_sz = (attr != nullptr ? attr->mp_size : 0U);
1398
1399 // Compute the aligned block size and required storage byte count.
1400 const uint32_t aligned_blk = stk::memory::BlockMemoryPool::AlignBlockSize(block_size);
1401 const uint32_t storage_required = (block_count * aligned_blk);
1402
1403 StkMemPool *pool = nullptr;
1404
1405 if ((mp_mem != nullptr) && (mp_sz >= storage_required))
1406 {
1407 // Caller-supplied pool storage - BlockMemoryPool external-storage ctor.
1408 pool = PlacementNewOrHeap<StkMemPool>(cb_mem, cb_sz,
1409 block_count, block_size, name, static_cast<uint8_t *>(mp_mem));
1410 }
1411 else
1412 {
1413 // Heap-allocated pool storage - BlockMemoryPool heap ctor.
1414 pool = PlacementNewOrHeap<StkMemPool>(cb_mem, cb_sz,
1415 block_count, block_size, name);
1416
1417 // If the heap ctor failed to allocate storage, clean up and bail.
1418 if ((pool != nullptr) && !pool->m_mpool.IsStorageValid())
1419 {
1420 ObjDestroy(pool);
1421 return nullptr;
1422 }
1423 }
1424
1425 return static_cast<osMemoryPoolId_t>(pool);
1426}
void * osMemoryPoolId_t
Definition cmsis_os2.h:326
bool IsStorageValid() const
Verify that the backing storage is valid and the pool is ready for use.
static constexpr size_t AlignBlockSize(size_t raw_size)
Round a raw block size up to the nearest multiple of BLOCK_ALIGN.
uint32_t mp_size
size of provided memory for data storage
Definition cmsis_os2.h:391
const char * name
name of the memory pool
Definition cmsis_os2.h:386
void * cb_mem
memory for control block
Definition cmsis_os2.h:388
uint32_t cb_size
size of provided memory for control block
Definition cmsis_os2.h:389
void * mp_mem
memory for data storage
Definition cmsis_os2.h:390

References stk::memory::BlockMemoryPool::AlignBlockSize(), osMemoryPoolAttr_t::cb_mem, osMemoryPoolAttr_t::cb_size, IsIrqContext(), stk::memory::BlockMemoryPool::IsStorageValid(), StkMemPool::m_mpool, osMemoryPoolAttr_t::mp_mem, osMemoryPoolAttr_t::mp_size, osMemoryPoolAttr_t::name, ObjDestroy(), and PlacementNewOrHeap().

Here is the call graph for this function:

◆ osMessageQueueDelete()

osStatus_t osMessageQueueDelete ( osMessageQueueId_t mq_id)

Delete a Message Queue object.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1632 of file cmsis_os2_stk.cpp.

1633{
1634 if (IsIrqContext() || (mq_id == nullptr))
1636
1637 ObjDestroy(static_cast<StkMessageQueue *>(mq_id));
1638
1639 return osOK;
1640}

References IsIrqContext(), ObjDestroy(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osMessageQueueGet()

osStatus_t osMessageQueueGet ( osMessageQueueId_t mq_id,
void * msg_ptr,
uint8_t * msg_prio,
uint32_t timeout )

Get a Message from a Queue or timeout if Queue is empty.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
[out]msg_ptrpointer to buffer for message to get from a queue.
[out]msg_priopointer to buffer for message priority or NULL.
[in]timeoutCMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
Returns
status code that indicates the execution status of the function.

Definition at line 1571 of file cmsis_os2_stk.cpp.

1573{
1574 if (!mq_id || !msg_ptr)
1575 return osErrorParameter;
1576 if (IsIrqContext() && (timeout != 0U))
1577 return osErrorISR;
1578
1579 stk::Timeout stk_timeout = CmsisTimeoutToStk(timeout);
1580
1581 if (!static_cast<StkMessageQueue *>(mq_id)->m_mq.Get(msg_ptr, stk_timeout))
1582 return ((stk_timeout == stk::NO_WAIT) ? osErrorResource : osErrorTimeout);
1583
1584 if (msg_prio)
1585 *msg_prio = 0U; // STK queues have no priority lanes.
1586
1587 return osOK;
1588}
static constexpr Timeout NO_WAIT
Timeout value: return immediately if the synchronization object is not yet signaled (non-blocking pol...
Definition stk_common.h:189

References CmsisTimeoutToStk(), IsIrqContext(), stk::NO_WAIT, osErrorISR, osErrorParameter, osErrorResource, osErrorTimeout, and osOK.

Here is the call graph for this function:

◆ osMessageQueueGetCapacity()

uint32_t osMessageQueueGetCapacity ( osMessageQueueId_t mq_id)

Get maximum number of messages in a Message Queue.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
Returns
maximum number of messages.

Definition at line 1590 of file cmsis_os2_stk.cpp.

1591{
1592 if (mq_id == nullptr)
1593 return 0U;
1594
1595 return static_cast<uint32_t>(static_cast<StkMessageQueue *>(mq_id)->m_mq.GetCapacity());
1596}
size_t GetCapacity() const
Get the maximum number of messages the queue can hold.
stk::sync::MessageQueue m_mq

References stk::sync::MessageQueue::GetCapacity(), and StkMessageQueue::m_mq.

Here is the call graph for this function:

◆ osMessageQueueGetCount()

uint32_t osMessageQueueGetCount ( osMessageQueueId_t mq_id)

Get number of queued messages in a Message Queue.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
Returns
number of queued messages.

Definition at line 1606 of file cmsis_os2_stk.cpp.

1607{
1608 if (mq_id == nullptr)
1609 return 0U;
1610
1611 return static_cast<uint32_t>(static_cast<StkMessageQueue *>(mq_id)->m_mq.GetCount());
1612}
size_t GetCount() const
Get the current number of messages in the queue.

References stk::sync::MessageQueue::GetCount(), and StkMessageQueue::m_mq.

Here is the call graph for this function:

◆ osMessageQueueGetMsgSize()

uint32_t osMessageQueueGetMsgSize ( osMessageQueueId_t mq_id)

Get maximum message size in a Message Queue.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
Returns
maximum message size in bytes.

Definition at line 1598 of file cmsis_os2_stk.cpp.

1599{
1600 if (mq_id == nullptr)
1601 return 0U;
1602
1603 return static_cast<uint32_t>(static_cast<StkMessageQueue *>(mq_id)->m_mq.GetMsgSize());
1604}
size_t GetMsgSize() const
Get the size of each message in bytes.

References stk::sync::MessageQueue::GetMsgSize(), and StkMessageQueue::m_mq.

Here is the call graph for this function:

◆ osMessageQueueGetName()

const char * osMessageQueueGetName ( osMessageQueueId_t mq_id)

Get name of a Message Queue object.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
Returns
name as null-terminated string.

Definition at line 1547 of file cmsis_os2_stk.cpp.

1548{
1549 if (mq_id == nullptr)
1550 return nullptr;
1551
1552 return static_cast<StkMessageQueue *>(mq_id)->m_mq.GetTraceName();
1553}

◆ osMessageQueueGetSpace()

uint32_t osMessageQueueGetSpace ( osMessageQueueId_t mq_id)

Get number of available slots for messages in a Message Queue.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
Returns
number of available slots for messages.

Definition at line 1614 of file cmsis_os2_stk.cpp.

1615{
1616 if (mq_id == nullptr)
1617 return 0U;
1618
1619 return static_cast<uint32_t>(static_cast<StkMessageQueue *>(mq_id)->m_mq.GetSpace());
1620}
size_t GetSpace() const
Get the number of free slots currently available.

References stk::sync::MessageQueue::GetSpace(), and StkMessageQueue::m_mq.

Here is the call graph for this function:

◆ osMessageQueueNew()

osMessageQueueId_t osMessageQueueNew ( uint32_t msg_count,
uint32_t msg_size,
const osMessageQueueAttr_t * attr )

Create and Initialize a Message Queue object.

Parameters
[in]msg_countmaximum number of messages in queue.
[in]msg_sizemaximum message size in bytes.
[in]attrmessage queue attributes; NULL: default values.
Returns
message queue ID for reference by other functions or NULL in case of error.

Definition at line 1506 of file cmsis_os2_stk.cpp.

1508{
1509 if (IsIrqContext() || (msg_count == 0U) || (msg_size == 0U))
1510 return nullptr;
1511
1513 return nullptr;
1514
1515 const char *name = (attr != nullptr ? attr->name : nullptr);
1516 void *cb_mem = (attr != nullptr ? attr->cb_mem : nullptr);
1517 uint32_t cb_sz = (attr != nullptr ? attr->cb_size : 0U);
1518 void *ext_buf = (attr != nullptr ? attr->mq_mem : nullptr);
1519 uint32_t ext_buf_size = (attr != nullptr ? attr->mq_size : 0U);
1520
1521 const uint32_t buf_required = msg_count * msg_size;
1522
1523 StkMessageQueue *mq = nullptr;
1524
1525 if ((ext_buf != nullptr) && (ext_buf_size >= buf_required))
1526 {
1527 // Data buffer: use caller-supplied memory.
1528 mq = PlacementNewOrHeap<StkMessageQueue>(cb_mem, cb_sz,
1529 msg_count, msg_size, name, static_cast<uint8_t *>(ext_buf));
1530 }
1531 else
1532 {
1533 // Data buffer: heap-allocated inside StkMessageQueue constructor.
1534 mq = PlacementNewOrHeap<StkMessageQueue>(cb_mem, cb_sz,
1535 msg_count, msg_size, name);
1536
1537 if ((mq != nullptr) && (mq->m_mq.GetBuffer() == nullptr))
1538 {
1539 ObjDestroy(mq);
1540 return nullptr;
1541 }
1542 }
1543
1544 return static_cast<osMessageQueueId_t>(mq);
1545}
void * osMessageQueueId_t
Definition cmsis_os2.h:329
static const size_t CAPACITY_MAX
Max capacity supported (number of messages).
uint8_t * GetBuffer()
Get pointer to the message buffer.
const char * name
name of the message queue
Definition cmsis_os2.h:396
void * cb_mem
memory for control block
Definition cmsis_os2.h:398
uint32_t mq_size
size of provided memory for data storage
Definition cmsis_os2.h:401
uint32_t cb_size
size of provided memory for control block
Definition cmsis_os2.h:399
void * mq_mem
memory for data storage
Definition cmsis_os2.h:400

References stk::sync::MessageQueue::CAPACITY_MAX, osMessageQueueAttr_t::cb_mem, osMessageQueueAttr_t::cb_size, stk::sync::MessageQueue::GetBuffer(), IsIrqContext(), StkMessageQueue::m_mq, osMessageQueueAttr_t::mq_mem, osMessageQueueAttr_t::mq_size, osMessageQueueAttr_t::name, ObjDestroy(), and PlacementNewOrHeap().

Here is the call graph for this function:

◆ osMessageQueuePut()

osStatus_t osMessageQueuePut ( osMessageQueueId_t mq_id,
const void * msg_ptr,
uint8_t msg_prio,
uint32_t timeout )

Put a Message into a Queue or timeout if Queue is full.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
[in]msg_ptrpointer to buffer with message to put into a queue.
[in]msg_priomessage priority.
[in]timeoutCMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
Returns
status code that indicates the execution status of the function.

Definition at line 1555 of file cmsis_os2_stk.cpp.

1557{
1558 if (!mq_id || !msg_ptr)
1559 return osErrorParameter;
1560 if (IsIrqContext() && (timeout != 0U))
1561 return osErrorISR;
1562
1563 stk::Timeout stk_timeout = CmsisTimeoutToStk(timeout);
1564
1565 if (!static_cast<StkMessageQueue *>(mq_id)->m_mq.Put(msg_ptr, stk_timeout))
1566 return ((stk_timeout == stk::NO_WAIT) ? osErrorResource : osErrorTimeout);
1567
1568 return osOK;
1569}

References CmsisTimeoutToStk(), IsIrqContext(), stk::NO_WAIT, osErrorISR, osErrorParameter, osErrorResource, osErrorTimeout, and osOK.

Here is the call graph for this function:

◆ osMessageQueueReset()

osStatus_t osMessageQueueReset ( osMessageQueueId_t mq_id)

Reset a Message Queue to initial empty state.

Parameters
[in]mq_idmessage queue ID obtained by osMessageQueueNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1622 of file cmsis_os2_stk.cpp.

1623{
1624 if (IsIrqContext() || (mq_id == nullptr))
1626
1627 static_cast<StkMessageQueue *>(mq_id)->m_mq.Reset();
1628
1629 return osOK;
1630}

References IsIrqContext(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osMutexAcquire()

osStatus_t osMutexAcquire ( osMutexId_t mutex_id,
uint32_t timeout )

Acquire a Mutex or timeout if it is locked.

Parameters
[in]mutex_idmutex ID obtained by osMutexNew.
[in]timeoutCMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
Returns
status code that indicates the execution status of the function.

Definition at line 1251 of file cmsis_os2_stk.cpp.

1252{
1253 if (IsIrqContext())
1254 return osErrorISR;
1255 if (mutex_id == nullptr)
1256 return osErrorParameter;
1257
1258 StkMutex *m = static_cast<StkMutex *>(mutex_id);
1259 stk::Timeout stk_timeout = CmsisTimeoutToStk(timeout);
1260
1261 bool acquired = m->m_mutex.TimedLock(stk_timeout);
1262 if (!acquired)
1263 return ((stk_timeout == stk::NO_WAIT) ? osErrorResource : osErrorTimeout);
1264
1265 return osOK;
1266}
bool TimedLock(Timeout timeout_ticks)
Acquire lock.
stk::sync::Mutex m_mutex

References CmsisTimeoutToStk(), IsIrqContext(), StkMutex::m_mutex, stk::NO_WAIT, osErrorISR, osErrorParameter, osErrorResource, osErrorTimeout, osOK, and stk::sync::Mutex::TimedLock().

Here is the call graph for this function:

◆ osMutexDelete()

osStatus_t osMutexDelete ( osMutexId_t mutex_id)

Delete a Mutex object.

Parameters
[in]mutex_idmutex ID obtained by osMutexNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1291 of file cmsis_os2_stk.cpp.

1292{
1293 if (IsIrqContext() || (mutex_id == nullptr))
1295
1296 ObjDestroy(static_cast<StkMutex *>(mutex_id));
1297 return osOK;
1298}

References IsIrqContext(), ObjDestroy(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osMutexGetName()

const char * osMutexGetName ( osMutexId_t mutex_id)

Get name of a Mutex object.

Parameters
[in]mutex_idmutex ID obtained by osMutexNew.
Returns
name as null-terminated string.

Definition at line 1243 of file cmsis_os2_stk.cpp.

1244{
1245 if (mutex_id == nullptr)
1246 return nullptr;
1247
1248 return static_cast<StkMutex *>(mutex_id)->m_mutex.GetTraceName();
1249}

◆ osMutexGetOwner()

osThreadId_t osMutexGetOwner ( osMutexId_t mutex_id)

Get Thread which owns a Mutex object.

Parameters
[in]mutex_idmutex ID obtained by osMutexNew.
Returns
thread ID of owner thread or NULL when mutex was not acquired.

Definition at line 1279 of file cmsis_os2_stk.cpp.

1280{
1281 if (mutex_id == nullptr)
1282 return nullptr;
1283
1284 stk::TId tid = static_cast<StkMutex *>(mutex_id)->m_mutex.GetOwner();
1285
1286 // tid is hw::PtrToWord(this) where 'this' is the StkThread* - cast it back.
1287 return reinterpret_cast<osThreadId_t>(static_cast<void *>(
1288 reinterpret_cast<StkThread *>(static_cast<uintptr_t>(tid))));
1289}
void * osThreadId_t
Definition cmsis_os2.h:311
Word TId
Definition stk_common.h:120

◆ osMutexNew()

osMutexId_t osMutexNew ( const osMutexAttr_t * attr)

Create and Initialize a Mutex object.

Parameters
[in]attrmutex attributes; NULL: default values.
Returns
mutex ID for reference by other functions or NULL in case of error.

Definition at line 1221 of file cmsis_os2_stk.cpp.

1222{
1223 if (IsIrqContext())
1224 return nullptr;
1225
1226 // osMutexPrioInherit: ignored, supported by default.
1227 // osMutexRecursive: ignored, sync::Mutex is always recursive.
1228 // osMutexRobust: will assert as unsafe code.
1229 const char *name = (attr != nullptr ? attr->name : nullptr);
1230 void *cb_mem = (attr != nullptr ? attr->cb_mem : nullptr);
1231 uint32_t cb_sz = (attr != nullptr ? attr->cb_size : 0U);
1232 bool robust = (attr != nullptr) && (attr->attr_bits & osMutexRobust);
1233
1234 // disallow osMutexRobust
1235 STK_ASSERT(!robust);
1236 if (robust)
1237 return nullptr;
1238
1239 StkMutex *m = PlacementNewOrHeap<StkMutex>(cb_mem, cb_sz, name);
1240 return static_cast<osMutexId_t>(m);
1241}
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:411
void * osMutexId_t
Definition cmsis_os2.h:320
#define osMutexRobust
Robust mutex.
Definition cmsis_os2.h:280
uint32_t cb_size
size of provided memory for control block
Definition cmsis_os2.h:373
uint32_t attr_bits
attribute bits
Definition cmsis_os2.h:371
const char * name
name of the mutex
Definition cmsis_os2.h:370
void * cb_mem
memory for control block
Definition cmsis_os2.h:372

References osMutexAttr_t::attr_bits, osMutexAttr_t::cb_mem, osMutexAttr_t::cb_size, IsIrqContext(), osMutexAttr_t::name, osMutexRobust, PlacementNewOrHeap(), and STK_ASSERT.

Here is the call graph for this function:

◆ osMutexRelease()

osStatus_t osMutexRelease ( osMutexId_t mutex_id)

Release a Mutex that was acquired by osMutexAcquire.

Parameters
[in]mutex_idmutex ID obtained by osMutexNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1268 of file cmsis_os2_stk.cpp.

1269{
1270 if (IsIrqContext())
1271 return osErrorISR;
1272 if (mutex_id == nullptr)
1273 return osErrorParameter;
1274
1275 static_cast<StkMutex *>(mutex_id)->m_mutex.Unlock();
1276 return osOK;
1277}

References IsIrqContext(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osSemaphoreAcquire()

osStatus_t osSemaphoreAcquire ( osSemaphoreId_t semaphore_id,
uint32_t timeout )

Acquire a Semaphore token or timeout if no tokens are available.

Parameters
[in]semaphore_idsemaphore ID obtained by osSemaphoreNew.
[in]timeoutCMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
Returns
status code that indicates the execution status of the function.

Definition at line 1334 of file cmsis_os2_stk.cpp.

1335{
1336 if (semaphore_id == nullptr)
1337 return osErrorParameter;
1338 if (IsIrqContext() && (timeout != 0U))
1339 return osErrorISR;
1340
1341 StkSemaphore *s = static_cast<StkSemaphore *>(semaphore_id);
1342 stk::Timeout stk_timeout = CmsisTimeoutToStk(timeout);
1343
1344 bool acquired = s->m_semaphore.Wait(stk_timeout);
1345 if (!acquired)
1346 return (stk_timeout == stk::NO_WAIT) ? osErrorResource : osErrorTimeout;
1347
1348 return osOK;
1349}
bool Wait(Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal (decrement counter).
stk::sync::Semaphore m_semaphore

References CmsisTimeoutToStk(), IsIrqContext(), StkSemaphore::m_semaphore, stk::NO_WAIT, osErrorISR, osErrorParameter, osErrorResource, osErrorTimeout, osOK, and stk::sync::Semaphore::Wait().

Here is the call graph for this function:

◆ osSemaphoreDelete()

osStatus_t osSemaphoreDelete ( osSemaphoreId_t semaphore_id)

Delete a Semaphore object.

Parameters
[in]semaphore_idsemaphore ID obtained by osSemaphoreNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1368 of file cmsis_os2_stk.cpp.

1369{
1370 if (IsIrqContext() || (semaphore_id == nullptr))
1372
1373 ObjDestroy(static_cast<StkSemaphore *>(semaphore_id));
1374 return osOK;
1375}

References IsIrqContext(), ObjDestroy(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osSemaphoreGetCount()

uint32_t osSemaphoreGetCount ( osSemaphoreId_t semaphore_id)

Get current Semaphore token count.

Parameters
[in]semaphore_idsemaphore ID obtained by osSemaphoreNew.
Returns
number of tokens available.

Definition at line 1360 of file cmsis_os2_stk.cpp.

1361{
1362 if (semaphore_id == nullptr)
1363 return 0U;
1364
1365 return static_cast<uint32_t>(static_cast<StkSemaphore *>(semaphore_id)->m_semaphore.GetCount());
1366}
uint16_t GetCount() const
Get current counter value.

References stk::sync::Semaphore::GetCount(), and StkSemaphore::m_semaphore.

Here is the call graph for this function:

◆ osSemaphoreGetName()

const char * osSemaphoreGetName ( osSemaphoreId_t semaphore_id)

Get name of a Semaphore object.

Parameters
[in]semaphore_idsemaphore ID obtained by osSemaphoreNew.
Returns
name as null-terminated string.

Definition at line 1326 of file cmsis_os2_stk.cpp.

1327{
1328 if (semaphore_id == nullptr)
1329 return nullptr;
1330
1331 return static_cast<StkSemaphore *>(semaphore_id)->m_semaphore.GetTraceName();
1332}

◆ osSemaphoreNew()

osSemaphoreId_t osSemaphoreNew ( uint32_t max_count,
uint32_t initial_count,
const osSemaphoreAttr_t * attr )

Create and Initialize a Semaphore object.

Parameters
[in]max_countmaximum number of available tokens.
[in]initial_countinitial number of available tokens.
[in]attrsemaphore attributes; NULL: default values.
Returns
semaphore ID for reference by other functions or NULL in case of error.

Definition at line 1305 of file cmsis_os2_stk.cpp.

1307{
1308 if (IsIrqContext())
1309 return nullptr;
1310
1311 if ((max_count == 0U) || (initial_count > max_count))
1312 return nullptr;
1313
1314 // STK Semaphore uses uint16_t counters, clamp to stk::sync::Semaphore::COUNT_MAX.
1315 uint16_t mc = stk::Min(max_count, static_cast<uint32_t>(stk::sync::Semaphore::COUNT_MAX));
1316 uint16_t ic = stk::Min(initial_count, static_cast<uint32_t>(stk::sync::Semaphore::COUNT_MAX));
1317
1318 const char *name = (attr != nullptr ? attr->name : nullptr);
1319 void *cb_mem = (attr != nullptr ? attr->cb_mem : nullptr);
1320 uint32_t cb_sz = (attr != nullptr ? attr->cb_size : 0U);
1321
1322 StkSemaphore *s = PlacementNewOrHeap<StkSemaphore>(cb_mem, cb_sz, ic, mc, name);
1323 return static_cast<osSemaphoreId_t>(s);
1324}
void * osSemaphoreId_t
Definition cmsis_os2.h:323
static constexpr T Min(T a, T b)
Compile-time minimum of two values.
Definition stk_defs.h:633
static const uint16_t COUNT_MAX
Max count value supported.
const char * name
name of the semaphore
Definition cmsis_os2.h:378
uint32_t cb_size
size of provided memory for control block
Definition cmsis_os2.h:381
void * cb_mem
memory for control block
Definition cmsis_os2.h:380

References osSemaphoreAttr_t::cb_mem, osSemaphoreAttr_t::cb_size, stk::sync::Semaphore::COUNT_MAX, IsIrqContext(), stk::Min(), osSemaphoreAttr_t::name, and PlacementNewOrHeap().

Here is the call graph for this function:

◆ osSemaphoreRelease()

osStatus_t osSemaphoreRelease ( osSemaphoreId_t semaphore_id)

Release a Semaphore token up to the initial maximum count.

Parameters
[in]semaphore_idsemaphore ID obtained by osSemaphoreNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1351 of file cmsis_os2_stk.cpp.

1352{
1353 if (semaphore_id == nullptr)
1354 return osErrorParameter;
1355
1356 static_cast<StkSemaphore *>(semaphore_id)->m_semaphore.Signal();
1357 return osOK;
1358}

References osErrorParameter, and osOK.

◆ osThreadDetach()

osStatus_t osThreadDetach ( osThreadId_t thread_id)

Detach a thread (thread storage can be reclaimed when thread terminates).

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
status code that indicates the execution status of the function.

Definition at line 836 of file cmsis_os2_stk.cpp.

837{
838 if (IsIrqContext() || (thread_id == nullptr))
840
841 StkThread *t = static_cast<StkThread *>(thread_id);
842
844
845 switch (t->m_join_state)
846 {
848 // already detached - CMSIS spec says this is an error
849 return osError;
850
852 // already joined - cannot detach
853 return osError;
854
856 // thread finished but nobody joined yet, transition to Detached
857 // and free the control block now, since no joiner will ever do it
859 ObjDestroy(t); // safe: task slot already freed by the kernel
860 return osOK;
861
863 // normal case: thread is still running or just hasn't been joined
865 return osOK;
866 }
867
868 return osError;
869}
RAII-style low-level synchronization primitive for atomic code execution. Used as building brick for ...
Definition stk_sync_cs.h:54
volatile JoinState m_join_state

References StkThread::Detached, StkThread::Exited, IsIrqContext(), StkThread::Joinable, StkThread::Joined, StkThread::m_join_state, ObjDestroy(), osError, osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osThreadEnumerate()

uint32_t osThreadEnumerate ( osThreadId_t * thread_array,
uint32_t array_items )

Enumerate active threads.

Parameters
[out]thread_arraypointer to array for retrieving thread IDs.
[in]array_itemsmaximum number of items in array for retrieving thread IDs.
Returns
number of enumerated threads.

Definition at line 960 of file cmsis_os2_stk.cpp.

961{
962 uint32_t result_count = 0U;
963 const osKernelState_t kstate = osKernelGetState();
964
965 // kernel must be active and buffer must be valid
966 if ((kstate != osKernelInactive) && (thread_array != nullptr) && (array_items != 0U))
967 {
968 // cast the raw pointer array to the expected ITask* destination type
969 stk::ITask **tasks_destination = reinterpret_cast<stk::ITask **>(thread_array);
970
971 // bind raw destination buffer into a temporary ArrayView object
972 const size_t count = g_StkKernel.EnumerateTasks(
973 stk::ArrayView<stk::ITask *>(tasks_destination, static_cast<size_t>(array_items)));
974
975 result_count = static_cast<uint32_t>(count);
976 }
977
978 return result_count;
979}
Lightweight, non-owning view over a contiguous sequence of elements.
Definition stk_common.h:226
Interface for a user task.
Definition stk_common.h:589

References g_StkKernel, osKernelGetState(), and osKernelInactive.

Here is the call graph for this function:

◆ osThreadExit()

void osThreadExit ( void )

Terminate execution of current running thread.

Definition at line 913 of file cmsis_os2_stk.cpp.

914{
915 StkThread *t = static_cast<StkThread *>(osThreadGetId());
916
917 g_StkKernel.ScheduleTaskRemoval(t);
918
919 // Wait for removal.
920 for (;;)
921 stk::Yield();
922}
osThreadId_t osThreadGetId(void)
void Yield()
Notify scheduler to switch to the next runnable task.
Definition stk_helper.h:386

References __NO_RETURN, g_StkKernel, osThreadGetId(), and stk::Yield().

Here is the call graph for this function:

◆ osThreadFeedWatchdog()

osStatus_t osThreadFeedWatchdog ( uint32_t ticks)

Feed watchdog of the current running thread.

Parameters
[in]ticksinterval in kernel ticks until the thread watchdog expires, or 0 to stop the watchdog
Returns
status code that indicates the execution status of the function.

◆ osThreadFlagsClear()

uint32_t osThreadFlagsClear ( uint32_t flags)

Clear the specified Thread Flags of current running thread.

Parameters
[in]flagsspecifies the flags of the thread that shall be cleared.
Returns
thread flags before clearing or error code if highest bit set.

Definition at line 996 of file cmsis_os2_stk.cpp.

997{
999 if (self == nullptr)
1000 return osFlagsErrorUnknown;
1001
1002 StkThread *t = static_cast<StkThread *>(self);
1003
1004 uint32_t result = t->m_thread_flags.Clear(flags);
1005 return StkFlagsResultToCmsis(result);
1006}
#define osFlagsErrorUnknown
osError (-1).
Definition cmsis_os2.h:255
uint32_t Clear(uint32_t flags)
Clear one or more flags.
stk::sync::EventFlags m_thread_flags

References stk::sync::EventFlags::Clear(), StkThread::m_thread_flags, osFlagsErrorUnknown, osThreadGetId(), and StkFlagsResultToCmsis().

Here is the call graph for this function:

◆ osThreadFlagsGet()

uint32_t osThreadFlagsGet ( void )

Get the current Thread Flags of current running thread.

Returns
current thread flags.

Definition at line 1008 of file cmsis_os2_stk.cpp.

1009{
1010 osThreadId_t self = osThreadGetId();
1011 if (self == nullptr)
1012 return 0U;
1013
1014 return static_cast<StkThread *>(self)->m_thread_flags.Get();
1015}

References osThreadGetId().

Here is the call graph for this function:

◆ osThreadFlagsSet()

uint32_t osThreadFlagsSet ( osThreadId_t thread_id,
uint32_t flags )

Set the specified Thread Flags of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
[in]flagsspecifies the flags of the thread that shall be set.
Returns
thread flags after setting or error code if highest bit set.

Definition at line 985 of file cmsis_os2_stk.cpp.

986{
987 if ((thread_id == nullptr) || ((flags & osFlagsError) != 0))
989
990 StkThread *t = static_cast<StkThread *>(thread_id);
991
992 uint32_t result = t->m_thread_flags.Set(flags);
993 return StkFlagsResultToCmsis(result);
994}
uint32_t Set(uint32_t flags)
Set one or more flags.

References StkThread::m_thread_flags, osFlagsError, osFlagsErrorParameter, stk::sync::EventFlags::Set(), and StkFlagsResultToCmsis().

Here is the call graph for this function:

◆ osThreadFlagsWait()

uint32_t osThreadFlagsWait ( uint32_t flags,
uint32_t options,
uint32_t timeout )

Wait for one or more Thread Flags of the current running thread to become signaled.

Parameters
[in]flagsspecifies the flags to wait for.
[in]optionsspecifies flags options (osFlagsXxxx).
[in]timeoutCMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
Returns
thread flags before clearing or error code if highest bit set.

Definition at line 1017 of file cmsis_os2_stk.cpp.

1018{
1019 if (IsIrqContext())
1020 return osFlagsErrorISR;
1021
1022 osThreadId_t self = osThreadGetId();
1023 if (self == nullptr)
1024 return osFlagsErrorUnknown;
1025
1026 StkThread *t = static_cast<StkThread *>(self);
1027
1028 uint32_t result = t->m_thread_flags.Wait(flags, CmsisFlagsOptionsToStk(options),
1029 CmsisTimeoutToStk(timeout));
1030
1031 return StkFlagsResultToCmsis(result);
1032}
#define osFlagsErrorISR
osErrorISR (-6).
Definition cmsis_os2.h:259
uint32_t Wait(uint32_t flags, uint32_t options=OPT_WAIT_ANY, Timeout timeout_ticks=WAIT_INFINITE)
Wait for one or more flags to be set.

References CmsisFlagsOptionsToStk(), CmsisTimeoutToStk(), IsIrqContext(), StkThread::m_thread_flags, osFlagsErrorISR, osFlagsErrorUnknown, osThreadGetId(), StkFlagsResultToCmsis(), and stk::sync::EventFlags::Wait().

Here is the call graph for this function:

◆ osThreadGetAffinityMask()

uint32_t osThreadGetAffinityMask ( osThreadId_t thread_id)

Get current processor affinity mask of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
current processor affinity mask of the specified thread.

◆ osThreadGetClass()

uint32_t osThreadGetClass ( osThreadId_t thread_id)

Get safety class of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
safety class of the specified thread.

◆ osThreadGetCount()

uint32_t osThreadGetCount ( void )

Get number of active threads.

Returns
number of active threads.

Definition at line 949 of file cmsis_os2_stk.cpp.

950{
952 return 0U;
953
954 // avoid race with OnTick
956
957 return static_cast<uint32_t>(g_StkKernel.GetSwitchStrategy()->GetSize());
958}

References g_StkKernel, osKernelGetState(), and osKernelInactive.

Here is the call graph for this function:

◆ osThreadGetId()

osThreadId_t osThreadGetId ( void )

Return the thread ID of the current running thread.

Returns
thread ID for reference by other functions or NULL in case of error.

Definition at line 725 of file cmsis_os2_stk.cpp.

726{
728 return nullptr;
729
730 // STK's GetTid() returns the ITask pointer cast to Word.
731 stk::TId tid = stk::GetTid();
732
733 // tid is hw::PtrToWord(this) where 'this' is the StkThread* - cast it back.
734 return reinterpret_cast<osThreadId_t>(static_cast<void *>(
735 reinterpret_cast<StkThread *>(static_cast<uintptr_t>(tid))));
736}
TId GetTid()
Get task/thread Id of the calling task.
Definition stk_helper.h:243

References stk::GetTid(), IsIrqContext(), osKernelGetState(), and osKernelInactive.

Referenced by osThreadExit(), osThreadFlagsClear(), osThreadFlagsGet(), osThreadFlagsWait(), osThreadGetState(), and osThreadJoin().

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

◆ osThreadGetName()

const char * osThreadGetName ( osThreadId_t thread_id)

Get name of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
name as null-terminated string.

Definition at line 717 of file cmsis_os2_stk.cpp.

718{
719 if (thread_id == nullptr)
720 return nullptr;
721
722 return static_cast<StkThread *>(thread_id)->m_name;
723}

◆ osThreadGetPriority()

osPriority_t osThreadGetPriority ( osThreadId_t thread_id)

Get current priority of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
current priority value of the specified thread.

Definition at line 786 of file cmsis_os2_stk.cpp.

787{
788 if (IsIrqContext() || (thread_id == nullptr))
789 return osPriorityError;
790
791 StkThread *t = static_cast<StkThread *>(thread_id);
793}
static __stk_forceinline osPriority_t StkPrioToCmsis(int32_t p)
volatile int32_t m_stk_priority

References IsIrqContext(), StkThread::m_stk_priority, osPriorityError, and StkPrioToCmsis().

Here is the call graph for this function:

◆ osThreadGetStackSize()

uint32_t osThreadGetStackSize ( osThreadId_t thread_id)

Get stack size of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
stack size in bytes.

Definition at line 754 of file cmsis_os2_stk.cpp.

755{
756 if (thread_id == nullptr)
757 return 0U;
758
759 StkThread *t = static_cast<StkThread *>(thread_id);
760 return static_cast<uint32_t>(t->GetStackSizeBytes());
761}
size_t GetStackSizeBytes() const override
Get size of the memory in bytes.

References StkThread::GetStackSizeBytes().

Here is the call graph for this function:

◆ osThreadGetStackSpace()

uint32_t osThreadGetStackSpace ( osThreadId_t thread_id)

Get available stack space of a thread based on stack watermark recording during execution.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
remaining stack space in bytes.

Definition at line 763 of file cmsis_os2_stk.cpp.

764{
765 if (thread_id == nullptr)
766 return 0U;
767
768 StkThread *t = static_cast<StkThread *>(thread_id);
769 return static_cast<uint32_t>(t->GetStackSpace() * sizeof(stk::Word));
770}
uintptr_t Word
Native processor word type.
Definition stk_common.h:115
virtual size_t GetStackSpace() const
Get available stack space.
Definition stk_common.h:318

References stk::IStackMemory::GetStackSpace().

Here is the call graph for this function:

◆ osThreadGetState()

osThreadState_t osThreadGetState ( osThreadId_t thread_id)

Get current thread state of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
current thread state of the specified thread.

Definition at line 738 of file cmsis_os2_stk.cpp.

739{
740 if (IsIrqContext() || (thread_id == nullptr))
741 return osThreadError;
742
743 StkThread *t = static_cast<StkThread *>(thread_id);
744
745 if (t->m_suspended)
746 return osThreadBlocked;
747
748 if (thread_id == osThreadGetId())
749 return osThreadRunning;
750
751 return osThreadReady;
752}

References IsIrqContext(), StkThread::m_suspended, osThreadBlocked, osThreadError, osThreadGetId(), osThreadReady, and osThreadRunning.

Here is the call graph for this function:

◆ osThreadGetZone()

uint32_t osThreadGetZone ( osThreadId_t thread_id)

Get MPU protected zone of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
MPU protected zone of the specified thread.

References __NO_RETURN.

◆ osThreadJoin()

osStatus_t osThreadJoin ( osThreadId_t thread_id)

Wait for specified thread to terminate.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
status code that indicates the execution status of the function.

Definition at line 871 of file cmsis_os2_stk.cpp.

872{
873 if (IsIrqContext() || (thread_id == nullptr))
875
876 // Self-join is undefined behavior per POSIX / CMSIS spec.
877 if (thread_id == osThreadGetId())
878 return osErrorParameter;
879
880 StkThread *t = static_cast<StkThread *>(thread_id);
881
883
884 // Only joinable threads can be joined.
886 return osError;
887
888 // Double-join: second caller always gets an error.
890 return osError;
891
893
894 // Block until OnExit() fires (transitions state to Exited).
895 // m_join_cv.Wait() atomically releases m_join_mutex and suspends.
897 {
898 // WAIT_INFINITE - CMSIS osThreadJoin has no timeout parameter.
900 }
901
902 // At this point m_join_state == Exited (or Detached if someone
903 // raced osThreadDetach - treat that as an error).
905 return osError;
906
907 // Free the control block - the kernel has already freed the slot.
908 ObjDestroy(t);
909
910 return osOK;
911}
static constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
Definition stk_common.h:183
bool Wait(IMutex &mutex, Timeout timeout_ticks=WAIT_INFINITE)
Wait for a signal.
stk::sync::ConditionVariable m_join_cv

References StkThread::Detached, StkThread::Exited, IsIrqContext(), StkThread::Joined, StkThread::m_join_cv, StkThread::m_join_state, ObjDestroy(), osError, osErrorISR, osErrorParameter, osOK, osThreadGetId(), stk::sync::ConditionVariable::Wait(), and stk::WAIT_INFINITE.

Here is the call graph for this function:

◆ osThreadNew()

osThreadId_t osThreadNew ( osThreadFunc_t func,
void * argument,
const osThreadAttr_t * attr )

Create a thread and add it to Active Threads.

Parameters
[in]functhread function.
[in]argumentpointer that is passed to the thread function as start argument.
[in]attrthread attributes; NULL: default values.
Returns
thread ID for reference by other functions or NULL in case of error.

Definition at line 643 of file cmsis_os2_stk.cpp.

644{
645 if (IsIrqContext() || (func == nullptr) || (osKernelGetState() == osKernelInactive))
646 return nullptr;
647
648 bool joinable = (attr != nullptr) && (attr->attr_bits & osThreadJoinable);
649 void *cb_mem = (attr != nullptr ? attr->cb_mem : nullptr);
650 uint32_t cb_size = (attr != nullptr ? attr->cb_size : 0U);
651
652 StkThread *t = PlacementNewOrHeap<StkThread>(cb_mem, cb_size);
653 if (t == nullptr)
654 return nullptr;
655
656 t->m_func = func;
657 t->m_argument = argument;
658 t->m_name = nullptr;
660
661 osPriority_t cmsis_prio = osPriorityNormal;
662 size_t stack_words = CMSIS_STK_DEFAULT_STACK_WORDS;
663
664 if (attr != nullptr)
665 {
666 t->m_name = attr->name;
667
668 if (attr->priority != osPriorityNone)
669 cmsis_prio = attr->priority;
670
671 if ((cmsis_prio < osPriorityIdle) || (cmsis_prio > osPriorityISR))
672 {
673 ObjDestroy(t);
674 return nullptr;
675 }
676
677 // Stack: prefer caller-provided memory.
678 if ((attr->stack_mem != nullptr) && (attr->stack_size > 0U))
679 {
680 size_t words = attr->stack_size / sizeof(stk::Word);
681 if (words < CMSIS_STK_MIN_STACK_WORDS)
683
684 t->m_stack = static_cast<stk::Word *>(attr->stack_mem);
685 t->m_stack_size = words;
686 t->m_stack_owned = false;
687 }
688 else
689 if (attr->stack_size > 0U)
690 {
691 stack_words = attr->stack_size / sizeof(stk::Word);
692 if (stack_words < CMSIS_STK_MIN_STACK_WORDS)
693 stack_words = CMSIS_STK_MIN_STACK_WORDS;
694 }
695 }
696
697 // Allocate stack if not caller-provided.
698 if (t->m_stack == nullptr)
699 {
700 t->m_stack = new (std::nothrow) stk::Word[stack_words];
701 if (t->m_stack == nullptr)
702 {
703 ObjDestroy(t);
704 return nullptr;
705 }
706 t->m_stack_size = stack_words;
707 t->m_stack_owned = true;
708 }
709
710 t->m_stk_priority = CmsisPrioToStk(cmsis_prio);
711
712 g_StkKernel.AddTask(t);
713
714 return static_cast<osThreadId_t>(t);
715}
#define CMSIS_STK_MIN_STACK_WORDS
#define CMSIS_STK_DEFAULT_STACK_WORDS
static __stk_forceinline int32_t CmsisPrioToStk(osPriority_t p)
#define osThreadJoinable
Thread created in joinable mode.
Definition cmsis_os2.h:264
void * cb_mem
memory for control block
Definition cmsis_os2.h:343
uint32_t attr_bits
attribute bits
Definition cmsis_os2.h:342
uint32_t cb_size
size of provided memory for control block
Definition cmsis_os2.h:344
void * stack_mem
memory for stack
Definition cmsis_os2.h:345
osPriority_t priority
initial thread priority (default: osPriorityNormal)
Definition cmsis_os2.h:347
uint32_t stack_size
size of stack
Definition cmsis_os2.h:346
const char * name
name of the thread
Definition cmsis_os2.h:341
stk::Word * m_stack
size_t m_stack_size
osThreadFunc_t m_func
const char * m_name
void * m_argument

References osThreadAttr_t::attr_bits, osThreadAttr_t::cb_mem, osThreadAttr_t::cb_size, CMSIS_STK_DEFAULT_STACK_WORDS, CMSIS_STK_MIN_STACK_WORDS, CmsisPrioToStk(), StkThread::Detached, g_StkKernel, IsIrqContext(), StkThread::Joinable, StkThread::m_argument, StkThread::m_func, StkThread::m_join_state, StkThread::m_name, StkThread::m_stack, StkThread::m_stack_owned, StkThread::m_stack_size, StkThread::m_stk_priority, osThreadAttr_t::name, ObjDestroy(), osKernelGetState(), osKernelInactive, osPriorityIdle, osPriorityISR, osPriorityNone, osPriorityNormal, osThreadJoinable, PlacementNewOrHeap(), osThreadAttr_t::priority, osThreadAttr_t::stack_mem, and osThreadAttr_t::stack_size.

Here is the call graph for this function:

◆ osThreadProtectPrivileged()

osStatus_t osThreadProtectPrivileged ( void )

Protect creation of privileged threads.

Returns
status code that indicates the execution status of the function.

◆ osThreadResume()

osStatus_t osThreadResume ( osThreadId_t thread_id)

Resume execution of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
status code that indicates the execution status of the function.

Definition at line 818 of file cmsis_os2_stk.cpp.

819{
820 if (IsIrqContext() || (thread_id == nullptr) || (osKernelGetState() == osKernelInactive))
822
823 StkThread *t = static_cast<StkThread *>(thread_id);
824
826
827 if (!t->m_suspended)
828 return osOK; // not suspended, nothing to do
829
830 g_StkKernel.ResumeTask(t);
831 t->m_suspended = false;
832
833 return osOK;
834}

References g_StkKernel, IsIrqContext(), StkThread::m_suspended, osErrorISR, osErrorParameter, osKernelGetState(), osKernelInactive, and osOK.

Here is the call graph for this function:

◆ osThreadResumeClass()

osStatus_t osThreadResumeClass ( uint32_t safety_class,
uint32_t mode )

Resume execution of threads for specified safety classes.

Parameters
[in]safety_classsafety class.
[in]modesafety mode.
Returns
status code that indicates the execution status of the function.

◆ osThreadSetAffinityMask()

osStatus_t osThreadSetAffinityMask ( osThreadId_t thread_id,
uint32_t affinity_mask )

Set processor affinity mask of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
[in]affinity_maskprocessor affinity mask for the thread.
Returns
status code that indicates the execution status of the function.

◆ osThreadSetPriority()

osStatus_t osThreadSetPriority ( osThreadId_t thread_id,
osPriority_t priority )

Change priority of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
[in]prioritynew priority value for the thread function.
Returns
status code that indicates the execution status of the function.

Definition at line 772 of file cmsis_os2_stk.cpp.

773{
774 if (IsIrqContext() || (thread_id == nullptr))
776
777 if ((priority < osPriorityIdle) || (priority > osPriorityISR))
778 return osErrorParameter;
779
780 StkThread *t = static_cast<StkThread *>(thread_id);
781 t->m_stk_priority = CmsisPrioToStk(priority);
782
783 return osOK;
784}

References CmsisPrioToStk(), IsIrqContext(), StkThread::m_stk_priority, osErrorISR, osErrorParameter, osOK, osPriorityIdle, and osPriorityISR.

Here is the call graph for this function:

◆ osThreadSuspend()

osStatus_t osThreadSuspend ( osThreadId_t thread_id)

Suspend execution of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
status code that indicates the execution status of the function.

Definition at line 806 of file cmsis_os2_stk.cpp.

807{
808 if (IsIrqContext() || (thread_id == nullptr) || (osKernelGetState() == osKernelInactive))
810
811 StkThread *t = static_cast<StkThread *>(thread_id);
812
813 g_StkKernel.SuspendTask(t, t->m_suspended);
814
815 return osOK;
816}

References g_StkKernel, IsIrqContext(), StkThread::m_suspended, osErrorISR, osErrorParameter, osKernelGetState(), osKernelInactive, and osOK.

Here is the call graph for this function:

◆ osThreadSuspendClass()

osStatus_t osThreadSuspendClass ( uint32_t safety_class,
uint32_t mode )

Suspend execution of threads for specified safety classes.

Parameters
[in]safety_classsafety class.
[in]modesafety mode.
Returns
status code that indicates the execution status of the function.

◆ osThreadTerminate()

osStatus_t osThreadTerminate ( osThreadId_t thread_id)

Terminate execution of a thread.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
status code that indicates the execution status of the function.

Definition at line 924 of file cmsis_os2_stk.cpp.

925{
926 if ((thread_id == nullptr) || (osKernelGetState() == osKernelInactive))
927 return osErrorParameter;
928
929 StkThread *t = static_cast<StkThread *>(thread_id);
930
932
933 // RemoveTask triggers the STATE_REMOVE_PENDING path in the kernel,
934 // which will call OnExit() before freeing the slot.
935 g_StkKernel.ScheduleTaskRemoval(t);
936
937 // For detached threads, free immediately (no joiner expected).
938 // For joinable threads, OnExit() will wake the joiner; the joiner
939 // calls ObjDestroy(). Do NOT free here.
940 {
942 ObjDestroy(t);
943 // else: joiner owns the lifetime
944 }
945
946 return osOK;
947}

References StkThread::Detached, g_StkKernel, StkThread::m_join_state, ObjDestroy(), osErrorParameter, osKernelGetState(), osKernelInactive, and osOK.

Here is the call graph for this function:

◆ osThreadTerminateZone()

osStatus_t osThreadTerminateZone ( uint32_t zone)

Terminate execution of threads assigned to a specified MPU protected zone.

Parameters
[in]zoneMPU protected zone.
Returns
status code that indicates the execution status of the function.

◆ osThreadYield()

osStatus_t osThreadYield ( void )

Pass control to next thread that is in state READY.

Returns
status code that indicates the execution status of the function.

Definition at line 795 of file cmsis_os2_stk.cpp.

796{
797 if (IsIrqContext())
798 return osErrorISR;
800 return osError;
801
802 stk::Yield();
803 return osOK;
804}

References IsIrqContext(), osError, osErrorISR, osKernelGetState(), osKernelInactive, osOK, and stk::Yield().

Here is the call graph for this function:

◆ osTimerDelete()

osStatus_t osTimerDelete ( osTimerId_t timer_id)

Delete a timer.

Parameters
[in]timer_idtimer ID obtained by osTimerNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1129 of file cmsis_os2_stk.cpp.

1130{
1131 if (IsIrqContext() || (timer_id == nullptr))
1133
1134 StkTimer *timer = static_cast<StkTimer *>(timer_id);
1135
1136 if ((g_TimerHost != nullptr) && timer->IsActive())
1137 g_TimerHost->Stop(*timer);
1138
1139 ObjDestroy(timer);
1140 return osOK;
1141}
static stk::time::TimerHost * g_TimerHost
bool IsActive() const
Check whether the timer is currently active.

References g_TimerHost, stk::time::TimerHost::Timer::IsActive(), IsIrqContext(), ObjDestroy(), osErrorISR, osErrorParameter, and osOK.

Here is the call graph for this function:

◆ osTimerGetName()

const char * osTimerGetName ( osTimerId_t timer_id)

Get name of a timer.

Parameters
[in]timer_idtimer ID obtained by osTimerNew.
Returns
name as null-terminated string.

Definition at line 1085 of file cmsis_os2_stk.cpp.

1086{
1087 if (timer_id == nullptr)
1088 return nullptr;
1089
1090 return static_cast<StkTimer *>(timer_id)->m_name;
1091}

◆ osTimerIsRunning()

uint32_t osTimerIsRunning ( osTimerId_t timer_id)

Check if a timer is running.

Parameters
[in]timer_idtimer ID obtained by osTimerNew.
Returns
0 not running, 1 running.

Definition at line 1121 of file cmsis_os2_stk.cpp.

1122{
1123 if (timer_id == nullptr)
1124 return 0U;
1125
1126 return (static_cast<StkTimer *>(timer_id)->IsActive() ? 1U : 0U);
1127}

◆ osTimerNew()

osTimerId_t osTimerNew ( osTimerFunc_t func,
osTimerType_t type,
void * argument,
const osTimerAttr_t * attr )

Create and Initialize a timer.

Parameters
[in]funcfunction pointer to callback function.
[in]typeosTimerOnce for one-shot or osTimerPeriodic for periodic behavior.
[in]argumentargument to the timer callback function.
[in]attrtimer attributes; NULL: default values.
Returns
timer ID for reference by other functions or NULL in case of error.

Definition at line 1068 of file cmsis_os2_stk.cpp.

1070{
1071 if (IsIrqContext() || (func == nullptr) || (osKernelGetState() == osKernelInactive))
1072 return nullptr;
1073
1075 return nullptr;
1076
1077 const char *name = (attr != nullptr ? attr->name : nullptr);
1078 void *cb_mem = (attr != nullptr ? attr->cb_mem : nullptr);
1079 uint32_t cb_sz = (attr != nullptr ? attr->cb_size : 0U);
1080
1081 StkTimer *timer = PlacementNewOrHeap<StkTimer>(cb_mem, cb_sz, func, type, argument, name);
1082 return static_cast<osTimerId_t>(timer);
1083}
void * osTimerId_t
Definition cmsis_os2.h:314
void * cb_mem
memory for control block
Definition cmsis_os2.h:356
const char * name
name of the timer
Definition cmsis_os2.h:354
uint32_t cb_size
size of provided memory for control block
Definition cmsis_os2.h:357
static bool EnsureTimerHostCreated()

References osTimerAttr_t::cb_mem, osTimerAttr_t::cb_size, StkTimer::EnsureTimerHostCreated(), IsIrqContext(), osTimerAttr_t::name, osKernelGetState(), osKernelInactive, and PlacementNewOrHeap().

Here is the call graph for this function:

◆ osTimerStart()

osStatus_t osTimerStart ( osTimerId_t timer_id,
uint32_t ticks )

Start or restart a timer.

Parameters
[in]timer_idtimer ID obtained by osTimerNew.
[in]tickstime ticks value of the timer.
Returns
status code that indicates the execution status of the function.

Definition at line 1093 of file cmsis_os2_stk.cpp.

1094{
1095 if (IsIrqContext() || (timer_id == nullptr) || (g_TimerHost == nullptr))
1097
1098 StkTimer *timer = static_cast<StkTimer *>(timer_id);
1099
1100 uint32_t period = (timer->m_type == osTimerPeriodic) ? ticks : 0U;
1101 timer->m_period_ticks = period;
1102
1103 bool ok = g_TimerHost->Restart(*timer, ticks, period);
1104 return (ok ? osOK : osError);
1105}
osTimerType_t m_type
uint32_t m_period_ticks

References g_TimerHost, IsIrqContext(), StkTimer::m_period_ticks, StkTimer::m_type, osError, osErrorISR, osErrorParameter, osOK, and osTimerPeriodic.

Here is the call graph for this function:

◆ osTimerStop()

osStatus_t osTimerStop ( osTimerId_t timer_id)

Stop a timer.

Parameters
[in]timer_idtimer ID obtained by osTimerNew.
Returns
status code that indicates the execution status of the function.

Definition at line 1107 of file cmsis_os2_stk.cpp.

1108{
1109 if (IsIrqContext() || (timer_id == nullptr) || (g_TimerHost == nullptr))
1111
1112 StkTimer *timer = static_cast<StkTimer *>(timer_id);
1113
1114 if (!timer->IsActive())
1115 return osErrorResource;
1116
1117 bool ok = g_TimerHost->Stop(*timer);
1118 return (ok ? osOK : osError);
1119}

References g_TimerHost, stk::time::TimerHost::Timer::IsActive(), IsIrqContext(), osError, osErrorISR, osErrorParameter, osErrorResource, and osOK.

Here is the call graph for this function:

◆ osWatchdogAlarm_Handler()

uint32_t osWatchdogAlarm_Handler ( osThreadId_t thread_id)

Handler for expired thread watchdogs.

Parameters
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
Returns
new watchdog reload value or 0 to stop the watchdog.

◆ osZoneSetup_Callback()

void osZoneSetup_Callback ( uint32_t zone)

Setup MPU protected zone (called when zone changes).

Parameters
[in]zonezone number.