µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
cmsis_os.h File Reference
#include <cmsis-plus/rtos/os-c-decls.h>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Classes

struct  os_mail_queue_s
 
struct  os_mailQ_def
 Definition structure for mail queue. More...
 
struct  os_messageQ_def
 Definition structure for message queue. More...
 
struct  os_mutex_def
 Mutex definition structure contains setup information for a mutex. More...
 
struct  os_pool_def
 Definition structure for memory block allocation. More...
 
struct  os_semaphore_def
 Semaphore definition structure contains setup information for a semaphore. More...
 
struct  os_thread_def
 Thread definition structure contains startup information of a thread. More...
 
struct  os_timer_def
 Timer definition structure contains timer parameters. More...
 
struct  osEvent
 Event structure contains detailed information about an event. More...
 

Macros

#define osCMSIS   0x00010002
 
#define osCMSIS_KERNEL   0x00010000
 
#define osFeature_MailQ   1
 
#define osFeature_MainThread   0
 
#define osFeature_MessageQ   1
 
#define osFeature_Pool   1
 
#define osFeature_Semaphore   30
 
#define osFeature_Signals   8
 
#define osFeature_SysTick   1
 
#define osFeature_Wait   1
 
#define osKernelSystemId   "µOS++"
 
#define osKernelSysTickFrequency   (OS_INTEGER_SYSTICK_FREQUENCY_HZ)
 The RTOS kernel system timer frequency.
 
#define osKernelSysTickMicroSec(microsec)   (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000)
 Convert a microseconds value to ticks.
 
#define osMailQ(name)   &os_mailQ_def_##name
 Access a mail queue definition.
 
#define osMailQAllocatedDef(name, items, type)
 Create a mail queue definition.
 
#define osMailQDef(name, items, type)   osMailQAllocatedDef(name, items, type)
 
#define osMailQStaticDef(name, items, type)
 
#define osMessageQ(name)   &os_messageQ_def_##name
 Access a Message Queue.
 
#define osMessageQAllocatedDef(name, items, type)
 Create a Message Queue Definition.
 
#define osMessageQDef(name, items, type)   osMessageQAllocatedDef(name, items, type)
 
#define osMessageQStaticDef(name, items, type)
 
#define osMutex(name)   &os_mutex_def_##name
 Access a mutex.
 
#define osMutexDef(name)
 Define a mutex.
 
#define osPool(name)   &os_pool_def_##name
 Access a Memory Pool definition.
 
#define osPoolAllocatedDef(name, items, type)
 Define a Memory Pool.
 
#define osPoolDef(name, items, type)   osPoolAllocatedDef(name, items, type)
 
#define osPoolStaticDef(name, items, type)
 
#define osSemaphore(name)   &os_semaphore_def_##name
 Access a Semaphore definition.
 
#define osSemaphoreDef(name)
 Define a Semaphore object.
 
#define osThread(name)   &os_thread_def_##name
 Access a Thread definition.
 
#define osThreadAllocatedDef(name, priority, instances, stacksz)
 Create a Thread Definition.
 
#define osThreadDef(name, priority, instances, stacksz)   osThreadAllocatedDef(name, priority, instances, stacksz)
 
#define osThreadStaticDef(name, priority, instances, stacksz)
 
#define osTimer(name)   &os_timer_def_##name
 Access the timer.
 
#define osTimerDef(name, function)
 Define timer.
 
#define osWaitForever   0xFFFFFFFF
 Timeout value.
 

Typedefs

typedef struct os_mail_queue_s os_mail_queue_t
 
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 os_mail_queue_t osMailQ
 
typedef struct os_mailQ_def osMailQDef_t
 Definition structure for mail queue.
 
typedef osMailQosMailQId
 Mail ID identifies the mail queue (pointer to a mail queue control block).
 
typedef os_mqueue_t osMessageQ
 
typedef os_mqueue_attr_t osMessageQAttr
 
typedef struct os_messageQ_def osMessageQDef_t
 Definition structure for message queue.
 
typedef osMessageQosMessageQId
 Message ID identifies the message queue (pointer to a message queue control block).
 
typedef os_mutex_t osMutex
 
typedef os_mutex_attr_t osMutexAttr
 
typedef struct os_mutex_def osMutexDef_t
 Mutex definition structure contains setup information for a mutex.
 
typedef osMutexosMutexId
 Mutex ID identifies the mutex (pointer to a mutex control block).
 
typedef os_mempool_t osPool
 
typedef os_mempool_attr_t osPoolAttr
 
typedef struct os_pool_def osPoolDef_t
 Definition structure for memory block allocation.
 
typedef osPoolosPoolId
 Pool ID identifies the memory pool (pointer to a memory pool control block).
 
typedef os_semaphore_t osSemaphore
 
typedef os_semaphore_attr_t osSemaphoreAttr
 
typedef struct os_semaphore_def osSemaphoreDef_t
 Semaphore definition structure contains setup information for a semaphore.
 
typedef osSemaphoreosSemaphoreId
 Semaphore ID identifies the semaphore (pointer to a semaphore control block).
 
typedef os_thread_t osThread
 
typedef os_thread_attr_t osThreadAttr
 
typedef struct os_thread_def osThreadDef_t
 Thread definition structure contains startup information of a thread.
 
typedef osThreadosThreadId
 Thread ID identifies the thread (pointer to a thread control block).
 
typedef os_timer_t osTimer
 
typedef os_timer_attr_t osTimerAttr
 
typedef struct os_timer_def osTimerDef_t
 Timer definition structure contains timer parameters.
 
typedef osTimerosTimerId
 Timer ID identifies the timer (pointer to a timer control block).
 

Enumerations

enum  os_timer_type {
  osTimerOnce = os_timer_once ,
  osTimerPeriodic = os_timer_periodic
}
 Timer type value for the timer definition. More...
 
enum  osPriority {
  osPriorityIdle = os_thread_priority_idle ,
  osPriorityLow = os_thread_priority_low ,
  osPriorityBelowNormal = os_thread_priority_below_normal ,
  osPriorityNormal = os_thread_priority_normal ,
  osPriorityAboveNormal = os_thread_priority_above_normal ,
  osPriorityHigh = os_thread_priority_high ,
  osPriorityRealtime = os_thread_priority_realtime ,
  osPriorityError = os_thread_priority_error
}
 
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...
 

Functions

osStatus osDelay (uint32_t millisec)
 Time Delay.
 
osStatus osKernelInitialize (void)
 Initialize the RTOS.
 
int32_t osKernelRunning (void)
 Check if the RTOS scheduler is started.
 
osStatus osKernelStart (void)
 
uint32_t osKernelSysTick (void)
 Get the system timer counter.
 
void * osMailAlloc (osMailQId mail_id, uint32_t millisec)
 Allocate a memory block from a mail.
 
void * osMailCAlloc (osMailQId mail_id, uint32_t millisec)
 Allocate and clear a memory block from a mail.
 
osMailQId osMailCreate (const osMailQDef_t *mail_def, osThreadId thread_id)
 Create a mail queue.
 
osStatus osMailFree (osMailQId mail_id, void *mail)
 Free a memory block from a mail.
 
osEvent osMailGet (osMailQId mail_id, uint32_t millisec)
 Get a mail from a queue.
 
osStatus osMailPut (osMailQId mail_id, void *mail)
 Put a mail to a queue.
 
osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id)
 Create a message queue.
 
osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec)
 Get a message or Wait for a Message from a Queue.
 
osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec)
 Put a message to a queue.
 
osMutexId osMutexCreate (const osMutexDef_t *mutex_def)
 Create a mutex.
 
osStatus osMutexDelete (osMutexId mutex_id)
 Delete the mutex.
 
osStatus osMutexRelease (osMutexId mutex_id)
 Release the mutex.
 
osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec)
 Wait for mutex.
 
void * osPoolAlloc (osPoolId pool_id)
 Allocate a memory block.
 
void * osPoolCAlloc (osPoolId pool_id)
 Allocate and clear a memory block.
 
osPoolId osPoolCreate (const osPoolDef_t *pool_def)
 Create a memory pool.
 
osStatus osPoolFree (osPoolId pool_id, void *block)
 Free a memory block.
 
osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count)
 Create a semaphore.
 
osStatus osSemaphoreDelete (osSemaphoreId semaphore_id)
 Delete the semaphore.
 
osStatus osSemaphoreRelease (osSemaphoreId semaphore_id)
 Release the semaphore.
 
int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec)
 Wait until a Semaphore token becomes available.
 
int32_t osSignalClear (osThreadId thread_id, int32_t signals)
 Clear the specified Signal Flags of an active thread.
 
int32_t osSignalSet (osThreadId thread_id, int32_t signals)
 Set signal flags.
 
osEvent osSignalWait (int32_t signals, uint32_t millisec)
 Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
 
osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *args)
 Create a thread.
 
osThreadId osThreadGetId (void)
 Get the current thread.
 
