CMSIS-RTOS RTX: cmsis_os.h File Reference

| CMSIS-RTOS RTX Version 4.80 CMSIS-RTOS RTX: Real-Time Operating System for Cortex-M processor-based devices

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
cmsis_os.h File Reference

## Data Structures
struct | osThreadDef_t
| Thread Definition structure contains startup information of a thread. More...
struct | osTimerDef_t
| Timer Definition structure contains timer parameters. More...
struct | osMutexDef_t
| Mutex Definition structure contains setup information for a mutex. More...
struct | osSemaphoreDef_t
| Semaphore Definition structure contains setup information for a semaphore. More...
struct | osPoolDef_t
| Definition structure for memory block allocation. More...
struct | osMessageQDef_t
| Definition structure for message queue. More...
struct | osMailQDef_t
| Definition structure for mail queue. More...
struct | osEvent
| Event structure contains detailed information about an event. More...

## Macros
#define | osCMSIS 0x10002U
| CMSIS-RTOS API version (main [31:16] .sub [15:0])
#define | osCMSIS_RTX ((4<<16)|80)
| RTOS identification and version (main [31:16] .sub [15:0])
#define | osKernelSystemId "RTX V4.80"
| RTOS identification string.
#define | osFeature_MainThread 1
| main can be thread
#define | osFeature_Pool 1
| Memory Pools available.
#define | osFeature_MailQ 1
| Mail Queues available.
#define | osFeature_MessageQ 1
| Message Queues available.
#define | osFeature_Signals 16
| 16 Signal Flags available per thread
#define | osFeature_Semaphore 65535
| Maximum count for osSemaphoreCreate function.
#define | osFeature_Wait 0
| osWait not available
#define | osFeature_SysTick 1
| osKernelSysTick functions available
#define | os_InRegs
#define | osWaitForever 0xFFFFFFFFU
| Timeout value.
#define | osKernelSysTickFrequency os_tickfreq
| The RTOS kernel system timer frequency in Hz.
#define | osKernelSysTickMicroSec(microsec) ((microsec * os_tickus_i) + ((microsec * os_tickus_f) >> 16))
| Convert a microseconds value to a RTOS kernel system timer value.
#define | osThreadDef(name, priority, instances, stacksz)
| Create a Thread Definition with function, priority, and stack requirements.
#define | osThread(name) &os_thread_def_##name
| Access a Thread definition.
#define | osTimerDef(name, function)
| Define a Timer object.
#define | osTimer(name) &os_timer_def_##name
| Access a Timer definition.
#define | osMutexDef(name)
| Define a Mutex.
#define | osMutex(name) &os_mutex_def_##name
| Access a Mutex definition.
#define | osSemaphoreDef(name)
| Define a Semaphore object.
#define | osSemaphore(name) &os_semaphore_def_##name
| Access a Semaphore definition.
#define | osPoolDef(name, no, type)
| Define a Memory Pool.
#define | osPool(name) &os_pool_def_##name
| Access a Memory Pool definition.
#define | osMessageQDef(name, queue_sz, type)
| Create a Message Queue Definition.
#define | osMessageQ(name) &os_messageQ_def_##name
| Access a Message Queue Definition.
#define | osMailQDef(name, queue_sz, type)
| Create a Mail Queue Definition.
#define | osMailQ(name) &os_mailQ_def_##name
| Access a Mail Queue Definition.

## Typedefs
typedef void(* | os_pthread )(void const *argument)
| Entry point of a thread.
typedef void(* | os_ptimer )(void const *argument)
| Entry point of a timer call back function.
typedef struct os_thread_cb * | osThreadId
| Thread ID identifies the thread (pointer to a thread control block).
typedef struct os_timer_cb * | osTimerId
| Timer ID identifies the timer (pointer to a timer control block).
typedef struct os_mutex_cb * | osMutexId
| Mutex ID identifies the mutex (pointer to a mutex control block).
typedef struct os_semaphore_cb * | osSemaphoreId
| Semaphore ID identifies the semaphore (pointer to a semaphore control block).
typedef struct os_pool_cb * | osPoolId
| Pool ID identifies the memory pool (pointer to a memory pool control block).
typedef struct os_messageQ_cb * | osMessageQId
| Message ID identifies the message queue (pointer to a message queue control block).
typedef struct os_mailQ_cb * | osMailQId
| Mail ID identifies the mail queue (pointer to a mail queue control block).

