1 Star 0 Fork 4.9K

Cain / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CMSIS.md 185.73 KB
一键复制 编辑 原始数据 按行查看 历史
wenjun 提交于 2020-09-08 10:08 . add OpenHarmony 1.0 baseline

CMSIS

Overview

Provides standard, universal real-time operating system (RTOS) APIs.

These APIs comply with ARM CMSIS and are used for thread management, timer management, inter-process communications, and semaphores.

Since:

1.0

Version:

1.0

Summary

Data Structures

Data Structure Name

Description

osVersion_t

Describes the system version.

osThreadAttr_t

Describes thread attributes.

osTimerAttr_t

Describes timer attributes.

osEventFlagsAttr_t

Describes event attributes.

osMutexAttr_t

Describes mutex attributes.

osSemaphoreAttr_t

Describes semaphore attributes.

osMessageQueueAttr_t

Describes message queue attributes.

Macros

Macro Name and Value

Description

osWaitForever   0xFFFFFFFFU

Indicates that the RTOS waits forever unless an event flag is received.

osNoWait   0x0U

Indicates that the RTOS does not wait.

osFlagsWaitAny   0x00000000U

Indicates that the RTOS waits until any event flag is triggered.

osFlagsWaitAll   0x00000001U

Indicates that the system waits until all event flags are triggered.

osFlagsNoClear   0x00000002U

Indicates that defined flags are not cleared.

osFlagsError   0x80000000U

Indicates a flag error.

osFlagsErrorUnknown   0xFFFFFFFFU

Indicates an unknown error.

osFlagsErrorTimeout   0xFFFFFFFEU

Indicates a timeout.

osFlagsErrorResource   0xFFFFFFFDU

Indicates a resource error.

osFlagsErrorParameter   0xFFFFFFFCU

Indicates an incorrect parameter.

Typedefs

Typedef Name

Description

osThreadFunc_t) (void *argument)

typedef void(* 

Callback for thread scheduling.

osTimerFunc_t) (void *argument)

typedef void(* 

Callback for timer triggering.

osThreadId_t

typedef void * 

Identifies a thread.

osTimerId_t

typedef void * 

Identifies a timer.

osEventFlagsId_t

typedef void * 

Identifies an event flag.

osMutexId_t

typedef void * 

Identifies a mutex.

osSemaphoreId_t

typedef void * 

Identifies a semaphore object.

osMessageQueueId_t

typedef void * 

Identifies a message queue.

TZ_ModuleId_t

typedef uint32_t 

Identifies a TrustZone module call process.

Enumerations

Enumeration Name

Description

osKernelState_t {   osKernelInactive = 0, osKernelReady = 1, osKernelRunning = 2, osKernelLocked = 3,   osKernelSuspended = 4, osKernelError = -1, osKernelReserved = 0x7FFFFFFFU }

Enumerates kernel states.

osThreadState_t {   osThreadInactive = 0, osThreadReady = 1, osThreadRunning = 2, osThreadBlocked = 3,   osThreadTerminated = 4, osThreadError = -1, osThreadReserved = 0x7FFFFFFF }

Enumerates thread states.

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 }

Enumerates thread priorities.

osTimerType_t { osTimerOnce = 0, osTimerPeriodic = 1 }

Enumerates timer types.

os_timer_rouses_type { osTimerRousesIgnore = 0, osTimerRousesAllow = 1 }

Enumerates timer permissions.

os_timer_align_type { osTimerAlignIgnore = 0, osTimerAlignAllow = 1 }

Enumerates timer alignment modes.

osStatus_t {   osOK = 0, osError = -1, osErrorTimeout = -2, osErrorResource = -3,   osErrorParameter = -4, osErrorNoMemory = -5, osErrorISR = -6, osStatusReserved = 0x7FFFFFFF }

Enumerates return values of CMSIS-RTOS.

Functions

Function Name

Description

osKernelInitialize (void)

osStatus_t 

Initializes the RTOS kernel.

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

osStatus_t 

Obtains the system version and name.

osKernelGetState (void)

osKernelState_t 

Obtains the kernel state.

osKernelStart (void)

osStatus_t 

Starts the kernel.

osKernelLock (void)

int32_t 

Locks the kernel.

osKernelUnlock (void)

int32_t 

Unlocks the kernel.

osKernelRestoreLock (int32_t lock)

int32_t 

Restores the previous lock state of the kernel.

osKernelGetTickFreq (void)

uint32_t 

Obtains the number of kernel ticks per second.

osKernelGetSysTimerCount (void)

uint32_t 

Obtains the kernel system timer.

osKernelGetSysTimerFreq (void)

uint32_t 

Obtains the frequency of the system timer.

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

osThreadId_t 

Creates an active thread.

osThreadGetName (osThreadId_t thread_id)

const char * 

Obtains the name of a thread.

osThreadGetId (void)

osThreadId_t 

Obtains the ID of the currently running thread.