osPriority osThreadGetPriority (osThreadId thread_id)
 Get thread priority.
 
osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority)
 Change thread priority.
 
osStatus osThreadTerminate (osThreadId thread_id)
 Terminate a thread.
 
osStatus osThreadYield (void)
 Yield control.
 
osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *args)
 Create a timer.
 
osStatus osTimerDelete (osTimerId timer_id)
 Delete the timer.
 
osStatus osTimerStart (osTimerId timer_id, uint32_t millisec)
 Start the timer.
 
osStatus osTimerStop (osTimerId timer_id)
 Stop the timer.
 
osEvent osWait (uint32_t millisec)
 Wait for Signal, Message, Mail, or Timeout.
 

Macro Definition Documentation

◆ osCMSIS

#define osCMSIS   0x00010002
Note
MUST REMAIN UNCHANGED: osCMSIS identifies the CMSIS-RTOS API version. API version (main [31:16] .sub [15:0]).

Definition at line 98 of file cmsis_os.h.

◆ osCMSIS_KERNEL

#define osCMSIS_KERNEL   0x00010000
Note
CAN BE CHANGED: osCMSIS_KERNEL identifies the underlying RTOS kernel and version number. RTOS identification and version (main [31:16] .sub [15:0]).

Definition at line 101 of file cmsis_os.h.

◆ osFeature_MailQ

#define osFeature_MailQ   1

Mail Queues: 1=available, 0=not available.

Definition at line 109 of file cmsis_os.h.

◆ osFeature_MainThread

#define osFeature_MainThread   0
Note
MUST REMAIN UNCHANGED: osFeature_xxx shall be consistent in every CMSIS-RTOS. Main thread 1=main can be thread, 0=not available.

Definition at line 107 of file cmsis_os.h.

◆ osFeature_MessageQ

#define osFeature_MessageQ   1

Message Queues: 1=available, 0=not available.

Definition at line 110 of file cmsis_os.h.

◆ osFeature_Pool

#define osFeature_Pool   1

Memory Pools: 1=available, 0=not available.

Definition at line 108 of file cmsis_os.h.

◆ osFeature_Semaphore

#define osFeature_Semaphore   30

Maximum count for osSemaphoreCreate function.

Definition at line 112 of file cmsis_os.h.

◆ osFeature_Signals

#define osFeature_Signals   8

Maximum number of Signal Flags available per thread.

Definition at line 111 of file cmsis_os.h.

◆ osFeature_SysTick

#define osFeature_SysTick   1

osKernelSysTick functions: 1=available, 0=not available.

Definition at line 114 of file cmsis_os.h.

◆ osFeature_Wait

#define osFeature_Wait   1

osWait function: 1=available, 0=not available.

Definition at line 113 of file cmsis_os.h.

◆ osKernelSystemId

#define osKernelSystemId   "µOS++"
Note
MUST REMAIN UNCHANGED: osKernelSystemId shall be consistent in every CMSIS-RTOS. RTOS identification string.

Definition at line 104 of file cmsis_os.h.

◆ osKernelSysTickFrequency

#define osKernelSysTickFrequency   (OS_INTEGER_SYSTICK_FREQUENCY_HZ)

Specifies the frequency of the Kernel SysTick timer in Hz. The value is typically use to scale a time value and is for example used in osKernelSysTickMicroSec.

Note
Reflects the system timer setting and is typically defined in a configuration file.

Definition at line 447 of file cmsis_os.h.

◆ osKernelSysTickMicroSec

#define osKernelSysTickMicroSec (   microsec)    (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000)

Allows to scale a microsecond value to the frequency of the Kernel SysTick timer. This macro is typically used to check for short timeouts in polling loops.

Parameters
microsectime value in microseconds.
Returns
time value normalized to the osKernelSysTickFrequency.

Definition at line 460 of file cmsis_os.h.

◆ osMailQ

#define osMailQ (   name)    &os_mailQ_def_##name
Parameters
namename of the queue.
Note
CAN BE CHANGED: The parameter to osMailQ shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 1247 of file cmsis_os.h.

◆ osMailQAllocatedDef

#define osMailQAllocatedDef (   name,
  items,
  type 
)
Value:
struct { \
osMailQ data; \
struct { \
type pool[items]; \
} pool_storage; \
struct { \
void* queue[items]; \
os_mqueue_index_t links[2 * items]; \
os_mqueue_prio_t prios[items]; \
} queue_storage; \
} os_mailQ_##name; \
const osMailQDef_t os_mailQ_def_##name = { \
#name, \
(items), \
sizeof (type), \
sizeof (void*), \
0, \
0, \
0, \
0, \
&os_mailQ_##name.data \
}
uint8_t os_mqueue_prio_t
Type of variables holding message queue priorities.
os_mqueue_size_t os_mqueue_index_t
Definition structure for mail queue.
Definition cmsis_os.h:360
Parameters
namename of the queue.
itemsmaximum number of messages in queue.
typedata type of a single message element.
Note
CAN BE CHANGED: The parameter to osMailQDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 1187 of file cmsis_os.h.

◆ osMailQDef

#define osMailQDef (   name,
  items,
  type 
)    osMailQAllocatedDef(name, items, type)

Definition at line 1236 of file cmsis_os.h.

◆ osMailQStaticDef

#define osMailQStaticDef (   name,
  items,
  type 
)
Value:
struct { \
osMailQ data; \
struct { \
type pool[items]; \
} pool_storage; \
struct { \
void* queue[items]; \
os_mqueue_index_t links[2 * items]; \
os_mqueue_prio_t prios[items]; \
} queue_storage; \
} os_mailQ_##name; \
const osMailQDef_t os_mailQ_def_##name = { \
#name, \
(items), \
sizeof (type), \
sizeof (void*), \
&os_mailQ_##name.pool_storage, \
sizeof(os_mailQ_##name.pool_storage), \
&os_mailQ_##name.queue_storage, \
sizeof(os_mailQ_##name.queue_storage), \
&os_mailQ_##name.data \
}

Definition at line 1210 of file cmsis_os.h.

◆ osMessageQ

#define osMessageQ (   name)    &os_messageQ_def_##name
Parameters
namename of the queue.

Access to the message queue definition for the function osMessageCreate.

Note
CAN BE CHANGED: The parameter to osMessageQ shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 1123 of file cmsis_os.h.

◆ osMessageQAllocatedDef

#define osMessageQAllocatedDef (   name,
  items,
  type 
)
Value:
struct { \
osMessageQ data; \
} os_messageQ_##name; \
const osMessageQDef_t os_messageQ_def_##name = { \
#name, \
(items), \
sizeof (void*), \
0, \
0, \
&os_messageQ_##name.data \
}
Definition structure for message queue.
Definition cmsis_os.h:346
Message queue object storage.
Parameters
namename of the queue.
itemsmaximum number of messages in the queue.
typedata type of a single message element (for debugger).
Note
CAN BE CHANGED: The parameter to osMessageQDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 1076 of file cmsis_os.h.

◆ osMessageQDef

#define osMessageQDef (   name,
  items,
  type 
)    osMessageQAllocatedDef(name, items, type)

Definition at line 1109 of file cmsis_os.h.

◆ osMessageQStaticDef

#define osMessageQStaticDef (   name,
  items,
  type 
)
Value:
struct { \
osMessageQ data; \
struct { \
void* queue[items]; \
os_mqueue_index_t links[2 * items]; \
os_mqueue_prio_t prios[items]; \
} storage; \
} os_messageQ_##name; \
const osMessageQDef_t os_messageQ_def_##name = { \
#name, \
(items), \
sizeof (void*), \
&os_messageQ_##name.storage, \
sizeof(os_messageQ_##name.storage), \
&os_messageQ_##name.data \
}

Definition at line 1088 of file cmsis_os.h.

◆ osMutex

#define osMutex (   name)    &os_mutex_def_##name
Parameters
namename of the mutex object.

Provides osMutexCreate access to the mutex object definition.

Note
CAN BE CHANGED: The parameter to osMutex shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 803 of file cmsis_os.h.

◆ osMutexDef

#define osMutexDef (   name)
Value:
osMutex os_mutex_data_##name; \
const osMutexDef_t os_mutex_def_##name = \
{ \
#name, \
&os_mutex_data_##name \
}
Mutex definition structure contains setup information for a mutex.
Definition cmsis_os.h:305
Mutex object storage.
Definition os-c-decls.h:973
Parameters
namename of the mutex object.

Define a mutex object that is referenced by osMutex.

Note
CAN BE CHANGED: The parameter to osMutexDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 784 of file cmsis_os.h.

◆ osPool

#define osPool (   name)    &os_pool_def_##name
Parameters
namename of the memory pool.
Note
CAN BE CHANGED: The parameter to osPool shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 1009 of file cmsis_os.h.

◆ osPoolAllocatedDef