## Enumerations
enum | osPriority { osPriorityIdle = -3, osPriorityLow = -2, osPriorityBelowNormal = -1, osPriorityNormal = 0, osPriorityAboveNormal = +1, osPriorityHigh = +2, osPriorityRealtime = +3, osPriorityError = 0x84 }
| Priority used for thread control. More...
enum | osStatus { osOK = 0, osEventSignal = 0x08, osEventMessage = 0x10, osEventMail = 0x20, osEventTimeout = 0x40, osErrorParameter = 0x80, osErrorResource = 0x81, osErrorTimeoutResource = 0xC1, osErrorISR = 0x82, osErrorISRRecursive = 0x83, osErrorPriority = 0x84, osErrorNoMemory = 0x85, osErrorValue = 0x86, osErrorOS = 0xFF, os_status_reserved = 0x7FFFFFFF }
| Status code values returned by CMSIS-RTOS functions. More...
enum | os_timer_type { osTimerOnce = 0, osTimerPeriodic = 1 }
| Timer type value for the timer definition. More...

## Functions
osStatus | osKernelInitialize (void)
| Initialize the RTOS Kernel for creating objects.
osStatus | osKernelStart (void)
| Start the RTOS Kernel.
int32_t | osKernelRunning (void)
| Check if the RTOS kernel is already started.
uint32_t | osKernelSysTick (void)
| Get the RTOS kernel system timer counter.
osThreadId | osThreadCreate (const osThreadDef_t *thread_def, void *argument)
| Create a thread and add it to Active Threads and set it to state READY.
osThreadId | osThreadGetId (void)
| Return the thread ID of the current running thread.
osStatus | osThreadTerminate (osThreadId thread_id)
| Terminate execution of a thread and remove it from Active Threads.
osStatus | osThreadYield (void)
| Pass control to next thread that is in state READY.
osStatus | osThreadSetPriority (osThreadId thread_id, osPriority priority)
| Change priority of an active thread.
osPriority | osThreadGetPriority (osThreadId thread_id)
| Get current priority of an active thread.
osStatus | osDelay (uint32_t millisec)
| Wait for Timeout (Time Delay).
osTimerId | osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument)
| Create a timer.
osStatus | osTimerStart (osTimerId timer_id, uint32_t millisec)
| Start or restart a timer.
osStatus | osTimerStop (osTimerId timer_id)
| Stop the timer.
osStatus | osTimerDelete (osTimerId timer_id)
| Delete a timer that was created by osTimerCreate.
int32_t | osSignalSet (osThreadId thread_id, int32_t signals)
| Set the specified Signal Flags of an active thread.
int32_t | osSignalClear (osThreadId thread_id, int32_t signals)
| Clear the specified Signal Flags of an active thread.
os_InRegs osEvent | osSignalWait (int32_t signals, uint32_t millisec)
| Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
osMutexId | osMutexCreate (const osMutexDef_t *mutex_def)
| Create and Initialize a Mutex object.
osStatus | osMutexWait (osMutexId mutex_id, uint32_t millisec)
| Wait until a Mutex becomes available.
osStatus | osMutexRelease (osMutexId mutex_id)
| Release a Mutex that was obtained by osMutexWait.
osStatus | osMutexDelete (osMutexId mutex_id)
| Delete a Mutex that was created by osMutexCreate.
osSemaphoreId | osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count)
| Create and Initialize a Semaphore object used for managing resources.
int32_t | osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec)
| Wait until a Semaphore token becomes available.
osStatus | osSemaphoreRelease (osSemaphoreId semaphore_id)
| Release a Semaphore token.
osStatus | osSemaphoreDelete (osSemaphoreId semaphore_id)
| Delete a Semaphore that was created by osSemaphoreCreate.
osPoolId | osPoolCreate (const osPoolDef_t *pool_def)
| Create and Initialize a memory pool.
void * | osPoolAlloc (osPoolId pool_id)
| Allocate a memory block from a memory pool.
void * | osPoolCAlloc (osPoolId pool_id)
| Allocate a memory block from a memory pool and set memory block to zero.
osStatus | osPoolFree (osPoolId pool_id, void *block)
| Return an allocated memory block back to a specific memory pool.
osMessageQId | osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id)
| Create and Initialize a Message Queue.
osStatus | osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec)
| Put a Message to a Queue.
os_InRegs osEvent | osMessageGet (osMessageQId queue_id, uint32_t millisec)
| Get a Message or Wait for a Message from a Queue.
osMailQId | osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id)
| Create and Initialize mail queue.
void * | osMailAlloc (osMailQId queue_id, uint32_t millisec)
| Allocate a memory block from a mail.
void * | osMailCAlloc (osMailQId queue_id, uint32_t millisec)
| Allocate a memory block from a mail and set memory block to zero.
osStatus | osMailPut (osMailQId queue_id, void *mail)
| Put a mail to a queue.
os_InRegs osEvent | osMailGet (osMailQId queue_id, uint32_t millisec)
| Get a mail from a queue.
osStatus | osMailFree (osMailQId queue_id, void *mail)
| Free a memory block from a mail.
uint32_t | os_suspend (void)
| Suspend the RTX task scheduler.
void | os_resume (uint32_t sleep_time)
| Resume the RTX task scheduler.