osThreadGetState (osThreadId_t thread_id)

osThreadState_t 

Obtains the state of a thread.

osThreadGetStackSize (osThreadId_t thread_id)

uint32_t 

Obtains the stack size of a thread.

osThreadGetStackSpace (osThreadId_t thread_id)

uint32_t 

Obtains the size of the available stack space for a thread based on the stack watermark.

osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority)

osStatus_t 

Changes the priority of a thread.

osThreadGetPriority (osThreadId_t thread_id)

osPriority_t 

Gets the prority of an active thread.

osThreadYield (void)

osStatus_t 

Sets the currently running thread to the ready state.

osThreadSuspend (osThreadId_t thread_id)

osStatus_t 

Suspends a thread.

osThreadResume (osThreadId_t thread_id)

osStatus_t 

Resumes a thread from the suspended state.

osThreadTerminate (osThreadId_t thread_id)

osStatus_t 

Terminates a thread.

osThreadGetCount (void)

uint32_t 

Obtains the number of active threads.

osDelay (uint32_t ticks)

osStatus_t 

Waits for a period of time.

osDelayUntil (uint64_t ticks)

osStatus_t 

Waits until a specified time arrives.

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

osTimerId_t 

Creates and initializes a timer.

osTimerStart (osTimerId_t timer_id, uint32_t ticks)

osStatus_t 

Starts or restarts a timer.

osTimerStop (osTimerId_t timer_id)

osStatus_t 

Stops a timer.

osTimerIsRunning (osTimerId_t timer_id)

uint32_t 

Checks whether a timer is running.

osTimerDelete (osTimerId_t timer_id)

osStatus_t 

Deletes a timer.

osEventFlagsNew (const osEventFlagsAttr_t *attr)

osEventFlagsId_t 

Creates and initializes an event flags object.

osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags)

uint32_t 

Sets event flags.

osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags)

uint32_t 

Clears event flags.

osEventFlagsGet (osEventFlagsId_t ef_id)

uint32_t 

Obtains event flags.

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

uint32_t 

Waits for event flags to trigger.

osEventFlagsDelete (osEventFlagsId_t ef_id)

osStatus_t 

Deletes an event flags object.

osMutexNew (const osMutexAttr_t *attr)

osMutexId_t 

Creates and initializes a mutex.

osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout)

osStatus_t 

Obtains a mutex.

osMutexRelease (osMutexId_t mutex_id)

osStatus_t 

Releases a mutex.

osMutexGetOwner (osMutexId_t mutex_id)

osThreadId_t 

Obtains the thread ID of the currently acquired mutex.

osMutexDelete (osMutexId_t mutex_id)

osStatus_t 

Deletes a mutex.

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

osSemaphoreId_t 

Creates and initializes a semaphore object.

osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout)

osStatus_t 

Acquires a token of a semaphore object.

osSemaphoreRelease (osSemaphoreId_t semaphore_id)

osStatus_t 

Releases a token of a semaphore object.

osSemaphoreGetCount (osSemaphoreId_t semaphore_id)

uint32_t 

Obtains the number of available tokens of a semaphore object.

osSemaphoreDelete (osSemaphoreId_t semaphore_id)

osStatus_t 

Deletes a semaphore object.

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

osMessageQueueId_t 

Creates and initializes a message queue.

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

osStatus_t 

Places a message in a message queue.

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

osStatus_t 

Obtains a message in a message queue.

osMessageQueueGetCapacity (osMessageQueueId_t mq_id)

uint32_t 

Obtains the maximum number of messages that can be placed in a message queue.

osMessageQueueGetMsgSize (osMessageQueueId_t mq_id)

uint32_t 

Obtains the maximum size of messages that can be placed in a message queue.

osMessageQueueGetCount (osMessageQueueId_t mq_id)

uint32_t 

Obtains the number of queued messages in a message queue.

osMessageQueueGetSpace (osMessageQueueId_t mq_id)

uint32_t 

Obtains the number of available slots for messages in a message queue.

osMessageQueueDelete (osMessageQueueId_t mq_id)

osStatus_t 

Deletes a message queue.

Details

Macro Definition Documentation

osFlagsError

#define osFlagsError   0x80000000U

Description:

Indicates a flag error.

osFlagsErrorParameter

#define osFlagsErrorParameter   0xFFFFFFFCU

Description:

Indicates an incorrect parameter.

osFlagsErrorResource

#define osFlagsErrorResource   0xFFFFFFFDU

Description:

Indicates a resource error.

osFlagsErrorTimeout

#define osFlagsErrorTimeout   0xFFFFFFFEU

Description:

Indicates a timeout.

osFlagsErrorUnknown

#define osFlagsErrorUnknown   0xFFFFFFFFU

Description:

Indicates an unknown error.

osFlagsNoClear

#define osFlagsNoClear   0x00000002U

Description:

Indicates that defined flags are not cleared.