#define osPoolAllocatedDef (   name,
  items,
  type 
)
Value:
struct { \
osPool data; \
} os_pool_##name; \
const osPoolDef_t os_pool_def_##name = \
{ \
#name, \
(items), \
sizeof(type), \
0, \
0, \
&os_pool_##name.data \
}
Memory pool object storage.
Definition structure for memory block allocation.
Definition cmsis_os.h:332
Parameters
namename of the memory pool.
itemsmaximum number of blocks (objects) in the memory pool.
typedata type of a single block (object).
Note
CAN BE CHANGED: The parameter to osPoolDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 966 of file cmsis_os.h.

◆ osPoolDef

#define osPoolDef (   name,
  items,
  type 
)    osPoolAllocatedDef(name, items, type)

Definition at line 998 of file cmsis_os.h.

◆ osPoolStaticDef

#define osPoolStaticDef (   name,
  items,
  type 
)
Value:
struct { \
osPool data; \
struct { \
type pool[items]; \
} storage; \
} os_pool_##name; \
const osPoolDef_t os_pool_def_##name = \
{ \
#name, \
(items), \
sizeof(type), \
&os_pool_##name.storage, \
sizeof(os_pool_##name.storage), \
&os_pool_##name.data \
}

Definition at line 979 of file cmsis_os.h.

◆ osSemaphore

#define osSemaphore (   name)    &os_semaphore_def_##name
Parameters
namename of the semaphore object.
Note
CAN BE CHANGED: The parameter to osSemaphore shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 893 of file cmsis_os.h.

◆ osSemaphoreDef

#define osSemaphoreDef (   name)
Value:
osSemaphore os_semaphore_data_##name; \
const osSemaphoreDef_t os_semaphore_def_##name = \
{ \
#name, \
&os_semaphore_data_##name \
}
Semaphore definition structure contains setup information for a semaphore.
Definition cmsis_os.h:315
Semaphore object storage.
Parameters
namename of the semaphore object.
Note
CAN BE CHANGED: The parameter to osSemaphoreDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 876 of file cmsis_os.h.

◆ osThread

#define osThread (   name)    &os_thread_def_##name
Parameters
namename of the thread definition object.

Access to the thread definition for the function osThreadCreate.

Note
CAN BE CHANGED: The parameter to osThread shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 531 of file cmsis_os.h.

◆ osThreadAllocatedDef

#define osThreadAllocatedDef (   name,
  priority,
  instances,
  stacksz 
)
Value:
struct { \
osThread data[instances]; \
} os_thread_##name; \
const osThreadDef_t os_thread_def_##name = \
{ \
#name, \
(os_pthread)(name), \
(priority), \
(instances), \
(stacksz), \
&os_thread_##name.data[0], \
0 \
}
Thread definition structure contains startup information of a thread.
Definition cmsis_os.h:277
Thread object storage.
Definition os-c-decls.h:563
Parameters
namename of the thread function.
priorityinitial priority of the thread function.
instancesnumber of possible thread instances.
stackszstack size (in bytes) requirements for the thread function.

Define the attributes of a thread functions that can be created by the function osThreadCreate using osThread.

Note
CAN BE CHANGED: The parameters to osThreadDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 485 of file cmsis_os.h.

◆ osThreadDef

#define osThreadDef (   name,
  priority,
  instances,
  stacksz 
)    osThreadAllocatedDef(name, priority, instances, stacksz)

Definition at line 517 of file cmsis_os.h.

◆ osThreadStaticDef

#define osThreadStaticDef (   name,
  priority,
  instances,
  stacksz 
)
Value:
struct { \
uint64_t stack[(instances)*((stacksz+sizeof(uint64_t)-1)/sizeof(uint64_t))]; \
osThread data[instances]; \
} os_thread_##name; \
const osThreadDef_t os_thread_def_##name = \
{ \
#name, \
(os_pthread)(name), \
(priority), \
(instances), \
(stacksz), \
&os_thread_##name.data[0], \
&os_thread_##name.stack[0] \
}

Definition at line 499 of file cmsis_os.h.

◆ osTimer

#define osTimer (   name)    &os_timer_def_##name
Parameters
namename of the timer object.

Provide access to the timer definition for the function osTimerCreate.

Note
CAN BE CHANGED: The parameter to osTimer shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 676 of file cmsis_os.h.

◆ osTimerDef

#define osTimerDef (   name,
  function 
)
Value:
struct { \
osTimer data; \
} os_timer_##name; \
const osTimerDef_t os_timer_def_##name = \
{ \
#name, \
(os_ptimer)(function), \
&os_timer_##name.data \
}
Timer definition structure contains timer parameters.
Definition cmsis_os.h:294
Timer object storage.
Definition os-c-decls.h:784
Parameters
namename of the timer object.
functionname of the timer call back function.

Define the attributes of a timer object.

Note
CAN BE CHANGED: The parameter to osTimerDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.

Definition at line 654 of file cmsis_os.h.

◆ osWaitForever

#define osWaitForever   0xFFFFFFFF
Note
The names MUST REMAIN UNCHANGED: osWaitForever shall be consistent in every CMSIS-RTOS. Wait forever timeout value.

Definition at line 147 of file cmsis_os.h.

Typedef Documentation

◆ os_mail_queue_t

◆ os_pthread

typedef void(* os_pthread) (void const *argument)
Note
MUST REMAIN UNCHANGED: os_pthread shall be consistent in every CMSIS-RTOS.

Definition at line 186 of file cmsis_os.h.

◆ os_ptimer

typedef void(* os_ptimer) (void const *argument)
Note
MUST REMAIN UNCHANGED: os_ptimer shall be consistent in every CMSIS-RTOS.

Definition at line 193 of file cmsis_os.h.

◆ osMailQ

Definition at line 221 of file cmsis_os.h.

◆ osMailQDef_t

typedef struct os_mailQ_def osMailQDef_t
Note
CAN BE CHANGED: os_mailQ_def is implementation specific in every CMSIS-RTOS.

◆ osMailQId

typedef osMailQ* osMailQId
Note
CAN BE CHANGED: os_mailQ_cb is implementation specific in every CMSIS-RTOS.

Definition at line 263 of file cmsis_os.h.

◆ osMessageQ

Definition at line 212 of file cmsis_os.h.

◆ osMessageQAttr

Definition at line 213 of file cmsis_os.h.

◆ osMessageQDef_t

Note
CAN BE CHANGED: os_messageQ_def is implementation specific in every CMSIS-RTOS.

◆ osMessageQId

Note
CAN BE CHANGED: os_messageQ_cb is implementation specific in every CMSIS-RTOS.

Definition at line 257 of file cmsis_os.h.

◆ osMutex

Definition at line 203 of file cmsis_os.h.

◆ osMutexAttr

Definition at line 204 of file cmsis_os.h.

◆ osMutexDef_t

typedef struct os_mutex_def osMutexDef_t
Note
CAN BE CHANGED: os_mutex_def is implementation specific in every CMSIS-RTOS.

◆ osMutexId

typedef osMutex* osMutexId
Note
CAN BE CHANGED: os_mutex_cb is implementation specific in every CMSIS-RTOS.

Definition at line 239 of file cmsis_os.h.

◆ osPool

Definition at line 209 of file cmsis_os.h.

◆ osPoolAttr

Definition at line 210 of file cmsis_os.h.

◆ osPoolDef_t

typedef struct os_pool_def osPoolDef_t
Note
CAN BE CHANGED: os_pool_def is implementation specific in every CMSIS-RTOS.

◆ osPoolId

typedef osPool* osPoolId
Note
CAN BE CHANGED: os_pool_cb is implementation specific in every CMSIS-RTOS.

Definition at line 251 of file cmsis_os.h.

◆ osSemaphore

Definition at line 206 of file cmsis_os.h.

◆ osSemaphoreAttr

Definition at line 207 of file cmsis_os.h.

◆ osSemaphoreDef_t

Note
CAN BE CHANGED: os_semaphore_def is implementation specific in every CMSIS-RTOS.

◆ osSemaphoreId

Note
CAN BE CHANGED: os_semaphore_cb is implementation specific in every CMSIS-RTOS.

Definition at line 245 of file cmsis_os.h.

◆ osThread

Definition at line 197 of file cmsis_os.h.

◆ osThreadAttr

Definition at line 198 of file cmsis_os.h.

◆ osThreadDef_t

typedef struct os_thread_def osThreadDef_t
Note
CAN BE CHANGED: os_thread_def is implementation specific in every CMSIS-RTOS.

◆ osThreadId

typedef osThread* osThreadId
Note
CAN BE CHANGED: os_thread_cb is implementation specific in every CMSIS-RTOS.

Definition at line 227 of file cmsis_os.h.

◆ osTimer

Definition at line 200 of file cmsis_os.h.

◆ osTimerAttr

Definition at line 201 of file cmsis_os.h.

◆ osTimerDef_t

typedef struct os_timer_def osTimerDef_t
Note
CAN BE CHANGED: os_timer_def is implementation specific in every CMSIS-RTOS.