## Macro Definition Documentation

#define os_InRegs

#define osFeature_Wait 0

#define osWaitForever 0xFFFFFFFFU

wait forever timeout value

## Typedef Documentation

typedef void(* os_pthread)(void const *argument)

typedef void(* os_ptimer)(void const *argument)

typedef struct os_mailQ_cb* osMailQId

typedef struct os_messageQ_cb* osMessageQId

typedef struct os_mutex_cb* osMutexId

typedef struct os_pool_cb* osPoolId

typedef struct os_semaphore_cb* osSemaphoreId

typedef struct os_thread_cb* osThreadId

typedef struct os_timer_cb* osTimerId

## Enumeration Type Documentation

enum os_timer_type

Enumerator:

  osTimerOnce | one-shot timer
  osTimerPeriodic | repeating timer

enum osPriority

Enumerator:

  osPriorityIdle | priority: idle (lowest)
  osPriorityLow | priority: low
  osPriorityBelowNormal | priority: below normal
  osPriorityNormal | priority: normal (default)
  osPriorityAboveNormal | priority: above normal
  osPriorityHigh | priority: high
  osPriorityRealtime | priority: realtime (highest)
  osPriorityError | system cannot determine priority or thread has illegal priority

enum osStatus

Enumerator:

  osOK | function completed; no error or event occurred.
  osEventSignal | function completed; signal event occurred.
  osEventMessage | function completed; message event occurred.
  osEventMail | function completed; mail event occurred.
  osEventTimeout | function completed; timeout occurred.
  osErrorParameter | parameter error: a mandatory parameter was missing or specified an incorrect object.
  osErrorResource | resource not available: a specified resource was not available.
  osErrorTimeoutResource | resource not available within given time: a specified resource was not available within the timeout period.
  osErrorISR | not allowed in ISR context: the function cannot be called from interrupt service routines.
  osErrorISRRecursive | function called multiple times from ISR with same object.
  osErrorPriority | system cannot determine priority or thread has illegal priority.
  osErrorNoMemory | system is out of memory: it was impossible to allocate or reserve memory for the operation.
  osErrorValue | value of a parameter is out of range.
  osErrorOS | unspecified RTOS error: run-time error but no other error message fits.
  os_status_reserved | prevent from enum down-size compiler optimization.