osFlagsWaitAll

#define osFlagsWaitAll   0x00000001U

Description:

Indicates that the system waits until all event flags are triggered.

osFlagsWaitAny

#define osFlagsWaitAny   0x00000000U

Description:

Indicates that the RTOS waits until any event flag is triggered.

osNoWait

#define osNoWait   0x0U

Description:

Indicates that the RTOS does not wait.

osWaitForever

#define osWaitForever   0xFFFFFFFFU

Description:

Indicates that the RTOS waits forever unless an event flag is received.

Typedef Documentation

osEventFlagsId_t

typedef void* [osEventFlagsId_t](CMSIS.md#gaf0a3ba8f502ca6581ed1009005c0dadd)

Description:

Identifies an event flag.

osMessageQueueId_t

typedef void* [osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317)

Description:

Identifies a message queue.

osMutexId_t

typedef void* [osMutexId_t](CMSIS.md#ga29b7ba721f4fe0b11c84c55d079cc3e7)

Description:

Identifies a mutex.

osSemaphoreId_t

typedef void* [osSemaphoreId_t](CMSIS.md#ga5abc2c02a86678b63a711e13894ac5b1)

Description:

Identifies a semaphore object.

osThreadFunc_t

typedef void(* osThreadFunc_t) (void *argument)

Description:

Callback for thread scheduling.

osThreadId_t

typedef void* [osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217)

Description:

Identifies a thread.

osTimerFunc_t

typedef void(* osTimerFunc_t) (void *argument)

Description:

Callback for timer triggering.

osTimerId_t

typedef void* [osTimerId_t](CMSIS.md#gac2000ac2a8c6740700fd8e6c938cff44)

Description:

Identifies a timer.

TZ_ModuleId_t

typedef uint32_t [TZ_ModuleId_t](CMSIS.md#gad5ef21485fe5f60263bc0b48006202cb)

Description:

Identifies a TrustZone module call process.

Enumeration Type Documentation

os_timer_align_type

enum [os_timer_align_type](CMSIS.md#ga3d617b70715d7fb2c7c6f06809ee3913)

Description:

Enumerates timer alignment modes.

Enumerator

Description

osTimerAlignIgnore 

The timer ignores alignment.

osTimerAlignAllow 

The timer allows alignment.

os_timer_rouses_type

enum [os_timer_rouses_type](CMSIS.md#ga6274cbe33c6db824bbc40dc6eaa8e578)

Description:

Enumerates timer permissions.

Enumerator

Description

osTimerRousesIgnore 

The timer is not allowed to wake up the RTOS.

osTimerRousesAllow 

The timer is allowed to wake up the RTOS.

osKernelState_t

enum [osKernelState_t](CMSIS.md#ga08326469274b668140ca934b168a5ad4)

Description:

Enumerates kernel states.

Enumerator

Description

osKernelInactive 

The kernel is inactive.

osKernelReady 

The kernel is ready.

osKernelRunning 

The kernel is running.

osKernelLocked 

The kernel is locked.

osKernelSuspended 

The kernel is suspended.

osKernelError 

The kernel is abnormal.

osKernelReserved 

Reserved

osPriority_t

enum [osPriority_t](CMSIS.md#gad4e3e0971b41f2d17584a8c6837342ec)

Description:

Enumerates thread priorities.

Enumerator

Description

osPriorityNone 

Undefined

osPriorityIdle 

Reserved for idle threads

osPriorityLow 

Low (unsupported)

osPriorityLow1 

Low + 1

osPriorityLow2 

Low + 2

osPriorityLow3 

Low + 3

osPriorityLow4 

Low + 4

osPriorityLow5 

Low + 5

osPriorityLow6 

Low + 6

osPriorityLow7 

Low + 7

osPriorityBelowNormal 

Below normal

osPriorityBelowNormal1 

Below normal + 1

osPriorityBelowNormal2 

Below normal + 2

osPriorityBelowNormal3 

Below normal + 3

osPriorityBelowNormal4 

Below normal + 4

osPriorityBelowNormal5 

Below normal + 5

osPriorityBelowNormal6 

Below normal + 6

osPriorityBelowNormal7 

Below normal + 7 (unsupported)

osPriorityNormal 

Normal (unsupported)

osPriorityNormal1 

Normal + 1 (unsupported)

osPriorityNormal2 

Normal + 2 (unsupported)

osPriorityNormal3 

Normal + 3 (unsupported)

osPriorityNormal4 

Normal + 4 (unsupported)

osPriorityNormal5 

Normal + 5 (unsupported)

osPriorityNormal6 

Normal + 6 (unsupported)

osPriorityNormal7 

Normal + 7 (unsupported)

osPriorityAboveNormal 

Above normal (unsupported)

osPriorityAboveNormal1 

Above normal + 1 (unsupported)

osPriorityAboveNormal2 

Above normal + 2 (unsupported)

osPriorityAboveNormal3 

Above normal + 3 (unsupported)

osPriorityAboveNormal4 

Above normal + 4 (unsupported)

osPriorityAboveNormal5 

Above normal + 5 (unsupported)

osPriorityAboveNormal6 

Above normal + 6 (unsupported)

osPriorityAboveNormal7 

Above normal + 7 (unsupported)

osPriorityHigh 

High (unsupported)

osPriorityHigh1 

High + 1 (unsupported)

osPriorityHigh2 

High + 2 (unsupported)

osPriorityHigh3 

High + 3 (unsupported)

osPriorityHigh4 

High + 4 (unsupported)

osPriorityHigh5 

High + 5 (unsupported)

osPriorityHigh6 

High + 6 (unsupported)

osPriorityHigh7 

High + 7 (unsupported)

osPriorityRealtime 

Real-time (unsupported)

osPriorityRealtime1 

Real-time + 1 (unsupported)

osPriorityRealtime2 

Real-time + 2 (unsupported)

osPriorityRealtime3 

Real-time + 3 (unsupported)

osPriorityRealtime4 

Real-time + 4 (unsupported)

osPriorityRealtime5 

Real-time + 5 (unsupported)

osPriorityRealtime6 

Real-time + 6 (unsupported)

osPriorityRealtime7 

Real-time + 7 (unsupported)

osPriorityISR 

Reserved for ISR deferred threads (unsupported)

osPriorityError 

Invalid

osPriorityReserved 

Reserved. It enables the compiler to identify enumeration variables as 32-bit numbers and prevents the enumeration variables from being optimized.

osStatus_t

enum [osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e)

Description:

Enumerates return values of CMSIS-RTOS.

Enumerator

Description

osOK 

Operation completed successfully

osError 

Unspecified error

osErrorTimeout 

Timeout

osErrorResource 

Resource error

osErrorParameter 

Incorrect parameter

osErrorNoMemory 

Insufficient memory

osErrorISR 

Service interruption

osStatusReserved 

Reserved. It is used to prevent the compiler from optimizing enumerations.

osThreadState_t

enum [osThreadState_t](CMSIS.md#gad3dc89e942e38d9f3af858a0269a820d)

Description:

Enumerates thread states.

Enumerator

Description

osThreadInactive 

The thread is inactive.

osThreadReady 

The thread is ready.

osThreadRunning 

The thread is running.

osThreadBlocked 

The thread is blocked.

osThreadTerminated 

The thread is terminated.

osThreadError 

The thread is abnormal.

osThreadReserved 

Reserved

osTimerType_t

enum [osTimerType_t](CMSIS.md#ga7dc24a4c2b90334427081c3da7a71915)

Description:

Enumerates timer types.

Enumerator

Description

osTimerOnce 

One-shot timer

osTimerPeriodic 

Repeating timer

Function Documentation

osDelay()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osDelay (uint32_t ticks)

Description:

Waits for a period of time.

Parameters:

Name

Description

ticks Indicates the number of ticks to wait for.

Returns:

Returns the CMSIS-RTOS running result.

osDelayUntil()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osDelayUntil (uint64_t ticks)

Description:

Waits until a specified time arrives.

Parameters:

Name

Description

ticks Indicates the number of ticks converted from the absolute time.

Returns:

Returns the CMSIS-RTOS running result.

osEventFlagsClear()

uint32_t osEventFlagsClear ([osEventFlagsId_t](CMSIS.md#gaf0a3ba8f502ca6581ed1009005c0dadd) ef_id, uint32_t flags )

Description:

Clears event flags.

Parameters:

Name

Description

ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
flags Indicates the event flags to clear.

Returns:

Returns the event flags; returns osFlagsErrorParameter in the case of an error.

osEventFlagsDelete()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osEventFlagsDelete ([osEventFlagsId_t](CMSIS.md#gaf0a3ba8f502ca6581ed1009005c0dadd) ef_id)

Description:

Deletes an event flags object.

Parameters:

Name

Description

ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.

Returns:

Returns the CMSIS-RTOS running result.

osEventFlagsGet()

uint32_t osEventFlagsGet ([osEventFlagsId_t](CMSIS.md#gaf0a3ba8f502ca6581ed1009005c0dadd) ef_id)

Description:

Obtains event flags.

Parameters:

Name

Description

ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.

Returns:

Returns the event flags triggered.

osEventFlagsNew()

[osEventFlagsId_t](CMSIS.md#gaf0a3ba8f502ca6581ed1009005c0dadd) osEventFlagsNew (const [osEventFlagsAttr_t](osEventFlagsAttr_t.md) * attr)

Description:

Creates and initializes an event flags object.

Parameters:

Name

Description

attr Indicates the pointer to the event flags attributes. This parameter is not used.

Returns:

Returns the event flags ID; returns NULL in the case of an error.

osEventFlagsSet()

uint32_t osEventFlagsSet ([osEventFlagsId_t](CMSIS.md#gaf0a3ba8f502ca6581ed1009005c0dadd) ef_id, uint32_t flags )

Description:

Sets event flags.

Parameters:

Name

Description

ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
flags Indicates the event flags to set.

Returns:

Returns the event flags; returns osFlagsErrorParameter in the case of an error.

osEventFlagsWait()

uint32_t osEventFlagsWait ([osEventFlagsId_t](CMSIS.md#gaf0a3ba8f502ca6581ed1009005c0dadd) ef_id, uint32_t flags, uint32_t options, uint32_t timeout )

Description:

Waits for event flags to trigger.

Parameters:

Name

Description

ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
flags Indicates the event flags to trigger.
options Indicates the configuration of the event flags to trigger.
timeout Indicates the timeout duration.

Returns:

Returns the triggered event flags; returns an error value in the case of an error.

osKernelGetInfo()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osKernelGetInfo ([osVersion_t](osVersion_t.md) * version, char * id_buf, uint32_t id_size )

Description:

Obtains the system version and name.

Parameters:

Name

Description

version Indicates the pointer to the buffer for storing the version.
id_buf Indicates the pointer to the buffer for storing the kernel ID.
id_size Indicates the size of the buffer for storing the kernel ID.

Returns:

Returns the CMSIS-RTOS running result.

osKernelGetState()

[osKernelState_t](CMSIS.md#ga08326469274b668140ca934b168a5ad4) osKernelGetState (void )

Description:

Obtains the kernel state.

Returns:

Returns the kernel state.

osKernelGetSysTimerCount()

uint32_t osKernelGetSysTimerCount (void )

Description:

Obtains the kernel system timer.

Returns:

Returns the kernel system timer.

osKernelGetSysTimerFreq()

uint32_t osKernelGetSysTimerFreq (void )

Description:

Obtains the frequency of the system timer.

Returns:

Returns the system timer frequency.

osKernelGetTickFreq()

uint32_t osKernelGetTickFreq (void )

Description:

Obtains the number of kernel ticks per second.

Returns:

Returns the number of kernel ticks.

osKernelInitialize()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osKernelInitialize (void )

Description:

Initializes the RTOS kernel.

Returns:

Returns the CMSIS-RTOS running result.

osKernelLock()

int32_t osKernelLock (void )

Description:

Locks the kernel.

Returns:

Returns 1 if the kernel is locked successfully; returns 0 if the lock starts; returns a negative value in the case of an error.

osKernelRestoreLock()

int32_t osKernelRestoreLock (int32_t lock)

Description:

Restores the previous lock state of the kernel.

Parameters:

Name

Description

locks Indicates the lock state to restore to. The value 1 indicates the locked state, and 0 indicates the unlocked state.

Returns:

Returns 1 if the kernel is locked; returns 0 if the kernel is not locked; returns a negative value in the case of an error.

osKernelStart()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osKernelStart (void )

Description:

Starts the kernel.

Returns:

Returns the CMSIS-RTOS running result.

osKernelUnlock()

int32_t osKernelUnlock (void )

Description:

Unlocks the kernel.

Returns:

Returns 1 if the kernel is unlocked successfully; returns 0 if the kernel is not locked; returns a negative value in the case of an error.

osMessageQueueDelete()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osMessageQueueDelete ([osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) mq_id)

Description:

Deletes a message queue.

Parameters:

Name

Description

osMessageQueueId_t Indicates the message queue ID, which is obtained using osMessageQueueNew.

Returns:

Returns the CMSIS-RTOS running result.

osMessageQueueGet()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osMessageQueueGet ([osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) mq_id, void * msg_ptr, uint8_t * msg_prio, uint32_t timeout )

Description:

Obtains a message in a message queue.

Parameters:

Name

Description

osMessageQueueId_t Indicates the message queue ID, which is obtained using osMessageQueueNew.
msg_ptr Indicates the pointer to the buffer for storing the message to be retrieved from the message queue.
msg_prio Indicates the pointer to the buffer for storing the priority of the message to be retrieved from the message queue. This parameter can be left empty.
timeout Indicates the timeout duration.

Returns:

Returns the CMSIS-RTOS running result.

osMessageQueueGetCapacity()

uint32_t osMessageQueueGetCapacity ([osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) mq_id)

Description:

Obtains the maximum number of messages that can be placed in a message queue.

Parameters:

Name

Description

osMessageQueueId_t Indicates the message queue ID, which is obtained using osMessageQueueNew.

Returns:

Returns the maximum number.

osMessageQueueGetCount()

uint32_t osMessageQueueGetCount ([osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) mq_id)

Description:

Obtains the number of queued messages in a message queue.

Parameters:

Name

Description

osMessageQueueId_t Indicates the message queue ID, which is obtained using osMessageQueueNew.

Returns:

Returns the number of queued messages.

osMessageQueueGetMsgSize()

uint32_t osMessageQueueGetMsgSize ([osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) mq_id)

Description:

Obtains the maximum size of messages that can be placed in a message queue.

Parameters:

Name

Description

osMessageQueueId_t Indicates the message queue ID, which is obtained using osMessageQueueNew.

Returns:

Returns the maximum message size.

osMessageQueueGetSpace()

uint32_t osMessageQueueGetSpace ([osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) mq_id)

Description:

Obtains the number of available slots for messages in a message queue.

Parameters:

Name

Description

osMessageQueueId_t Indicates the message queue ID, which is obtained using osMessageQueueNew.

Returns:

Returns the number of available slots for messages.

osMessageQueueNew()

[osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const [osMessageQueueAttr_t](osMessageQueueAttr_t.md) * attr )

Description:

Creates and initializes a message queue.

Parameters:

Name

Description

msg_count Indicates the number of messages in the message queue.
msg_size Indicates the size of messages in the message queue.
attr Indicates the pointer to the message queue attributes. This parameter is not used.

Returns:

Returns the message queue ID; returns NULL in the case of an error.

osMessageQueuePut()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osMessageQueuePut ([osMessageQueueId_t](CMSIS.md#ga206dbc05367e03c39fc6d4d1ebcff317) mq_id, const void * msg_ptr, uint8_t msg_prio, uint32_t timeout )

Description:

Places a message in a message queue.

Parameters:

Name

Description

osMessageQueueId_t Indicates the message queue ID, which is obtained using osMessageQueueNew.
msg_ptr Indicates the pointer to the buffer for storing the message to be placed in the message queue.
msg_prio Indicates the priority of the message to be placed in the message queue.
timeout Indicates the timeout duration.

Returns:

Returns the CMSIS-RTOS running result.

osMutexAcquire()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osMutexAcquire ([osMutexId_t](CMSIS.md#ga29b7ba721f4fe0b11c84c55d079cc3e7) mutex_id, uint32_t timeout )

Description:

Obtains a mutex.

Parameters:

Name

Description

mutex_id Indicates the mutex ID, which is obtained using osMutexNew.
timeout Indicates the timeout duration.

Returns:

Returns the CMSIS-RTOS running result.

osMutexDelete()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osMutexDelete ([osMutexId_t](CMSIS.md#ga29b7ba721f4fe0b11c84c55d079cc3e7) mutex_id)

Description:

Deletes a mutex.

Parameters:

Name

Description

mutex_id Indicates the mutex ID, which is obtained using osMutexNew.

Returns:

Returns the CMSIS-RTOS running result.

osMutexGetOwner()

[osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) osMutexGetOwner ([osMutexId_t](CMSIS.md#ga29b7ba721f4fe0b11c84c55d079cc3e7) mutex_id)

Description:

Obtains the thread ID of the currently acquired mutex.

Parameters:

Name

Description

mutex_id Indicates the mutex ID, which is obtained using osMutexNew.

Returns:

Returns the thread ID.

osMutexNew()

[osMutexId_t](CMSIS.md#ga29b7ba721f4fe0b11c84c55d079cc3e7) osMutexNew (const [osMutexAttr_t](osMutexAttr_t.md) * attr)

Description:

Creates and initializes a mutex.

Parameters:

Name

Description

attr Indicates the pointer to the mutex attributes. This parameter is not used.

Returns:

Returns the mutex ID; returns NULL in the case of an error.

osMutexRelease()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osMutexRelease ([osMutexId_t](CMSIS.md#ga29b7ba721f4fe0b11c84c55d079cc3e7) mutex_id)

Description:

Releases a mutex.

Parameters:

Name

Description

mutex_id Indicates the mutex ID, which is obtained using osMutexNew.

Returns:

Returns the CMSIS-RTOS running result.

osSemaphoreAcquire()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osSemaphoreAcquire ([osSemaphoreId_t](CMSIS.md#ga5abc2c02a86678b63a711e13894ac5b1) semaphore_id, uint32_t timeout )

Description:

Acquires a token of a semaphore object.

Parameters:

Name

Description

semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.
timeout Indicates the timeout duration.

Returns:

Returns the CMSIS-RTOS running result.

osSemaphoreDelete()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osSemaphoreDelete ([osSemaphoreId_t](CMSIS.md#ga5abc2c02a86678b63a711e13894ac5b1) semaphore_id)

Description:

Deletes a semaphore object.

Parameters:

Name

Description

semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.

Returns:

Returns the CMSIS-RTOS running result.

osSemaphoreGetCount()

uint32_t osSemaphoreGetCount ([osSemaphoreId_t](CMSIS.md#ga5abc2c02a86678b63a711e13894ac5b1) semaphore_id)

Description:

Obtains the number of available tokens of a semaphore object.

Parameters:

Name

Description

semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.

Returns:

Returns the number of available tokens.

osSemaphoreNew()

[osSemaphoreId_t](CMSIS.md#ga5abc2c02a86678b63a711e13894ac5b1) osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const [osSemaphoreAttr_t](osSemaphoreAttr_t.md) * attr )

Description:

Creates and initializes a semaphore object.

Parameters:

Name

Description

max_count Indicates the maximum number of available tokens that can be applied for.
initial_count Indicates the initial number of available tokens.
attr Indicates the pointer to the semaphore attributes. This parameter is not used.

Returns:

Returns the semaphore ID; returns NULL in the case of an error.

osSemaphoreRelease()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osSemaphoreRelease ([osSemaphoreId_t](CMSIS.md#ga5abc2c02a86678b63a711e13894ac5b1) semaphore_id)

Description:

Releases a token of a semaphore object.

Parameters:

Name

Description

semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.

Returns:

Returns the CMSIS-RTOS running result.

osThreadGetCount()

uint32_t osThreadGetCount (void )

Description:

Obtains the number of active threads.

Returns:

Returns the number; returns 0 in the case of an error.

osThreadGetId()

[osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) osThreadGetId (void )

Description:

Obtains the ID of the currently running thread.

Returns:

Returns the thread ID; returns NULL in the case of an error.

osThreadGetName()

const char* osThreadGetName ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Obtains the name of a thread.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the thread name; returns NULL in the case of an error.

osThreadGetPriority()

[osPriority_t](CMSIS.md#gad4e3e0971b41f2d17584a8c6837342ec) osThreadGetPriority ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Gets the prority of an active thread.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the prority of the thread.

osThreadGetStackSize()

uint32_t osThreadGetStackSize ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Obtains the stack size of a thread.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the stack size, in bytes; returns 0 in the case of an error.

osThreadGetStackSpace()

uint32_t osThreadGetStackSpace ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Obtains the size of the available stack space for a thread based on the stack watermark.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the available stack size, in bytes; returns 0 in the case of an error.

osThreadGetState()

[osThreadState_t](CMSIS.md#gad3dc89e942e38d9f3af858a0269a820d) osThreadGetState ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Obtains the state of a thread.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the thread state.

osThreadNew()

[osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) osThreadNew ([osThreadFunc_t](CMSIS.md#ga8ef2773ed8ef63ab8727e0d06ebec4d2) func, void * argument, const [osThreadAttr_t](osThreadAttr_t.md) * attr )

Description:

Creates an active thread.

Parameters:

Name

Description

func Indicates the entry of the thread callback function.
argument Indicates the pointer to the argument passed to the thread.
attr Indicates the thread attributes. If this parameter is left unspecified, the default value 0 is used.

Returns:

Returns the thread ID; returns NULL in the case of an error.

osThreadResume()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osThreadResume ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Resumes a thread from the suspended state.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the CMSIS-RTOS running result.

osThreadSetPriority()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osThreadSetPriority ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id, [osPriority_t](CMSIS.md#gad4e3e0971b41f2d17584a8c6837342ec) priority )

Description:

Changes the priority of a thread.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
priority Indicates the new priority.

Returns:

Returns the CMSIS-RTOS running result.

osThreadSuspend()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osThreadSuspend ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Suspends a thread.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the CMSIS-RTOS running result.

osThreadTerminate()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osThreadTerminate ([osThreadId_t](CMSIS.md#ga6333e016ba9b008e6dd76851c38b9217) thread_id)

Description:

Terminates a thread.

Parameters:

Name

Description

thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.

Returns:

Returns the CMSIS-RTOS running result.

osThreadYield()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osThreadYield (void )

Description:

Sets the currently running thread to the ready state.

Returns:

Returns the CMSIS-RTOS running result.

osTimerDelete()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osTimerDelete ([osTimerId_t](CMSIS.md#gac2000ac2a8c6740700fd8e6c938cff44) timer_id)

Description:

Deletes a timer.

Parameters:

Name

Description

timer_id Indicates the timer ID, which is obtained using osTimerNew.

Returns:

Returns the CMSIS-RTOS running result.

osTimerIsRunning()

uint32_t osTimerIsRunning ([osTimerId_t](CMSIS.md#gac2000ac2a8c6740700fd8e6c938cff44) timer_id)

Description:

Checks whether a timer is running.

Parameters:

Name

Description

timer_id Indicates the timer ID, which is obtained using osTimerNew.

Returns:

Returns 1 if the timer is running; returns 0 otherwise.

osTimerNew()

[osTimerId_t](CMSIS.md#gac2000ac2a8c6740700fd8e6c938cff44) osTimerNew ([osTimerFunc_t](CMSIS.md#ga77a298218f3c8382b39a09a6d134d040) func, [osTimerType_t](CMSIS.md#ga7dc24a4c2b90334427081c3da7a71915) type, void * argument, const [osTimerAttr_t](osTimerAttr_t.md) * attr )

Description:

Creates and initializes a timer.

Parameters:

Name

Description

func Indicates the entry of the timer callback function.
type Indicates the timer type.
argument Indicates the pointer to the argument used in timer callback.
attr Indicates the pointer to the timer attributes. This parameter is not used.

Returns:

Returns the timer ID; returns NULL in the case of an error.

osTimerStart()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osTimerStart ([osTimerId_t](CMSIS.md#gac2000ac2a8c6740700fd8e6c938cff44) timer_id, uint32_t ticks )

Description:

Starts or restarts a timer.

Parameters:

Name

Description

timer_id Indicates the timer ID, which is obtained using osTimerNew.
ticks Indicates the number of ticks since the timer starts running.

Returns:

Returns the CMSIS-RTOS running result.

osTimerStop()

[osStatus_t](CMSIS.md#ga6c0dbe6069e4e7f47bb4cd32ae2b813e) osTimerStop ([osTimerId_t](CMSIS.md#gac2000ac2a8c6740700fd8e6c938cff44) timer_id)

Description:

Stops a timer.

Parameters:

Name

Description

timer_id Indicates the timer ID, which is obtained using osTimerNew.

Returns:

Returns the CMSIS-RTOS running result.

Variable Documentation

api

uint32_t osVersion_t::api

Description:

API version

attr_bits [1/6]

uint32_t osThreadAttr_t::attr_bits

Description:

Thread attribute bits

attr_bits [2/6]

uint32_t osTimerAttr_t::attr_bits

Description:

Reserved attribute bits

attr_bits [3/6]

uint32_t osEventFlagsAttr_t::attr_bits

Description:

Reserved attribute bits

attr_bits [4/6]

uint32_t osMutexAttr_t::attr_bits

Description:

Reserved attribute bits

attr_bits [5/6]

uint32_t osSemaphoreAttr_t::attr_bits

Description:

Reserved attribute bits

attr_bits [6/6]

uint32_t osMessageQueueAttr_t::attr_bits

Description:

Reserved attribute bits

cb_mem [1/6]

void* osThreadAttr_t::cb_mem

Description:

Memory for the thread control block

cb_mem [2/6]

void* osTimerAttr_t::cb_mem

Description:

Memory for the timer control block

cb_mem [3/6]

void* osEventFlagsAttr_t::cb_mem

Description:

Memory for the event control block

cb_mem [4/6]

void* osMutexAttr_t::cb_mem

Description:

Memory for the mutex control block

cb_mem [5/6]

void* osSemaphoreAttr_t::cb_mem

Description:

Memory for the semaphore control block

cb_mem [6/6]

void* osMessageQueueAttr_t::cb_mem

Description:

Memory for the message queue control block

cb_size [1/6]

uint32_t osThreadAttr_t::cb_size

Description:

Size of the memory for the thread control block

cb_size [2/6]

uint32_t osTimerAttr_t::cb_size

Description:

Size of the memory for the timer control block

cb_size [3/6]

uint32_t osEventFlagsAttr_t::cb_size

Description:

Size of the memory for the event control block

cb_size [4/6]

uint32_t osMutexAttr_t::cb_size

Description:

Size of the memory for the mutex control block

cb_size [5/6]

uint32_t osSemaphoreAttr_t::cb_size

Description:

Size of the memory for the semaphore control block

cb_size [6/6]

uint32_t osMessageQueueAttr_t::cb_size

Description:

Size of the memory for the message queue control block

kernel

uint32_t osVersion_t::kernel

Description:

Kernel version

mq_mem

void* osMessageQueueAttr_t::mq_mem

Description:

Memory for storing data in the message queue

mq_size

uint32_t osMessageQueueAttr_t::mq_size

Description:

Size of the memory for storing data in the message queue

name [1/6]

const char* osThreadAttr_t::name

Description:

Thread name

name [2/6]

const char* osTimerAttr_t::name

Description:

Timer name

name [3/6]

const char* osEventFlagsAttr_t::name

Description:

Event name

name [4/6]

const char* osMutexAttr_t::name

Description:

Mutex name

name [5/6]

const char* osSemaphoreAttr_t::name

Description:

Semaphore name

name [6/6]

const char* osMessageQueueAttr_t::name

Description:

Message queue name

priority

[osPriority_t](CMSIS.md#gad4e3e0971b41f2d17584a8c6837342ec) osThreadAttr_t::priority

Description:

Thread priority

reserved

uint32_t osThreadAttr_t::reserved

Description:

Reserved

stack_mem

void* osThreadAttr_t::stack_mem

Description:

Memory for the thread stack

stack_size

uint32_t osThreadAttr_t::stack_size

Description:

Size of the thread stack

tz_module

[TZ_ModuleId_t](CMSIS.md#gad5ef21485fe5f60263bc0b48006202cb) osThreadAttr_t::tz_module

Description:

TrustZone module of the thread

1
https://gitee.com/cain_qin/docs.git
git@gitee.com:cain_qin/docs.git
cain_qin
docs
docs
master

搜索帮助