◆ osTimerId

typedef osTimer* osTimerId
Note
CAN BE CHANGED: os_timer_cb is implementation specific in every CMSIS-RTOS.

Definition at line 233 of file cmsis_os.h.

Enumeration Type Documentation

◆ os_timer_type

Note
The names MUST REMAIN UNCHANGED: os_timer_type shall be consistent in every CMSIS-RTOS.
Enumerator
osTimerOnce 

One-shot timer.

osTimerPeriodic 

Repeating timer.

Definition at line 176 of file cmsis_os.h.

177 {
os_timer_type
Timer type value for the timer definition.
Definition cmsis_os.h:177
@ osTimerPeriodic
Definition cmsis_os.h:179
@ osTimerOnce
Definition cmsis_os.h:178
@ os_timer_once
Definition os-c-decls.h:696
@ os_timer_periodic
Definition os-c-decls.h:697

◆ osPriority

enum osPriority

Priority used for thread control.

Note
The names MUST REMAIN UNCHANGED: osPriority shall be consistent in every CMSIS-RTOS.
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.

Definition at line 131 of file cmsis_os.h.

132 {
141 } osPriority;
osPriority
Definition cmsis_os.h:132
@ osPriorityRealtime
Definition cmsis_os.h:139
@ osPriorityAboveNormal
Definition cmsis_os.h:137
@ osPriorityBelowNormal
Definition cmsis_os.h:135
@ osPriorityNormal
Definition cmsis_os.h:136
@ osPriorityIdle
Definition cmsis_os.h:133
@ osPriorityLow
Definition cmsis_os.h:134
@ osPriorityHigh
Definition cmsis_os.h:138
@ osPriorityError
Definition cmsis_os.h:140
@ os_thread_priority_error
Definition os-c-decls.h:281
@ os_thread_priority_below_normal
Definition os-c-decls.h:274
@ os_thread_priority_high
Definition os-c-decls.h:277
@ os_thread_priority_realtime
Definition os-c-decls.h:278
@ os_thread_priority_idle
Definition os-c-decls.h:271
@ os_thread_priority_normal
Definition os-c-decls.h:275
@ os_thread_priority_low
Definition os-c-decls.h:273
@ os_thread_priority_above_normal
Definition os-c-decls.h:276

◆ osStatus

enum osStatus
Note
The names MUST REMAIN UNCHANGED: osStatus shall be consistent in every CMSIS-RTOS.
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.

Definition at line 153 of file cmsis_os.h.

154 {
155 osOK = 0,
156 osEventSignal = 0x08,
157 osEventMessage = 0x10,
158 osEventMail = 0x20,
159 osEventTimeout = 0x40,
160 osErrorParameter = 0x80,
161 osErrorResource = 0x81,
163 osErrorISR = 0x82,
164 osErrorISRRecursive = 0x83,
165 osErrorPriority = 0x84,
166 osErrorNoMemory = 0x85,
167 osErrorValue = 0x86,
168 osErrorOS = 0xFF,
169 os_status_reserved = 0x7FFFFFFF
170 } osStatus;
osStatus
Status code values returned by CMSIS-RTOS functions.
Definition cmsis_os.h:154
@ osEventMail
Definition cmsis_os.h:158
@ osErrorISR
Definition cmsis_os.h:163
@ osErrorTimeoutResource
Definition cmsis_os.h:162
@ osErrorValue
Definition cmsis_os.h:167
@ osEventSignal
Definition cmsis_os.h:156
@ osErrorOS
Definition cmsis_os.h:168
@ osEventTimeout
Definition cmsis_os.h:159
@ osErrorResource
Definition cmsis_os.h:161
@ osOK
Definition cmsis_os.h:155
@ osErrorPriority
Definition cmsis_os.h:165
@ osErrorParameter
Definition cmsis_os.h:160
@ os_status_reserved
Definition cmsis_os.h:169
@ osEventMessage
Definition cmsis_os.h:157
@ osErrorNoMemory
Definition cmsis_os.h:166
@ osErrorISRRecursive
Definition cmsis_os.h:164

Function Documentation

◆ osDelay()

osStatus osDelay ( uint32_t  millisec)
Parameters
[in]millisecTimeout value "time delay" value.
Return values
osEventTimeoutThe time delay is executed.
osErrorISRosDelay() cannot be called from interrupt service routines.

Wait for a specified time period in millisec.

The millisec value specifies the number of timer ticks and is therefore an upper bound. The exact time delay depends on the actual time elapsed since the last timer tick.

For a value of 1, the system waits until the next timer tick occurs. That means that the actual time delay may be up to one timer tick less.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3734 of file os-c-wrapper.cpp.

3735{
3737 {
3738 return osErrorISR;
3739 }
3740
3742 clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)));
3743
3744 if (res == ETIMEDOUT)
3745 {
3746 return osEventTimeout;
3747 }
3748 else
3749 {
3750 return osErrorOS;
3751 }
3752}
static constexpr clock::duration_t ticks_cast(Rep_T microsec)
Convert microseconds to ticks.
result_t sleep_for(duration_t duration)
Sleep for a relative duration.
clock_systick sysclock
The system clock object instance.
bool in_handler_mode(void)
Check if the CPU is in handler mode.
Definition os-sched.h:1101
uint32_t result_t
Type of values returned by RTOS functions.
Definition os-decls.h:95

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osErrorOS, osEventTimeout, os::rtos::clock::sleep_for(), os::rtos::sysclock, and os::rtos::clock_systick::ticks_cast().

◆ osKernelInitialize()

osStatus osKernelInitialize ( void  )
Return values
osOKThe RTOS kernel was initialised.
osErrorISRThe function cannot be invoked from Interrupt Service Routines.
Note
MUST REMAIN UNCHANGED: osKernelInitialize shall be consistent in every CMSIS-RTOS.

Initialise of the RTOS Kernel to allow peripheral setup and creation of other RTOS objects with the functions:

  • osThreadCreate : Create a thread function.
  • osTimerCreate : Define attributes of the timer callback function.
  • osMutexCreate : Define and initialise a mutex.
  • osSemaphoreCreate : Define and initialise a semaphore.
  • osPoolCreate : Define and initialise a fix-size memory pool.
  • osMessageCreate : Define and initialise a message queue.
  • osMailCreate : Define and initialise a mail queue with fix-size memory blocks.

The RTOS scheduler does not start thread switching until the function osKernelStart is called.

Note
In case that the RTOS Kernel starts thread execution with the function main the function osKernelInitialize stops thread switching. This allows you to setup the system to a defined state before thread switching is resumed with osKernelStart.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3409 of file os-c-wrapper.cpp.

3410{
3412 {
3413 return osErrorISR;
3414 }
3415
3417 return osOK;
3418}
result_t initialize(void)
Initialise the RTOS scheduler.
Definition os-core.cpp:164

References os::rtos::interrupts::in_handler_mode(), os::rtos::scheduler::initialize(), osErrorISR, and osOK.

◆ osKernelRunning()

int32_t osKernelRunning ( void  )
Return values
0The RTOS is not started.
1The RTOS is started.

Identifies if the RTOS scheduler is started. For systems with the option to start the main function as a thread this allows you to identify that the RTOS scheduler is already running.

Note
Can be invoked from Interrupt Service Routines.

Definition at line 3446 of file os-c-wrapper.cpp.

3447{
3448 return scheduler::started () ? 1 : 0;
3449}
bool started(void)
Check if the scheduler was started.
Definition os-sched.h:829

References os::rtos::scheduler::started().

◆ osKernelStart()

osStatus osKernelStart ( void  )

Start the RTOS scheduler.

Return values
osOKThe RTOS scheduler has been successfully started.
osErrorISRThe function cannot be invoked from Interrupt Service Routines.
Note
MUST REMAIN UNCHANGED: osKernelStart shall be consistent in every CMSIS-RTOS.

Start the RTOS Kernel and begin thread switching.

Note
When the CMSIS-RTOS starts thread execution with the function main this function resumes thread switching. The main thread will continue executing after osKernelStart.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3431 of file os-c-wrapper.cpp.

3432{
3434 // In µOS++ this does not return.
3435}
void start(void)
Start the RTOS scheduler.
Definition os-core.cpp:193

References os::rtos::scheduler::start().

◆ osKernelSysTick()

uint32_t osKernelSysTick ( void  )
Returns
The RTOS kernel system timer as a 32-bits value.
Note
MUST REMAIN UNCHANGED: osKernelSysTick shall be consistent in every CMSIS-RTOS.

◆ osMailAlloc()

void * osMailAlloc ( osMailQId  mail_id,
uint32_t  millisec 
)
Parameters
[in]mail_idmail queue ID obtained with osMailCreate.
[in]millisecTimeout value or 0 in case of no time-out.
Returns
pointer to memory block that can be filled with mail or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osMailAlloc shall be consistent in every CMSIS-RTOS.

◆ osMailCAlloc()

void * osMailCAlloc ( osMailQId  mail_id,
uint32_t  millisec 
)
Parameters
[in]mail_idmail queue ID obtained with osMailCreate.
[in]millisecTimeout value or 0 in case of no time-out.
Returns
pointer to memory block that can be filled with mail or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osMailCAlloc shall be consistent in every CMSIS-RTOS.

◆ osMailCreate()

osMailQId osMailCreate ( const osMailQDef_t mail_def,
osThreadId  thread_id 
)
Parameters
[in]mail_defreference to the mail queue definition obtain with osMailQ.
[in]thread_idthread ID (obtained by osThreadCreate or osThreadGetId) or NULL.
Returns
mail queue ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osMailCreate shall be consistent in every CMSIS-RTOS.

◆ osMailFree()

osStatus osMailFree ( osMailQId  mail_id,
void *  mail 
)
Parameters
[in]mail_idmail queue ID obtained with osMailCreate.
[in]mailpointer to the memory block that was obtained with osMailGet.
Return values
osOKThe mail block is released.
osErrorValueMail block does not belong to the mail queue pool.
osErrorParameterThe value to the parameter queue_id is incorrect.
Note
MUST REMAIN UNCHANGED: osMailFree shall be consistent in every CMSIS-RTOS.

◆ osMailGet()

osEvent osMailGet ( osMailQId  mail_id,
uint32_t  millisec 
)
Parameters
[in]mail_idmail queue ID obtained with osMailCreate.
[in]millisecTimeout value or 0 in case of no time-out.
Return values
osOKNo mail is available in the queue and no timeout was specified.
osEventTimeoutNo mail has arrived during the given timeout period.
osEventMailMail received, value.p contains the pointer to mail content.
osErrorParameterA parameter is invalid or outside of a permitted range.
Note
MUST REMAIN UNCHANGED: osMailGet shall be consistent in every CMSIS-RTOS.

◆ osMailPut()

osStatus osMailPut ( osMailQId  mail_id,
void *  mail 
)
Parameters
[in]mail_idmail queue ID obtained with osMailCreate.
[in]mailmemory block previously allocated with osMailAlloc or osMailCAlloc.
Return values
osOKThe message is put into the queue.
osErrorValueMail was previously not allocated as memory slot.
osErrorParameterA parameter is invalid or outside of a permitted range.
Note
MUST REMAIN UNCHANGED: osMailPut shall be consistent in every CMSIS-RTOS.

◆ osMessageCreate()

osMessageQId osMessageCreate ( const osMessageQDef_t queue_def,
osThreadId  thread_id 
)
Parameters
[in]queue_defqueue definition referenced with osMessageQ.
[in]thread_idthread ID (obtained by osThreadCreate or osThreadGetId) or NULL.
Returns
message queue ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osMessageCreate shall be consistent in every CMSIS-RTOS.

◆ osMessageGet()

osEvent osMessageGet ( osMessageQId  queue_id,
uint32_t  millisec 
)
Parameters
[in]queue_idmessage queue ID obtained with osMessageCreate.
[in]millisecTimeout value or 0 in case of no time-out.
Return values
osOKNo message is available in the queue and no timeout was specified.
osEventTimeoutNo message has arrived during the given timeout period.
osEventMessageMessage received, value.p contains the pointer to message.
osErrorParameterA parameter is invalid or outside of a permitted range.
Note
MUST REMAIN UNCHANGED: osMessageGet shall be consistent in every CMSIS-RTOS.

◆ osMessagePut()

osStatus osMessagePut ( osMessageQId  queue_id,
uint32_t  info,
uint32_t  millisec 
)
Parameters
[in]queue_idmessage queue ID obtained with osMessageCreate.
[in]infomessage information.
[in]millisecTimeout value or 0 in case of no time-out.
Return values
osOKThe message is put into the queue.
osErrorResourceno memory in the queue was available.
osErrorTimeoutResourceno memory in the queue was available during the given time limit.
osErrorParametera parameter is invalid or outside of a permitted range. status code that indicates the execution status of the function.
Note
MUST REMAIN UNCHANGED: osMessagePut shall be consistent in every CMSIS-RTOS.

◆ osMutexCreate()

osMutexId osMutexCreate ( const osMutexDef_t mutex_def)
Parameters
[in]mutex_defmutex definition referenced with osMutex.
Returns
mutex ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osMutexCreate shall be consistent in every CMSIS-RTOS.

Create and initialise a mutex object instance.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4099 of file os-c-wrapper.cpp.

4100{
4102 {
4103 return nullptr;
4104 }
4105
4106 if (mutex_def == nullptr)
4107 {
4108 return nullptr;
4109 }
4110
4111 mutex::attributes attr;
4114
4115 new ((void*)mutex_def->data) mutex (mutex_def->name, attr);
4116
4117 return reinterpret_cast<osMutexId> (mutex_def->data);
4118}
Mutex attributes.
Definition os-mutex.h:202
type_t mx_type
Attribute with the mutex type.
Definition os-mutex.h:273
protocol_t mx_protocol
Attribute with the mutex protocol.
Definition os-mutex.h:263
POSIX compliant mutex.
Definition os-mutex.h:52
@ inherit
Inherit priority from highest priority thread.
Definition os-mutex.h:80
@ recursive
Recursive mutex behaviour.
Definition os-mutex.h:168
osMutex * data
Definition cmsis_os.h:307
const char * name
Definition cmsis_os.h:306

References os_mutex_def::data, os::rtos::interrupts::in_handler_mode(), os::rtos::mutex::protocol::inherit, os::rtos::mutex::attributes::mx_protocol, os::rtos::mutex::attributes::mx_type, os_mutex_def::name, and os::rtos::mutex::type::recursive.

◆ osMutexDelete()

osStatus osMutexDelete ( osMutexId  mutex_id)
Parameters
[in]mutex_idmutex ID obtained by osMutexCreate.
Return values
osOKThe mutex object has been deleted.
osErrorISRosMutexDelete cannot be called from interrupt service routines.
osErrorResourceAll tokens have already been released.
osErrorParameterThe parameter mutex_id is incorrect.
Note
MUST REMAIN UNCHANGED: osMutexDelete shall be consistent in every CMSIS-RTOS.

Delete a mutex object instance. The function releases internal memory obtained for mutex handling. After this call the mutex_id is no longer valid and cannot be used. The mutex may be created again using the function osMutexCreate.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4248 of file os-c-wrapper.cpp.

4249{
4251 {
4252 return osErrorISR;
4253 }
4254
4255 if (mutex_id == nullptr)
4256 {
4257 return osErrorParameter;
4258 }
4259
4260 (reinterpret_cast<rtos::mutex&> (*mutex_id)).~mutex ();
4261 return osOK;
4262}

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osErrorParameter, and osOK.

◆ osMutexRelease()

osStatus osMutexRelease ( osMutexId  mutex_id)
Parameters
[in]mutex_idmutex ID obtained by osMutexCreate.
Return values
osOKThe mutex has been correctly released.
osErrorResourceThe mutex was not obtained before.
osErrorParameterThe parameter mutex_id is incorrect.
osErrorISRosMutexRelease cannot be called from interrupt service routines.
Note
MUST REMAIN UNCHANGED: osMutexRelease shall be consistent in every CMSIS-RTOS.

Release a mutex that was obtained with osMutexWait. Other threads that currently wait for the same mutex will be now put into the state READY.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4209 of file os-c-wrapper.cpp.

4210{
4212 {
4213 return osErrorISR;
4214 }
4215
4216 if (mutex_id == nullptr)
4217 {
4218 return osErrorParameter;
4219 }
4220
4221 result_t res;
4222 res = (reinterpret_cast<rtos::mutex&> (*mutex_id)).unlock ();
4223
4224 if (res == result::ok)
4225 {
4226 return osOK;
4227 }
4228 else if ((res == EPERM) || (res == ENOTRECOVERABLE))
4229 {
4230 return osErrorResource;
4231 }
4232 else
4233 {
4234 return osErrorOS;
4235 }
4236}
@ ok
Function completed; no errors or events occurred.
Definition os-decls.h:179

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, and osOK.

◆ osMutexWait()

osStatus osMutexWait ( osMutexId  mutex_id,
uint32_t  millisec 
)
Parameters
[in]mutex_idmutex ID obtained by osMutexCreate.
[in]millisecTimeout value or 0 in case of no time-out.
Return values
osOKThe mutex has been obtain.
osErrorTimeoutResourcethe mutex could not be obtained in the given time.
osErrorResourceThe mutex could not be obtained when no timeout was specified.
osErrorParameterThe parameter mutex_id is incorrect.
osErrorISRosMutexWait cannot be called from interrupt service routines.
Note
MUST REMAIN UNCHANGED: osMutexWait shall be consistent in every CMSIS-RTOS.

Wait until a mutex becomes available. If no other thread has obtained the mutex, the function instantly returns and blocks the mutex object.

The argument millisec specifies how long the system waits for a mutex. While the system waits the thread that is calling this function is put into the state WAITING. The millisec timeout can have the following values:

  • when millisec is 0, the function returns instantly.
  • when millisec is set to osWaitForever the function will wait for an infinite time until the mutex becomes available.
  • all other values specify a time in millisecond for a timeout.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4139 of file os-c-wrapper.cpp.

4140{
4142 {
4143 return osErrorISR;
4144 }
4145
4146 if (mutex_id == nullptr)
4147 {
4148 return osErrorParameter;
4149 }
4150
4151 result_t ret;
4152 if (millisec == osWaitForever)
4153 {
4154 ret = (reinterpret_cast<rtos::mutex&> (*mutex_id)).lock ();
4155 // osErrorResource:
4156 }
4157 else if (millisec == 0)
4158 {
4159 ret = (reinterpret_cast<rtos::mutex&> (*mutex_id)).try_lock ();
4160 }
4161 else
4162 {
4163 ret = (reinterpret_cast<rtos::mutex&> (*mutex_id))
4164 .timed_lock (
4165 clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)));
4166 // osErrorTimeoutResource:
4167 }
4168
4169 if (ret == result::ok)
4170 {
4171 // osOK: the mutex has been obtained.
4172 return osOK;
4173 }
4174 else if (ret == EWOULDBLOCK)
4175 {
4176 // The mutex could not be obtained when no timeout was specified.
4177 // Only for try_lock().
4178 return osErrorResource;
4179 }
4180 else if (ret == ENOTRECOVERABLE)
4181 {
4182 // The mutex could not be obtained when no timeout was specified.
4183 // Only for lock().
4184 return osErrorResource;
4185 }
4186 else if (ret == ETIMEDOUT)
4187 {
4188 // The mutex could not be obtained in the given time.
4189 // Only for timed_lock().
4191 }
4192 else
4193 {
4194 return osErrorOS;
4195 }
4196
4197 /* NOTREACHED */
4198}
#define osWaitForever
Timeout value.
Definition cmsis_os.h:147

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, osErrorTimeoutResource, osOK, osWaitForever, and os::rtos::clock_systick::ticks_cast().

◆ osPoolAlloc()

void * osPoolAlloc ( osPoolId  pool_id)
Parameters
[in]pool_idmemory pool ID obtain referenced with osPoolCreate.
Returns
address of the allocated memory block or NULL in case of no memory available.
Note
MUST REMAIN UNCHANGED: osPoolAlloc shall be consistent in every CMSIS-RTOS.

◆ osPoolCAlloc()

void * osPoolCAlloc ( osPoolId  pool_id)
Parameters
[in]pool_idmemory pool ID obtain referenced with osPoolCreate.
Returns
address of the allocated memory block or NULL in case of no memory available.
Note
MUST REMAIN UNCHANGED: osPoolCAlloc shall be consistent in every CMSIS-RTOS.

◆ osPoolCreate()

osPoolId osPoolCreate ( const osPoolDef_t pool_def)
Parameters
[in]pool_defmemory pool definition referenced with osPool.
Returns
memory pool ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osPoolCreate shall be consistent in every CMSIS-RTOS.

◆ osPoolFree()

osStatus osPoolFree ( osPoolId  pool_id,
void *  block 
)
Parameters
[in]pool_idmemory pool ID obtain referenced with osPoolCreate.
[in]blockaddress of the allocated memory block that is returned to the memory pool.
Return values
osOKThe memory block is released.
osErrorValueThe block does not belong to the memory pool.
osErrorParameterA parameter is invalid or outside of a permitted range.
Note
MUST REMAIN UNCHANGED: osPoolFree shall be consistent in every CMSIS-RTOS.

◆ osSemaphoreCreate()

osSemaphoreId osSemaphoreCreate ( const osSemaphoreDef_t semaphore_def,
int32_t  count 
)
Parameters
[in]semaphore_defsemaphore definition referenced with osSemaphore.
[in]countnumber of available resources.
Returns
semaphore ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osSemaphoreCreate shall be consistent in every CMSIS-RTOS.

◆ osSemaphoreDelete()

osStatus osSemaphoreDelete ( osSemaphoreId  semaphore_id)
Parameters
[in]semaphore_idsemaphore object referenced with osSemaphoreCreate.
Return values
osOKThe semaphore object has been deleted.
osErrorISRosSemaphoreDelete cannot be called from interrupt service routines.
osErrorResourceThe semaphore object could not be deleted.
osErrorParameterThe parameter semaphore_id is incorrect.
Note
MUST REMAIN UNCHANGED: osSemaphoreDelete shall be consistent in every CMSIS-RTOS.

◆ osSemaphoreRelease()

osStatus osSemaphoreRelease ( osSemaphoreId  semaphore_id)
Parameters
[in]semaphore_idsemaphore object referenced with osSemaphoreCreate.
Return values
osOKThe semaphore has been released.
osErrorResourceAll tokens have already been released.
osErrorParameterThe parameter semaphore_id is incorrect.
Note
MUST REMAIN UNCHANGED: osSemaphoreRelease shall be consistent in every CMSIS-RTOS.

◆ osSemaphoreWait()

int32_t osSemaphoreWait ( osSemaphoreId  semaphore_id,
uint32_t  millisec 
)
Parameters
[in]semaphore_idsemaphore object referenced with osSemaphoreCreate.
[in]millisecTimeout value or 0 in case of no time-out.
Returns
number of available tokens, or -1 in case of incorrect parameters.
Note
MUST REMAIN UNCHANGED: osSemaphoreWait shall be consistent in every CMSIS-RTOS.

◆ osSignalClear()

int32_t osSignalClear ( osThreadId  thread_id,
int32_t  signals 
)
Parameters
[in]thread_idthread ID obtained by osThreadCreate or osThreadGetId.
[in]signalsspecifies the signal flags of the thread that shall be cleared.
Returns
previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters or call from ISR.
Note
MUST REMAIN UNCHANGED: osSignalClear shall be consistent in every CMSIS-RTOS.

Clear the signal flags of an active thread.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3970 of file os-c-wrapper.cpp.

3971{
3972 if (thread_id == nullptr)
3973 {
3974 return (int32_t)0x80000000;
3975 }
3976
3977 if (interrupts::in_handler_mode () || (signals == 0))
3978 {
3979 return (int32_t)0x80000000;
3980 }
3981
3982 flags::mask_t sig;
3983
3984#if defined(OS_INCLUDE_RTOS_THREAD_PUBLIC_FLAGS_CLEAR)
3985 ((thread*)(thread_id))->flags_clear ((flags::mask_t)signals, &sig);
3986#else
3987 assert (((thread*)(thread_id)) == &this_thread::thread ());
3988 // IGNORE THREAD ID!
3989 this_thread::flags_clear ((flags::mask_t)signals, &sig);
3990#endif
3991 return (int32_t)sig;
3992}
Standard thread.
uint32_t mask_t
Type of variables holding flags masks.
Definition os-decls.h:266

References os::rtos::interrupts::in_handler_mode().

◆ osSignalSet()

int32_t osSignalSet ( osThreadId  thread_id,
int32_t  signals 
)
Parameters
[in]thread_idthread ID obtained by osThreadCreate or osThreadGetId.
[in]signalsspecifies the signal flags of the thread that should be set.
Returns
previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
Note
MUST REMAIN UNCHANGED: osSignalSet shall be consistent in every CMSIS-RTOS.

Set the signal flags of an active thread.

Note
Can be invoked from Interrupt Service Routines.

Definition at line 3946 of file os-c-wrapper.cpp.

3947{
3948 if (thread_id == nullptr)
3949 {
3950 return (int32_t)0x80000000;
3951 }
3952
3953 if (signals == (int32_t)0x80000000)
3954 {
3955 return (int32_t)0x80000000;
3956 }
3957
3958 flags::mask_t osig;
3959 ((thread*)(thread_id))->flags_raise ((flags::mask_t)signals, &osig);
3960 return (int32_t)osig;
3961}

◆ osSignalWait()

osEvent osSignalWait ( int32_t  signals,
uint32_t  millisec 
)
Parameters
[in]signalswait until all specified signal flags set or 0 for any single signal flag.
[in]millisecTimeout value or 0 in case of no time-out.
Return values
osOKNo signal received when the timeout value millisec was 0.
osEventTimeoutSignal not occurred within timeout.
osEventSignalSignal occurred, value.signals contains the signal flags; these signal flags are cleared.
osErrorValueThe value signals is outside of the permitted range.
osErrorISRosSignalWait cannot be called from interrupt service routines.
Note
MUST REMAIN UNCHANGED: osSignalWait shall be consistent in every CMSIS-RTOS.

Suspend the execution of the current RUNNING thread until all specified signal flags with the parameter signals are set. When the parameter signals is 0 the current RUNNING thread is suspended until any signal is set. When these signal flags are already set, the function returns instantly. Otherwise the thread is put into the state WAITING. Signal flags that are reported as event are automatically cleared.

The argument millisec specifies how long the system waits for the specified signal flags. While the system waits the tread calling this function is put into the state WAITING. The timeout value can have the following values:

  • when millisec is 0, the function returns instantly.
  • when millisec is set to osWaitForever the function will wait an infinite time until a specified signal is set.
  • all other values specify a time in millisecond for a timeout.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4023 of file os-c-wrapper.cpp.

4024{
4025 osEvent event;
4026
4028 {
4029 event.status = osErrorISR;
4030 return event;
4031 }
4032
4033 if ((uint32_t)signals & 0x80000000)
4034 {
4035 event.status = osErrorValue;
4036 return event;
4037 }
4038
4039 result_t res;
4040 if (millisec == osWaitForever)
4041 {
4042 res = this_thread::flags_wait ((flags::mask_t)signals,
4043 (flags::mask_t*)&event.value.signals);
4044 }
4045 else if (millisec == 0)
4046 {
4047 res = this_thread::flags_try_wait ((flags::mask_t)signals,
4048 (flags::mask_t*)&event.value.signals);
4049 }
4050 else
4051 {
4052 res = this_thread::flags_timed_wait (
4053 (flags::mask_t)signals,
4054 clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)),
4055 (flags::mask_t*)&event.value.signals);
4056 }
4057
4058 if (res == result::ok)
4059 {
4060 event.status = osEventSignal;
4061 }
4062 else if (res == EWOULDBLOCK)
4063 {
4064 event.status = osOK; // Only for try_flags_wait().
4065 }
4066 else if (res == ETIMEDOUT)
4067 {
4068 event.status = osEventTimeout; // Only for timed_flags_wait().
4069 }
4070 else if (res == EPERM)
4071 {
4072 event.status = osErrorISR;
4073 }
4074 else if (res == EINVAL)
4075 {
4076 event.status = osErrorValue;
4077 }
4078 else
4079 {
4080 event.status = osErrorOS;
4081 }
4082
4083 return event;
4084}
Event structure contains detailed information about an event.
Definition cmsis_os.h:378
osStatus status
Definition cmsis_os.h:379
int32_t signals
Definition cmsis_os.h:384
union osEvent::@0 value

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorValue, osEventSignal, osEventTimeout, osOK, osWaitForever, osEvent::signals, osEvent::status, os::rtos::clock_systick::ticks_cast(), and osEvent::value.

◆ osThreadCreate()

osThreadId osThreadCreate ( const osThreadDef_t thread_def,
void *  args 
)
Parameters
[in]thread_defThread definition referenced with osThread.
[in]argsPointer that is passed to the thread function as start argument.
Returns
thread ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osThreadCreate shall be consistent in every CMSIS-RTOS.

Find a free slot in the array of thread definitions and initialise the thread.

Start the thread function by adding it to the Active Threads list and set it to state READY. The thread function receives the argument pointer as function argument when the function is started. When the priority of the created thread function is higher than the current RUNNING thread, the created thread function starts instantly and becomes the new RUNNING thread.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3493 of file os-c-wrapper.cpp.

3494{
3496 {
3497 return nullptr;
3498 }
3499
3500 if (thread_def == nullptr)
3501 {
3502 return nullptr;
3503 }
3504
3505 thread::attributes attr;
3506 attr.th_priority = thread_def->tpriority;
3507 attr.th_stack_size_bytes = thread_def->stacksize;
3508
3509 // Creating thread with invalid priority should fail (validator requirement).
3510 if (thread_def->tpriority >= osPriorityError)
3511 {
3512 return nullptr;
3513 }
3514
3515 // Find a free slot in the tread definitions array.
3516 for (uint32_t i = 0; i < thread_def->instances; ++i)
3517 {
3518#pragma GCC diagnostic push
3519#if defined(__clang__)
3520#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
3521#endif
3522 thread* th = (thread*)&thread_def->data[i];
3523 if (th->state () == thread::state::undefined
3524 || th->state () == thread::state::destroyed)
3525 {
3526 if (attr.th_stack_size_bytes > 0)
3527 {
3528 attr.th_stack_address
3529 = &thread_def->stack[(i)
3530 * ((thread_def->stacksize
3531 + sizeof (uint64_t) - 1)
3532 / sizeof (uint64_t))];
3533 }
3534#pragma GCC diagnostic push
3535#if defined(__clang__)
3536#pragma clang diagnostic ignored "-Wcast-function-type"
3537#elif defined(__GNUC__)
3538#pragma GCC diagnostic ignored "-Wcast-function-type"
3539#endif
3540 new (th)
3541 thread (thread_def->name,
3542 reinterpret_cast<thread::func_t> (thread_def->pthread),
3543 args, attr);
3544#pragma GCC diagnostic pop
3545
3546 // No need to yield here, already done by constructor.
3547 return reinterpret_cast<osThreadId> (th);
3548 }
3549#pragma GCC diagnostic pop
3550 }
3551 return nullptr;
3552}
@ destroyed
Terminated and resources (like stack) released.
Definition os-thread.h:398
@ undefined
Used to catch uninitialised threads.
Definition os-thread.h:378
os_pthread pthread
Definition cmsis_os.h:279
uint64_t * stack
Definition cmsis_os.h:284
const char * name
Definition cmsis_os.h:278
osPriority tpriority
Definition cmsis_os.h:280
uint32_t stacksize
Definition cmsis_os.h:282
osThread * data
Definition cmsis_os.h:283
uint32_t instances
Definition cmsis_os.h:281

References os_thread_def::data, os::rtos::thread::state::destroyed, os::rtos::interrupts::in_handler_mode(), os_thread_def::instances, os_thread_def::name, osPriorityError, os_thread_def::pthread, os_thread_def::stack, os_thread_def::stacksize, os::rtos::thread::attributes::th_priority, os::rtos::thread::attributes::th_stack_address, os::rtos::thread::attributes::th_stack_size_bytes, os_thread_def::tpriority, and os::rtos::thread::state::undefined.

◆ osThreadGetId()

osThreadId osThreadGetId ( void  )
Returns
thread ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osThreadGetId shall be consistent in every CMSIS-RTOS.

Get the thread ID of the current running thread.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3561 of file os-c-wrapper.cpp.

3562{
3564 {
3565 return nullptr;
3566 }
3567
3568 return reinterpret_cast<osThreadId> (&this_thread::thread ());
3569}

References os::rtos::interrupts::in_handler_mode().

◆ osThreadGetPriority()

osPriority osThreadGetPriority ( osThreadId  thread_id)
Parameters
[in]thread_idthread ID obtained by osThreadCreate or osThreadGetId.
Returns
The current priority value of the thread, or osPriorityError if error.
Note
MUST REMAIN UNCHANGED: osThreadGetPriority shall be consistent in every CMSIS-RTOS.

Get the priority of an active thread. In case of a failure the value osPriorityError is returned.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3699 of file os-c-wrapper.cpp.

3700{
3702 {
3703 return osPriorityError;
3704 }
3705
3706 if (thread_id == nullptr)
3707 {
3708 return osPriorityError;
3709 }
3710
3711 // Call C++ accessor.
3712 thread::priority_t prio
3713 = (reinterpret_cast<rtos::thread&> (*thread_id)).priority ();
3714 return static_cast<osPriority> (prio);
3715}
POSIX compliant thread, using the default RTOS allocator.
Definition os-thread.h:251

References os::rtos::interrupts::in_handler_mode(), and osPriorityError.

◆ osThreadSetPriority()

osStatus osThreadSetPriority ( osThreadId  thread_id,
osPriority  priority 
)
Parameters
[in]thread_idthread ID obtained by osThreadCreate or osThreadGetId.
[in]prioritynew priority value for the thread function.
Return values
osOKThe priority of the specified thread has been successfully changed.
osErrorParameterthread_id is incorrect.
osErrorValueincorrect priority value.
osErrorResourcethread_id refers to a thread that is not an active thread.
osErrorISRosThreadSetPriority cannot be called from interrupt service routines.
Note
MUST REMAIN UNCHANGED: osThreadSetPriority shall be consistent in every CMSIS-RTOS.

Change the priority of a running thread. There is no need for an extra yield after it, if the priorities require, there is an implicit reschedule.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3645 of file os-c-wrapper.cpp.

3646{
3648 {
3649 return osErrorISR;
3650 }
3651
3652 if (thread_id == nullptr)
3653 {
3654 return osErrorParameter;
3655 }
3656
3657 thread::state_t state
3658 = (reinterpret_cast<rtos::thread&> (*thread_id)).state ();
3659 if (state == thread::state::undefined || state >= thread::state::destroyed)
3660 {
3661 return osErrorResource;
3662 }
3663
3664 if (priority < osPriorityIdle || priority >= osPriorityError)
3665 {
3666 return osErrorValue;
3667 }
3668
3669 // Call C++ mutator.
3670 thread::priority_t prio = static_cast<thread::priority_t> (priority);
3671 result_t res
3672 = ((reinterpret_cast<rtos::thread&> (*thread_id)).priority (prio));
3673
3674 // A mandatory yield is needed here, must be done
3675 // by the implementation.
3676
3677 if (res == result::ok)
3678 {
3679 return osOK;
3680 }
3681 else if (res == EINVAL)
3682 {
3683 return osErrorValue;
3684 }
3685 else
3686 {
3687 return osErrorOS;
3688 }
3689}

References os::rtos::thread::state::destroyed, os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, osErrorValue, osOK, osPriorityError, and os::rtos::thread::state::undefined.

◆ osThreadTerminate()

osStatus osThreadTerminate ( osThreadId  thread_id)
Parameters
[in]thread_idthread ID obtained by osThreadCreate or osThreadGetId.
Return values
osOKThe specified thread has been successfully terminated.
osErrorParameterthread_id is incorrect.
osErrorResourcethread_id refers to a thread that is not an active thread.
osErrorISRosThreadTerminate cannot be called from interrupt service routines.
Note
MUST REMAIN UNCHANGED: osThreadTerminate shall be consistent in every CMSIS-RTOS.

Remove the thread function from the active thread list. If the thread is currently RUNNING the execution will stop.

Note
In case that osThreadTerminate terminates the currently running task, the function never returns and other threads that are in the READY state are started.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3583 of file os-c-wrapper.cpp.

3584{
3586 {
3587 return osErrorISR;
3588 }
3589
3590 if (thread_id == nullptr)
3591 {
3592 return osErrorParameter;
3593 }
3594
3595 thread::state_t state
3596 = (reinterpret_cast<rtos::thread&> (*thread_id)).state ();
3597 if (state == thread::state::undefined)
3598 {
3599 return osErrorResource;
3600 }
3601
3602 if ((reinterpret_cast<thread*> (thread_id)) == &this_thread::thread ())
3603 {
3604 this_thread::exit ();
3605 /* NOTREACHED */
3606 }
3607 else
3608 {
3609 (reinterpret_cast<rtos::thread&> (*thread_id)).kill ();
3610 }
3611
3612 return osOK;
3613}
int kill(pid_t pid, int sig)

References os::rtos::interrupts::in_handler_mode(), kill(), osErrorISR, osErrorParameter, osErrorResource, osOK, and os::rtos::thread::state::undefined.

◆ osThreadYield()

osStatus osThreadYield ( void  )
Return values
osOKThe function has been correctly executed.
osErrorISRThe function cannot be called from interrupt service routines.
Note
MUST REMAIN UNCHANGED: osThreadYield shall be consistent in every CMSIS-RTOS.

Pass control to the next thread that is in state READY. If there is no other thread in the state READY, the current thread continues execution and no thread switching occurs.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3624 of file os-c-wrapper.cpp.

3625{
3627 {
3628 return osErrorISR;
3629 }
3630
3632
3633 return osOK;
3634}
void yield() noexcept
Yield the CPU to the next ready thread.

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osOK, and this_thread::yield().

◆ osTimerCreate()

osTimerId osTimerCreate ( const osTimerDef_t timer_def,
os_timer_type  type,
void *  args 
)
Parameters
[in]timer_defTimer object referenced with osTimer.
[in]typeosTimerOnce for one-shot or osTimerPeriodic for periodic behavior.
[in]argsArgument to the timer call back function.
Returns
timer ID for reference by other functions or NULL in case of error.
Note
MUST REMAIN UNCHANGED: osTimerCreate shall be consistent in every CMSIS-RTOS.

Create a one-shot or periodic timer and associate it with a callback function argument. The timer is initially stopped and must be started with osTimerStart().

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3822 of file os-c-wrapper.cpp.

3823{
3825 {
3826 return nullptr;
3827 }
3828
3829 if (timer_def == nullptr)
3830 {
3831 return nullptr;
3832 }
3833
3834 timer::attributes attr;
3835 attr.tm_type = (timer::type_t)type;
3836
3837#pragma GCC diagnostic push
3838#if defined(__clang__)
3839#pragma clang diagnostic ignored "-Wcast-function-type-strict"
3840#endif
3841 new ((void*)timer_def->data)
3842 timer (timer_def->name, (timer::func_t)timer_def->ptimer,
3843 (timer::func_args_t)args, attr);
3844#pragma GCC diagnostic pop
3845
3846 return reinterpret_cast<osTimerId> (timer_def->data);
3847}
Timer attributes.
Definition os-timer.h:131
type_t tm_type
Timer type attribute.
Definition os-timer.h:187
User single-shot or periodic timer.
Definition os-timer.h:56
void * func_args_t
Timer call back function arguments.
Definition os-timer.h:62
void(*)(func_args_t args) func_t
Entry point of a timer call back function.
Definition os-timer.h:68
uint8_t type_t
Type of of variables holding timer run types.
Definition os-timer.h:74
const char * name
Definition cmsis_os.h:295
osTimer * data
Definition cmsis_os.h:297
os_ptimer ptimer
Definition cmsis_os.h:296

References os_timer_def::data, os::rtos::interrupts::in_handler_mode(), os_timer_def::name, os_timer_def::ptimer, and os::rtos::timer::attributes::tm_type.

◆ osTimerDelete()

osStatus osTimerDelete ( osTimerId  timer_id)
Parameters
[in]timer_idtimer ID obtained by osTimerCreate.
Return values
osOKThe specified timer has been deleted.
osErrorISRosTimerDelete cannot be called from interrupt service routines.
osErrorParametertimer_id is incorrect.
Note
MUST REMAIN UNCHANGED: osTimerDelete shall be consistent in every CMSIS-RTOS.

Delete the timer object that was created by osTimerCreate.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3920 of file os-c-wrapper.cpp.

3921{
3923 {
3924 return osErrorISR;
3925 }
3926
3927 if (timer_id == nullptr)
3928 {
3929 return osErrorParameter;
3930 }
3931
3932 (reinterpret_cast<rtos::timer&> (*timer_id)).~timer ();
3933 return osOK;
3934}

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osErrorParameter, and osOK.

◆ osTimerStart()

osStatus osTimerStart ( osTimerId  timer_id,
uint32_t  millisec 
)
Parameters
[in]timer_idtimer ID obtained by osTimerCreate.
[in]millisecTimeout value "time delay" value of the timer.
Return values
osOKThe specified timer has been started or restarted.
osErrorISRosTimerStart cannot be called from interrupt service routines.
osErrorParametertimer_id is incorrect.
Note
MUST REMAIN UNCHANGED: osTimerStart shall be consistent in every CMSIS-RTOS.

Start or restart the timer.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3856 of file os-c-wrapper.cpp.

3857{
3859 {
3860 return osErrorISR;
3861 }
3862
3863 if (timer_id == nullptr)
3864 {
3865 return osErrorParameter;
3866 }
3867
3868 result_t res
3869 = (reinterpret_cast<rtos::timer&> (*timer_id))
3870 .start (clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)));
3871
3872 if (res == result::ok)
3873 {
3874 return osOK;
3875 }
3876 else
3877 {
3878 return osErrorOS;
3879 }
3880}

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osOK, and os::rtos::clock_systick::ticks_cast().

◆ osTimerStop()

osStatus osTimerStop ( osTimerId  timer_id)
Parameters
[in]timer_idtimer ID obtained by osTimerCreate.
Return values
osOKthe specified timer has been stopped.
osErrorISRosTimerStop cannot be called from interrupt service routines.
osErrorParametertimer_id is incorrect.
osErrorResourcethe timer is not started.
Note
MUST REMAIN UNCHANGED: osTimerStop shall be consistent in every CMSIS-RTOS.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3886 of file os-c-wrapper.cpp.

3887{
3889 {
3890 return osErrorISR;
3891 }
3892
3893 if (timer_id == nullptr)
3894 {
3895 return osErrorParameter;
3896 }
3897
3898 result_t res = (reinterpret_cast<rtos::timer&> (*timer_id)).stop ();
3899 if (res == result::ok)
3900 {
3901 return osOK;
3902 }
3903 else if (res == EAGAIN)
3904 {
3905 return osErrorResource;
3906 }
3907 else
3908 {
3909 return osErrorOS;
3910 }
3911}

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, and osOK.

◆ osWait()

osEvent osWait ( uint32_t  millisec)
Parameters
[in]millisecTimeout value or 0 in case of no time-out.
Return values
osEventSignalA signal event occurred and is returned.
osEventMessageA message event occurred and is returned.
osEventMailA mail event occurred and is returned.
osEventTimeoutThe time delay is executed.
osErrorISRosWait() cannot be called from interrupt service routines.
Note
MUST REMAIN UNCHANGED: osWait shall be consistent in every CMSIS-RTOS.