本帖最后由 XinLiYF 于 2018-4-22 21:59 编辑
H& |" D% f l, y
% @4 a7 T4 B5 {% Z/ O( [+ l" Z通用 RTOS 接口- q8 X) F4 d& e9 n0 k
8 j+ |2 H" H% V5 m
CMSIS-RTOS2 是一个通用的 API ,不受底层 RTOS 内核的影响。应用程序员在用户代码中调用 CMSIS-RTOS2 API 函数以确保从一个 RTOS 到另一个 RTOS 的最大可移植性。使用 CMSIS-RTOS2 API 的中间件可以避免不必要的移植工作。
7 I$ P3 `3 f) L# k- a 0 l0 N/ J: c$ s+ a* H; \ g
CMSIS-RTOS API 结构
2 q7 M1 B. _: {+ N0 O7 u % i+ E! ~" S7 H9 d
典型的 CMSIS-RTOS2 API 实现与现有的实时内核接口。CMSIS-RTOS2 API 提供以下属性和功能: % _( N, n% b. M! R
- 函数名称,标识符和参数是描述性的,易于理解的。这些功能强大而灵活,减少了暴露给用户的功能数量。
- 线程管理允许您定义,创建和控制线程。
- 中断服务程序(ISR)可以调用一些 CMSIS-RTOS 功能。 当 CMSIS-RTOS 函数不能从 ISR 上下文中调用时,它会拒绝调用并返回错误代码。
- 三种不同的事件类型支持多个线程和/或 ISR 之间的通信:
" t9 B) Z$ e' U( G: z' P8 m2 @- 线程标志: 可用于向线程指示特定条件。
- 事件标志: 可用于向线程或 ISR 指示事件。
- 消息: 可以发送到线程或 ISR 。消息缓冲在队列中。0 A0 T1 B* A% E( @9 W6 V
- 互斥管理和信号量已合并。
- CPU 时间可以安排以下功能:2 q2 k" Y9 C' E" b. b% h
- 超时参数包含在许多 CMSIS-RTOS 功能中,以避免系统锁定。当指定超时时,系统会等待,直到资源可用或发生事件。在等待时,运行其他线程。
- osDelay 和 osDelayUntil 函数将线程置于 WAITING 状态一段指定的时间。
- osThreadYield 提供协作式线程切换并将执行传递给具有相同优先级的另一个线程。2 P4 z8 m' _3 o3 I! a& M/ v$ G, I7 W$ G; n
- 定时器管理功能用于触发功能的执行。. c( _+ T6 |" K' j1 V
5 X3 c3 h2 M# N$ r- r5 P* a% A9 s
CMSIS-RTOS2 API 旨在通过 Cortex-M 存储器保护单元(MPU)选择性地整合多处理器系统和/或访问保护。
+ t3 `) V" t9 k" T1 |在一些 RTOS 实现中,线程可能在不同的处理器上执行,因此消息队列可能驻留在共享内存资源中。 * K9 x+ c* u5 u' C" ^! j
CMSIS-RTOS2 API 鼓励软件行业发展现有的 RTOS 实施。实时操作系统的实现可以在针对 Cortex-M 处理器的不同方面进行不同的优化。可选功能可能是例如 " U9 t" h$ M) Z& _; L( u
- 支持 Cortex-M 内存保护单元(MPU)。
- 支持多处理器系统。
- 支持 DMA 控制器。
- 确定性上下文切换。
- 循环上下文切换。
- 避免死锁,例如优先倒置。
- 通过使用 Armv7-M 指令 LDREX 和 STREX 来实现零中断延迟。+ A0 y) R$ W2 Q ^
$ C, p; |2 h* z' l6 J3 R' G: W使用 CMSIS-RTOS2 实现( k9 o6 v5 U1 ]) I' C. K) S" I
CMSIS-RTOS2 实现通常作为库提供。要将 RTOS 功能添加到现有的基于 CMSIS 的应用程序中,需要添加 RTOS 库(通常是一个或多个配置文件)。有一个新的头文件 cmsis_os2.h 可用。这是完全可移植应用程序所需的唯一头文件。在这种情况下,不能使用用户为控制块,对象数据和线程堆栈提供的内存。或者,您可以包含一个实现特定的头文件(例如 rtx_os.h),该文件还提供了用于资源分配的定义(例如控制块的大小,对象数据和线程堆栈所需的内存)。 这是可选的,意味着应用程序代码不是完全可移植的。 0 v" Y1 y, w5 E) ?
- J9 K+ G0 f" j: K8 B* _& U2 l% ]2 ]
CMSIS-RTOS 文件结构
# P b& y& J/ E: x
. o8 j; @* I: z8 r2 L
) _, e% _! \1 I8 c- X* \: S# W 将文件添加到项目后,用户可以开始使用 CMSIS-RTOS 功能。下面提供了一个代码示例: + o, n. p4 G: Y1 _6 S
代码示例 - /*----------------------------------------------------------------------------2 p: ^1 I$ s4 @$ \
- * CMSIS-RTOS 'main' function template
. G# q& T4 j5 g( ]% U" X3 `6 X - *---------------------------------------------------------------------------*/
1 D4 W6 ~, L! l. O2 i! e* U9 Z( g -
I/ M$ ^% A4 j6 j* i* _ - #include "RTE_Components.h"1 y# Z2 H7 c$ ^" O
- #include CMSIS_device_header
6 i8 v B1 t% L7 H - #include "cmsis_os2.h"
5 Z0 e! S+ t" s, C& g6 R0 f! E+ u -
9 `+ ]6 b( ?; _% a q' |. \& Y) n - /*----------------------------------------------------------------------------
- I8 e' t, E( \; G. d5 `; h/ g* [% [. b6 b - * Application main thread
( i/ K- J/ V" _0 g4 ~ - *---------------------------------------------------------------------------*/4 v1 K. P7 |6 V7 o7 a, G
- void app_main (void *argument) {
2 }$ E6 r; v1 _( d9 T9 C: H -
- H) N* N5 u! ?$ D5 B5 k - // ...
: ~4 f3 u2 W/ e - for (;;) {}
0 M! k# ~6 H3 |* y( A% u - }, h- z7 ?: }9 J
-
) O! |2 w& U- k3 U - int main (void) {
" E6 u3 C: n+ E5 D# n -
! U% q1 ^; `2 w! Y - // System Initialization1 X; |" Y0 ]/ j, x
- SystemCoreClockUpdate();6 `6 [5 T* b+ k+ J' Y
- #ifdef RTE_Compiler_EventRecorder
; g4 p+ `7 k; u- {8 ?4 W - // Initialize and start Event Recorder
: c, m7 ^4 A8 H9 O - EventRecorderInitialize(EventRecordError, 1U);
3 n+ b% ?/ ?- Q8 w$ N8 | - #endif3 h9 u9 {7 R* r: d4 m: g( P" U
- // ...
: q3 m" A. G2 ?. j O -
; z* a, j3 ?! Q - osKernelInitialize(); // Initialize CMSIS-RTOS! r( Y$ s" c5 `8 `# j
- osThreadNew(app_main, NULL, NULL); // Create application main thread4 s @0 ^: k; G* q' u3 e
- osKernelStart(); // Start thread execution
. |' A _3 y4 @3 T% L" B: T - for (;;) {}/ j* r* u4 ^ {
- }
复制代码 # o( o# }* h& \: c% Q. _' u
cmsis_os2.h 头文件/ M$ X3 w) e7 x$ e( }/ y
文件 cmsis_os2.h 是一个标准头文件,与每个 CMSIS-RTOS2 兼容的实时操作系统(RTOS)相连接。每个实现都提供了相同的 cmsis_os2.h ,它定义了到 CMSIS-RTOS2 的接口。
* r9 g; S7 V3 P* J; i8 K' j& j
通过使用 cmsis_os2.h 和动态对象分配,可以创建在不同的 CMSIS-RTOS2 实现上使用时不需要修改的源代码或库。 : z( l. k4 V9 |6 O% {4 D! _
头文件 cmsis_os2.h - /*) [0 X* { H" X0 r
- * Copyright (c) 2013-2017 ARM Limited. All rights reserved.* y& P0 _4 k( a G( u
- *! T8 Q+ Y6 E, `) L9 K
- * SPDX-License-Identifier: Apache-2.0/ G" r" \: B& ~ S/ T2 O9 `4 a
- *
6 w& X+ H" n B) X! Q% H, g - * Licensed under the Apache License, Version 2.0 (the License); you may! u9 h) W0 c( u
- * not use this file except in compliance with the License.
( r1 q1 _& g$ o, {- l - * You may obtain a copy of the License at2 @# X) z8 A: i2 U* g2 }" w$ T( ^
- *
& M2 f% N6 l1 Q0 S4 ` - * www.apache.org/licenses/LICENSE-2.00 }: A0 ~. L8 U
- *+ ^* O5 e: W# |6 u
- * Unless required by applicable law or agreed to in writing, software; X4 p9 u/ p) O3 Q! V" m
- * distributed under the License is distributed on an AS IS BASIS, WITHOUT
8 i1 t( t1 q6 X G - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.: v; i2 I3 C! h$ W7 ?! Z
- * See the License for the specific language governing permissions and
& C) y' n: k$ ~! ]+ u' q! e% A- D' E - * limitations under the License.' L5 b% F$ s" d% i1 ?+ Q
- *! a' E6 v* C3 `* F) p4 @4 Y2 ~
- * ----------------------------------------------------------------------
+ B0 l7 w6 u H5 Y0 s - *. L% b/ m0 x' y% [8 N. `7 a
- * $Date: 30. October 2017
9 A* T: y8 I9 o- U9 ]' A9 i - * $Revision: V2.1.2% ~+ a! C8 T% B; h; P9 M) Z
- ** x5 j3 Q" a( b, O: x/ v
- * Project: CMSIS-RTOS2 API& v h' Y& l& N1 h9 z
- * Title: cmsis_os2.h header file' v" {. i% o8 r( q; j( a
- *
: m9 l6 t7 l- a. }! W - * Version 2.1.2& S% y" I! i9 q8 c& W u' T; f
- * Additional functions allowed to be called from Interrupt Service Routines:7 |4 Q ]2 P# g
- * - osKernelGetInfo, osKernelGetState$ w. W0 @' i0 g
- * Version 2.1.1
, b! A9 j, c i$ ] - * Additional functions allowed to be called from Interrupt Service Routines:3 H& l9 m" m* T5 H y
- * - osKernelGetTickCount, osKernelGetTickFreq J2 Y5 f2 u B, q, `. x2 D/ c# c
- * Changed Kernel Tick type to uint32_t:! }/ \- v6 P$ [" p3 M4 V
- * - updated: osKernelGetTickCount, osDelayUntil
4 ]2 r e5 S7 P9 L" g4 E0 x - * Version 2.1.0# a2 {8 m4 `( x* F. b8 z& e
- * Support for critical and uncritical sections (nesting safe):% ^1 j$ n6 |3 \ i8 H
- * - updated: osKernelLock, osKernelUnlock
5 I- a$ v* c6 e" U( e - * - added: osKernelRestoreLock1 P1 H0 g& U1 {3 W! R9 {
- * Updated Thread and Event Flags:% L" u$ n( M3 a0 s: |3 ? B7 { V* z8 L
- * - changed flags parameter and return type from int32_t to uint32_t5 u# ^5 Q, a5 `# w$ t7 s* R
- * Version 2.0.0
& Y/ G2 P% U2 T o9 g# C - * Initial Release7 E5 M V1 c# `5 e
- *---------------------------------------------------------------------------*/
5 K9 h0 A* j5 @1 ~0 E# y- V9 k -
4 P9 K9 Y% ]" g) k - #ifndef CMSIS_OS2_H_ z0 j# L: `& r& l) w
- #define CMSIS_OS2_H_7 N7 K% e! j6 D0 y2 H
-
/ r& y6 C o% v8 c5 J" H* c$ ^ - #ifndef __NO_RETURN
) l% H) w7 u I$ y6 ?% x - #if defined(__CC_ARM)
$ e1 E8 Q( u/ E0 X6 P6 v - #define __NO_RETURN __declspec(noreturn)
4 t, H# q5 c& j; m: s, b - #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)+ w! K! s% ^+ c1 x. n' P
- #define __NO_RETURN __attribute__((__noreturn__))0 \% b6 c' k7 L
- #elif defined(__GNUC__)# E4 e5 I8 H/ a3 v( L! q
- #define __NO_RETURN __attribute__((__noreturn__))0 m# O' P" }; V* b
- #elif defined(__ICCARM__)
* ~1 X" V8 D7 G# R) m - #define __NO_RETURN __noreturn9 I% X! l% g' H. o
- #else# k6 E/ H/ V8 }, j, t8 q; d& f
- #define __NO_RETURN
2 ]/ W5 `4 l u) Q5 j - #endif
+ X" y% K2 _, N0 u! `" R1 Q - #endif: y( ~- n9 P. h z+ y
- , k5 |; t6 D: Y
- #include <stdint.h>* K8 i6 L5 y8 Y7 A. O
- #include <stddef.h>/ z" @/ p) p/ A
-
& z# f. K9 E" E - #ifdef __cplusplus
3 D& ~) D: t) l - extern "C"
& S& m2 H" Q+ u! k# D0 s - {
& z3 ^: f1 O8 x - #endif
3 m- M; g% m" k+ N( ? h8 I -
/ Y5 m5 l! _5 [9 v$ @5 @8 f -
5 Z2 _# [/ u, q- ` A - // ==== Enumerations, structures, defines ====, a# e! F% |3 A0 b; {+ Z
-
# ^3 {" n$ J- n2 t% ] - /// Version information.: M. r& z0 m4 x |
- typedef struct {- o0 K( [4 F1 V" R6 n, a
- uint32_t api; ///< API version (major.minor.rev: mmnnnrrrr dec).8 V5 E$ A+ O2 b% h
- uint32_t kernel; ///< Kernel version (major.minor.rev: mmnnnrrrr dec).
6 _6 r/ ~% i/ @ - } osVersion_t;
0 `/ r: L. t% E" F1 E+ A8 j8 t - - a: N1 L4 @) H$ f( t
- /// Kernel state.
* _ B, F A' ] - typedef enum {( t1 w# b$ y0 {1 [" ?0 t
- osKernelInactive = 0, ///< Inactive.
( m" n2 x0 y2 b. t; U - osKernelReady = 1, ///< Ready./ C& ]6 o2 \+ |( z$ T) `
- osKernelRunning = 2, ///< Running.
* H% `' i; y% Z - osKernelLocked = 3, ///< Locked." {1 N4 W1 M9 n& ^6 b2 @$ [! y3 t
- osKernelSuspended = 4, ///< Suspended., _: v1 z0 }4 G8 ?7 C: ?
- osKernelError = -1, ///< Error.
1 }( Q4 V" H$ |5 {% H - osKernelReserved = 0x7FFFFFFFU ///< Prevents enum down-size compiler optimization.
* a R/ P, H3 E' V! H - } osKernelState_t;
3 o* h+ B& N+ d: C* | - : T/ n, |* i b" O" `* R% Z
- /// Thread state.
" U1 b5 ~) b, Y& } - typedef enum {9 C" b) |" H9 B% V5 |
- osThreadInactive = 0, ///< Inactive. q6 i( t1 n5 I3 \( v9 n
- osThreadReady = 1, ///< Ready.
4 m# U; v. H, z$ ^ - osThreadRunning = 2, ///< Running.# M8 A Z! W" m0 B3 R
- osThreadBlocked = 3, ///< Blocked.
8 L0 ?: ?, f8 W0 G - osThreadTerminated = 4, ///< Terminated." o/ C) D1 Z7 s; w7 G
- osThreadError = -1, ///< Error.1 n4 F. e* b) n9 E5 {
- osThreadReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization.
7 _2 H; |& a& v6 |( N- J ^ - } osThreadState_t;( q: f% b% d; m, }
-
- N0 M. D2 s1 o% L6 V5 H6 m d& d - /// Priority values.: K0 s* h. T& p/ ^
- typedef enum {
. J7 U a! y- B2 T, A! c0 o$ J - osPriorityNone = 0, ///< No priority (not initialized).2 P- }* I& {, d* t: w; R
- osPriorityIdle = 1, ///< Reserved for Idle thread.5 N J+ ?& h1 ^. [: ^; r( k
- osPriorityLow = 8, ///< Priority: low
& ?0 e+ R" O ?, L - osPriorityLow1 = 8+1, ///< Priority: low + 1
, H' b7 [$ a* R# K6 n% d' O9 y. x - osPriorityLow2 = 8+2, ///< Priority: low + 2. ~! o3 I' r. I8 m. ?/ P
- osPriorityLow3 = 8+3, ///< Priority: low + 3
- m& Q( e! v% C# @+ O - osPriorityLow4 = 8+4, ///< Priority: low + 40 J3 g) E( a R. E2 J2 N- }
- osPriorityLow5 = 8+5, ///< Priority: low + 5( P/ `5 D* K& O7 D4 {- S1 A: c
- osPriorityLow6 = 8+6, ///< Priority: low + 6% |0 J3 ^5 @; s
- osPriorityLow7 = 8+7, ///< Priority: low + 77 k& o2 Z) z! s+ a
- osPriorityBelowNormal = 16, ///< Priority: below normal, S( f u" c1 N0 C# E0 x
- osPriorityBelowNormal1 = 16+1, ///< Priority: below normal + 1/ N: y8 f, k8 ?- ?) Q
- osPriorityBelowNormal2 = 16+2, ///< Priority: below normal + 2
4 z, e1 `0 b! f( }2 @/ ?3 g - osPriorityBelowNormal3 = 16+3, ///< Priority: below normal + 3
, |. E- K5 N. e* j - osPriorityBelowNormal4 = 16+4, ///< Priority: below normal + 4; i$ g# s( \6 Q% E: c* i
- osPriorityBelowNormal5 = 16+5, ///< Priority: below normal + 5
" b, D- c9 e5 U% t: h) o - osPriorityBelowNormal6 = 16+6, ///< Priority: below normal + 62 U" L; k W9 y' v u
- osPriorityBelowNormal7 = 16+7, ///< Priority: below normal + 7- X4 L% q N0 A% g$ @2 H/ `
- osPriorityNormal = 24, ///< Priority: normal
, S' O* L! L6 u" A3 A2 h9 M* J: } - osPriorityNormal1 = 24+1, ///< Priority: normal + 1
" Y- Q3 n3 X1 J# | - osPriorityNormal2 = 24+2, ///< Priority: normal + 2& H3 m' b: {3 p. c+ r5 b$ w
- osPriorityNormal3 = 24+3, ///< Priority: normal + 3: A% o( ~2 q' `& ~ X! `
- osPriorityNormal4 = 24+4, ///< Priority: normal + 4
5 V, D8 o6 [& } - osPriorityNormal5 = 24+5, ///< Priority: normal + 50 I# Z* ^) C! Y4 n4 Z
- osPriorityNormal6 = 24+6, ///< Priority: normal + 6
% c6 C+ i, ~- y, |3 z - osPriorityNormal7 = 24+7, ///< Priority: normal + 7& d C, i# I+ x+ _: s! ^/ q; f
- osPriorityAboveNormal = 32, ///< Priority: above normal% E# @! b! w `0 @
- osPriorityAboveNormal1 = 32+1, ///< Priority: above normal + 1
. w( f+ A5 Y1 A4 l - osPriorityAboveNormal2 = 32+2, ///< Priority: above normal + 2
* F6 \+ E+ g) f7 j$ t - osPriorityAboveNormal3 = 32+3, ///< Priority: above normal + 38 z. }# _% ~: Q0 P( t
- osPriorityAboveNormal4 = 32+4, ///< Priority: above normal + 4) }* P) w; l% |6 A7 O r H2 E5 `
- osPriorityAboveNormal5 = 32+5, ///< Priority: above normal + 51 p" T2 H( ?# ^8 n2 r, E3 J7 h
- osPriorityAboveNormal6 = 32+6, ///< Priority: above normal + 6' f5 n- X, I, C* [9 o7 g/ x5 m$ @
- osPriorityAboveNormal7 = 32+7, ///< Priority: above normal + 7
) f+ E/ S; {; Y+ S9 N8 y - osPriorityHigh = 40, ///< Priority: high, L2 u9 j \' O2 D! U4 N
- osPriorityHigh1 = 40+1, ///< Priority: high + 1
- H! K! [: C. ?. W) a( v8 T b - osPriorityHigh2 = 40+2, ///< Priority: high + 2
@8 Y3 f" f' p - osPriorityHigh3 = 40+3, ///< Priority: high + 3
3 u0 M! t$ D0 u: E W8 T - osPriorityHigh4 = 40+4, ///< Priority: high + 4
1 N# w3 u+ @ [; ~: n9 z$ J* [% y - osPriorityHigh5 = 40+5, ///< Priority: high + 5; T7 T* z# s3 V! t
- osPriorityHigh6 = 40+6, ///< Priority: high + 6
/ e A4 p' O# J+ e - osPriorityHigh7 = 40+7, ///< Priority: high + 7
: S8 S+ r% {3 q$ j" G# \ - osPriorityRealtime = 48, ///< Priority: realtime
- p: u6 t1 e b - osPriorityRealtime1 = 48+1, ///< Priority: realtime + 1
, \4 U+ R# C# [ - osPriorityRealtime2 = 48+2, ///< Priority: realtime + 2
" e) s( J! @7 d7 j - osPriorityRealtime3 = 48+3, ///< Priority: realtime + 3
* o. j9 a% y. e: @4 y - osPriorityRealtime4 = 48+4, ///< Priority: realtime + 4
3 U# q5 q" q, C3 z) b5 D - osPriorityRealtime5 = 48+5, ///< Priority: realtime + 5
9 N2 y# V h0 m9 ]* R - osPriorityRealtime6 = 48+6, ///< Priority: realtime + 6! n* K1 L! y; i9 z/ e5 x: y
- osPriorityRealtime7 = 48+7, ///< Priority: realtime + 7
+ n) b. R9 d5 i! j4 D9 F- E+ I" d: D - osPriorityISR = 56, ///< Reserved for ISR deferred thread.
2 F' C! w: O5 ]2 M" z0 f/ ` - osPriorityError = -1, ///< System cannot determine priority or illegal priority.
! Q; h0 _9 g. }% X- M - osPriorityReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization.9 o) z* }1 I+ t
- } osPriority_t;- G( a- I5 m& f
-
) R$ U3 T) l7 o0 M) a3 H5 ~ - /// Entry point of a thread.
4 K$ v# A/ V# q' Z+ C* d' e4 [" D - typedef void (*osThreadFunc_t) (void *argument);: x/ S o: [1 s
- ( N6 y. a" G+ _4 a
- /// Timer callback function.
5 C5 @' g8 o0 J' K3 E - typedef void (*osTimerFunc_t) (void *argument);
: O4 |$ k7 l5 r7 {3 w3 R7 y) { - 1 `; R. Y+ c/ K; o- B/ n
- /// Timer type./ x6 `/ G" X" F
- typedef enum {
2 W0 Z, R7 g, w2 L0 } - osTimerOnce = 0, ///< One-shot timer.$ _% }# v+ O" N! z
- osTimerPeriodic = 1 ///< Repeating timer.
5 {: l; P. ^0 N& S - } osTimerType_t;
& r$ p; P# _. f" S9 C -
/ P1 y8 @& i4 J' | - // Timeout value.6 J% e7 ?5 i: U6 {
- #define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value.. [3 p7 F: [4 p! B0 @ }
-
$ _! j% O; }' m" R8 v# t - // Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait).7 A$ o$ V, V4 [ V& r8 P# {
- #define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default).
' ~% R+ Z* t& q' v! n S' S - #define osFlagsWaitAll 0x00000001U ///< Wait for all flags.% F9 b4 x) |) a- [+ ^3 y; v
- #define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for.
: }* g; f% D/ o - & i3 D3 V1 z* B( G' j0 P
- // Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx).4 K$ u6 n+ s- |
- #define osFlagsError 0x80000000U ///< Error indicator.6 h1 l g+ D- O4 z g: ?4 Z- ~1 E6 W
- #define osFlagsErrorUnknown 0xFFFFFFFFU ///< osError (-1).' y8 U* {4 r5 v
- #define osFlagsErrorTimeout 0xFFFFFFFEU ///< osErrorTimeout (-2).
+ y8 [7 c: v5 V7 N! u - #define osFlagsErrorResource 0xFFFFFFFDU ///< osErrorResource (-3).
" @+ ?, ? r7 r- L# I# z - #define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4).
6 [# P4 A, t2 q, { - #define osFlagsErrorISR 0xFFFFFFFAU ///< osErrorISR (-6)., ^; e2 c, Z4 v# @: l; F
- 2 M' T/ U/ E: G# d0 o( }
- // Thread attributes (attr_bits in \ref osThreadAttr_t).) Z! h7 q% R7 H; @# |# |# [8 m7 {
- #define osThreadDetached 0x00000000U ///< Thread created in detached mode (default)
* |, v: ~( d: v1 T8 X) x - #define osThreadJoinable 0x00000001U ///< Thread created in joinable mode
j2 K7 D0 ~/ F* ^2 x$ A8 n - , n# z% ~8 t$ }4 k
- // Mutex attributes (attr_bits in \ref osMutexAttr_t).
/ Y+ c) G @. i - #define osMutexRecursive 0x00000001U ///< Recursive mutex.' F, c& _9 C0 t% p S. A
- #define osMutexPrioInherit 0x00000002U ///< Priority inherit protocol.0 }1 q* V4 W3 {3 E6 b
- #define osMutexRobust 0x00000008U ///< Robust mutex. f1 t* r' e e( y' j/ G$ ^
- ' i5 x0 Q$ T9 @
- /// Status code values returned by CMSIS-RTOS functions.
. `/ w* K# l+ k1 T- F$ E: n8 g4 W - typedef enum {
+ ~4 L; x/ Q) R - osOK = 0, ///< Operation completed successfully.: u$ u! l* @3 v" F: m d
- osError = -1, ///< Unspecified RTOS error: run-time error but no other error message fits.
# k$ {4 d% g1 x7 f - osErrorTimeout = -2, ///< Operation not completed within the timeout period.
+ y8 G; W' J" O - osErrorResource = -3, ///< Resource not available.
( S. @% F M( g8 S) X- e; u- Y - osErrorParameter = -4, ///< Parameter error.6 k N, `7 \5 J! r7 q; ] J
- osErrorNoMemory = -5, ///< System is out of memory: it was impossible to allocate or reserve memory for the operation.
( c8 k9 i/ H8 w- P+ ^ - osErrorISR = -6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines.' Z. l% g, @( U" W% D
- osStatusReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization.* D9 O! P) |- \. w1 S8 j' U
- } osStatus_t;. O1 R4 u1 R& F& y) l) ^
-
. t4 ^' U2 Z( X3 ~ - ' ? V$ d% Q3 G3 M. [- e
- /// \details Thread ID identifies the thread.
! o4 T+ a% j' o) U6 s+ C' I - typedef void *osThreadId_t;
, v5 m9 `3 p5 E& w' W; g -
+ |0 x: I# [9 q$ p, I# f% { - /// \details Timer ID identifies the timer.
5 U" e, c3 \# o8 C* | - typedef void *osTimerId_t;
1 L& p# L& s; J9 j% a -
! m7 y% R2 E$ P& s# L - /// \details Event Flags ID identifies the event flags.3 {: p3 `3 v1 o
- typedef void *osEventFlagsId_t;
3 _! @2 F& q" N5 N - , y8 b$ R f; y8 S1 h* T1 ?/ q
- /// \details Mutex ID identifies the mutex.
4 f9 l# ^) Y# C$ j! P1 s5 v; ^ - typedef void *osMutexId_t;
+ ~/ K/ `, ~; K3 R/ H -
5 \7 O' E7 A8 r7 O& n$ \ - /// \details Semaphore ID identifies the semaphore.
! y B) v, [6 w9 w f1 h - typedef void *osSemaphoreId_t;) j9 ]0 m" C% Y. d1 v% j8 I
-
F3 D# U+ g& r, Z - /// \details Memory Pool ID identifies the memory pool.
+ J( k0 a5 b: a/ Q: @ - typedef void *osMemoryPoolId_t;2 F; \4 _9 q+ S5 U5 i/ ]+ \
-
. e1 u7 T% ^; R9 t2 b& x - /// \details Message Queue ID identifies the message queue.' n9 U* [7 `% s+ V& ?* L4 Y
- typedef void *osMessageQueueId_t;1 S& @6 ~6 |9 n2 ?! p
- ( @- W$ I# L9 n) M! }; t
-
2 c7 m( W2 |7 S) O* S: {+ f - #ifndef TZ_MODULEID_T# @% H) e$ ^* A
- #define TZ_MODULEID_T( L$ \5 z, C# [& ^" u0 v; l
- /// \details Data type that identifies secure software modules called by a process.
# C2 U$ n0 ~; r6 [& |/ W% U - typedef uint32_t TZ_ModuleId_t;$ }! I- H# A" G9 E+ \! k2 |3 n
- #endif; E5 e+ K" @: q8 B: L) }5 y
-
2 L. q5 |; \7 c5 D- R5 U -
& [* s$ w& L! Y - /// Attributes structure for thread.
, }" X. ]7 C+ M( I7 A- q( e - typedef struct {; { q& X, N- E! D, k) O- `" e
- const char *name; ///< name of the thread4 M8 ~0 E/ @. G
- uint32_t attr_bits; ///< attribute bits( u" B* O! [" q( T6 w
- void *cb_mem; ///< memory for control block
- i2 Y/ o9 V K2 V6 s. f- H! r - uint32_t cb_size; ///< size of provided memory for control block" g9 }2 N( A1 ^' U. t
- void *stack_mem; ///< memory for stack
- k! V4 P l0 x - uint32_t stack_size; ///< size of stack
3 R" V2 ^( V; l - osPriority_t priority; ///< initial thread priority (default: osPriorityNormal)
+ u @0 @' L" t& d# v/ G. x2 H0 @2 } - TZ_ModuleId_t tz_module; ///< TrustZone module identifier1 W# e8 o" U9 ^
- uint32_t reserved; ///< reserved (must be 0)* k9 B7 Y! U' _! F
- } osThreadAttr_t;9 J# C) ?& X S; G
- ) S+ k5 `& W _& Y+ V" z
- /// Attributes structure for timer.
% n& J# }/ ~& L8 x. g: T$ A6 [ - typedef struct {$ m' L, W ^4 O
- const char *name; ///< name of the timer
% p. j& Q1 w v% v2 q4 `6 s# f - uint32_t attr_bits; ///< attribute bits
. i+ e! D: K+ g2 ]8 ? - void *cb_mem; ///< memory for control block' [/ K$ j0 L9 ^+ x, m
- uint32_t cb_size; ///< size of provided memory for control block, G, @4 e8 S) ^" ^/ Y6 O
- } osTimerAttr_t;
. v# C& `6 n. g5 V' A/ S -
) y! }8 V# T! ^1 j - /// Attributes structure for event flags." G3 h6 ^3 a: S( w3 T+ `2 w$ B
- typedef struct {
- M% Z9 Y! n4 G9 Q1 q - const char *name; ///< name of the event flags, K% G: ^, Q1 X. @
- uint32_t attr_bits; ///< attribute bits
1 q4 O1 X" x; K. T - void *cb_mem; ///< memory for control block- M5 p) R* v/ e, q* [
- uint32_t cb_size; ///< size of provided memory for control block
/ c5 H& x- p7 H% @4 j: u1 U - } osEventFlagsAttr_t;
; {. N$ A9 ?# ]/ |+ g: f - $ g* d3 g. i% }/ ^
- /// Attributes structure for mutex.) O2 H* J3 h9 e, x0 Z" [
- typedef struct {
4 r. A% h4 [; x- Y - const char *name; ///< name of the mutex
0 ]4 l/ `$ t! S/ |5 y+ N - uint32_t attr_bits; ///< attribute bits5 W. H$ Z* B. b* O- s8 @
- void *cb_mem; ///< memory for control block
( \% k( K5 X- b! {% D - uint32_t cb_size; ///< size of provided memory for control block( k/ X( g5 l, S/ l; u7 v* l; {
- } osMutexAttr_t;
1 F/ p( |+ c* i1 C4 u -
: b- C1 V- U% d0 X/ Q& ^( }1 z - /// Attributes structure for semaphore.
& | g5 O! H" n$ s8 e$ z3 o - typedef struct {
$ V- T% b! V7 J" t; u: ` - const char *name; ///< name of the semaphore _5 N" C6 `, s2 e, a% Y' I$ W& \
- uint32_t attr_bits; ///< attribute bits; K& |" R2 H9 {
- void *cb_mem; ///< memory for control block& l/ J1 W6 }* M6 b5 K
- uint32_t cb_size; ///< size of provided memory for control block
" ~4 i0 G6 t$ i' d - } osSemaphoreAttr_t;
, l/ z0 z, S) W3 a, `2 X+ T - % [7 O7 q3 ~( p' R
- /// Attributes structure for memory pool.; Y9 }. ~; a6 r8 \( r
- typedef struct {
2 d" A( F5 Z9 n j4 x+ k - const char *name; ///< name of the memory pool
( J' b1 P6 x: @/ ?" u - uint32_t attr_bits; ///< attribute bits$ R! b T4 |( M) f: Y" T# ^/ @
- void *cb_mem; ///< memory for control block
/ t1 n$ V% E+ A5 l5 ^ - uint32_t cb_size; ///< size of provided memory for control block0 O. Y( G8 m) z, a
- void *mp_mem; ///< memory for data storage. g8 |$ V2 {% k# e% M
- uint32_t mp_size; ///< size of provided memory for data storage
8 R- g, B. X5 W5 C4 B" X# W1 W - } osMemoryPoolAttr_t;
8 N5 q; V: G8 L2 [ - 6 B! b* L B) C+ _
- /// Attributes structure for message queue.
, ^/ J( o R; | - typedef struct {/ Q0 ~* T/ x9 |
- const char *name; ///< name of the message queue$ W/ \5 v* B* Y/ y, o" C" l s
- uint32_t attr_bits; ///< attribute bits
* x1 S/ _' C, v% s% m; J - void *cb_mem; ///< memory for control block# f6 n! y7 A7 I# {3 N: u, }% C9 n V
- uint32_t cb_size; ///< size of provided memory for control block
5 A N2 F4 w4 [/ X - void *mq_mem; ///< memory for data storage
' q' C8 r/ j9 T5 m; L6 _8 ^+ I - uint32_t mq_size; ///< size of provided memory for data storage ; [' G9 p+ M! S# i. E9 I1 O
- } osMessageQueueAttr_t;
! o% L5 W7 K# N! ?% a -
/ S) H# A9 ]6 y) G6 v f -
( Z M- V6 B2 y7 B9 s - // ==== Kernel Management Functions ====
# S2 w; N- h) t7 L6 k1 E - 1 ?2 r( W( i3 w2 \$ n- s7 e4 B
- /// Initialize the RTOS Kernel.
6 l& t2 ~- z- W4 `/ @& i - /// \return status code that indicates the execution status of the function.$ B7 Y* n! a% Q- a
- osStatus_t osKernelInitialize (void);( g- y1 H# q- ?& v/ I% z
-
8 X7 u) s0 W- ]0 v% { - /// Get RTOS Kernel Information.
" C7 m! Z! x2 V$ D - /// \param[out] version pointer to buffer for retrieving version information.
+ w K6 a; m9 d0 q5 m& ]% y - /// \param[out] id_buf pointer to buffer for retrieving kernel identification string.& o/ g. L, x& S1 v! ?3 R
- /// \param[in] id_size size of buffer for kernel identification string.% ]1 z/ ~. t% P Q
- /// \return status code that indicates the execution status of the function.
: ~6 K( F4 O, w; z& }+ o - osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size);1 V# k \0 J0 N3 `- L9 V
- 2 n9 `1 Z' F, H; c
- /// Get the current RTOS Kernel state.4 H& a. b6 H8 r, K
- /// \return current RTOS Kernel state.
0 Y+ h. e' M6 |+ i2 P - osKernelState_t osKernelGetState (void);
" }5 r( _' J- U' [4 P5 t1 G - # {, p4 [) o. f7 y4 m
- /// Start the RTOS Kernel scheduler.
" i: D. A4 d; h, Z* q3 U( b: w - /// \return status code that indicates the execution status of the function.5 L9 s1 r4 H' |: H8 [! r! Z+ r2 P0 n! O
- osStatus_t osKernelStart (void);- @& `: C2 C5 Y% k2 b, i1 n! s, C2 j
-
7 K0 X+ b! ]( Y5 b5 u2 S - /// Lock the RTOS Kernel scheduler.
6 I1 R2 g# B9 u% A8 b1 \ k - /// \return previous lock state (1 - locked, 0 - not locked, error code if negative).
2 n& b9 y7 S% W) Y- s- l) m - int32_t osKernelLock (void);
) m; F6 X6 G# x) K3 e; O. O -
4 ~& e( d* U0 y7 T - /// Unlock the RTOS Kernel scheduler.# ?: ]+ U2 T# t- Y- N# f
- /// \return previous lock state (1 - locked, 0 - not locked, error code if negative).
- E( b4 k/ x$ M8 E - int32_t osKernelUnlock (void); z. P& L; j: y
- : c2 J2 E3 Z6 W( K% E
- /// Restore the RTOS Kernel scheduler lock state.. W0 j$ s- _9 J# e
- /// \param[in] lock lock state obtained by \ref osKernelLock or \ref osKernelUnlock.& o! B- S- `, P9 U
- /// \return new lock state (1 - locked, 0 - not locked, error code if negative).# b& H8 C6 a. r8 m2 ]8 |
- int32_t osKernelRestoreLock (int32_t lock);
5 `8 {' I3 p% T7 ^3 U -
, r: U* q4 d& e$ W - /// Suspend the RTOS Kernel scheduler.7 g8 _0 b1 s3 h0 z7 H8 v/ V
- /// \return time in ticks, for how long the system can sleep or power-down.3 @1 Y- W1 N' T% [. X. ^
- uint32_t osKernelSuspend (void);
. {# x2 A2 d! _1 e, l9 P - 6 `0 M0 K& C; U+ \# V2 I
- /// Resume the RTOS Kernel scheduler.
2 S) Z' [ o* @9 r - /// \param[in] sleep_ticks time in ticks for how long the system was in sleep or power-down mode.8 \2 X: \% x1 d! S- Y" B/ e# z
- void osKernelResume (uint32_t sleep_ticks);
R& W3 ?# d1 ^3 f' I2 I& s -
- u4 d/ F4 e% |' P5 g' T0 F2 j( f - /// Get the RTOS kernel tick count.! S. b4 ^9 O, D6 P: v/ P
- /// \return RTOS kernel current tick count.& X$ M- ]) G0 H6 ?9 O% Z0 c2 @
- uint32_t osKernelGetTickCount (void);
+ `1 M9 ~& J, J- x: t( g - 9 C- v! |+ K2 q
- /// Get the RTOS kernel tick frequency.* }* g' {9 z8 a4 A& H
- /// \return frequency of the kernel tick in hertz, i.e. kernel ticks per second.
& M# j5 Q3 m, g/ R( X - uint32_t osKernelGetTickFreq (void);8 C" F6 _+ ?; W
- + u; E0 K. Y' p' L7 m9 V
- /// Get the RTOS kernel system timer count.
O$ X3 ` P" P+ X' J9 s, S1 h0 R - /// \return RTOS kernel current system timer count as 32-bit value.
/ p3 N* p5 x' D6 e" }" z. K6 \) Q - uint32_t osKernelGetSysTimerCount (void);* Q- |9 [4 a9 o* \1 L5 u
-
, q' s! r, [. y2 K& q0 I5 U% X4 o - /// Get the RTOS kernel system timer frequency.: P; p9 m$ z3 f2 R3 O+ |
- /// \return frequency of the system timer in hertz, i.e. timer ticks per second.0 y/ Q/ ~0 M9 |- j8 q9 H2 A
- uint32_t osKernelGetSysTimerFreq (void);
5 V; e8 l. U7 J' v -
m( B2 W5 {( e0 F, V -
, t2 s/ a0 H. n9 m. @( E4 V - // ==== Thread Management Functions ====
1 i6 {6 u. v! b4 t7 R- T( C - ; A7 t4 W! p" X) @) K# }& t% e
- /// Create a thread and add it to Active Threads.
1 Z% ~7 [# L) `- F4 ? - /// \param[in] func thread function.
# _ D- @% Z1 w: I - /// \param[in] argument pointer that is passed to the thread function as start argument.
5 x$ ~& l6 {( M! e. G - /// \param[in] attr thread attributes; NULL: default values.
( v$ c h0 v) q2 w* L( l - /// \return thread ID for reference by other functions or NULL in case of error.
$ E9 {; ~3 ?, R$ {7 O - osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
* Q$ k: I, K0 R/ D, { -
4 @% ^: U6 K3 L+ }2 H - /// Get name of a thread.
% n5 R& h8 D+ {0 ?8 |( ? - /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
, u' [, R n) i" n4 b' i& m! W& @ - /// \return name as NULL terminated string.* y9 v, s7 Y0 M0 A
- const char *osThreadGetName (osThreadId_t thread_id);0 k1 `) k9 C1 F+ L5 O# `4 P
-
1 N4 W- f1 T% I0 c' x0 ] - /// Return the thread ID of the current running thread.
4 _, Y" y# e0 O0 |4 s& m4 _ - /// \return thread ID for reference by other functions or NULL in case of error.
1 Z, `9 X+ s+ i: ?: x7 ` - osThreadId_t osThreadGetId (void);
0 `8 s1 a; o r9 a: O! z3 y. Q5 G7 ` - , L* I- ~2 q L5 J0 p
- /// Get current thread state of a thread.
7 u; {6 H6 t) d( g$ G! f) V - /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
e5 _4 |! T* n N - /// \return current thread state of the specified thread.- f, I9 \0 Y) y+ A/ K/ o3 M
- osThreadState_t osThreadGetState (osThreadId_t thread_id);
- V: X, @/ _9 d- c( K/ y -
- J" j H% R0 T9 F - /// Get stack size of a thread.
' t3 x* p8 O! Z/ x& p& {3 q - /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
8 Q2 Z6 Z# I! L+ a - /// \return stack size in bytes.
, w1 w# A: B* l - uint32_t osThreadGetStackSize (osThreadId_t thread_id);1 F# T0 _& s6 f" C4 H
-
0 S* ^& X2 B4 X - /// Get available stack space of a thread based on stack watermark recording during execution.: |9 L- W+ A% b# J( [* _
- /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.- X/ h! K) C) l% G2 T
- /// \return remaining stack space in bytes.
9 A& P# Q0 X& k5 B$ t - uint32_t osThreadGetStackSpace (osThreadId_t thread_id);
9 Z" v& `3 c* ~7 _+ z- g7 b - 3 {5 u5 `, J8 f8 s& s/ z
- /// Change priority of a thread.
3 M; ^1 s& p2 J; d h# a - /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.! Y6 V+ B0 T) f3 J5 `6 A
- /// \param[in] priority new priority value for the thread function.
+ u" G* }8 e# @ - /// \return status code that indicates the execution status of the function.7 _* J/ B* e) t) ~' T6 K! M
- osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority);5 R# K& I7 v& V) @; L
- * Q6 s/ N$ n, J7 e8 H' w9 m' p) K
- /// Get current priority of a thread.9 _4 g/ v! b5 i4 r; Z+ |
- /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
+ c1 L) f4 u* a; E2 p# y% i - /// \return current priority value of the specified thread.: K3 S |* k) ^8 @
- osPriority_t osThreadGetPriority (osThreadId_t thread_id);
: F" v5 A2 ]1 h' D6 y -
* B3 x2 L. e+ E4 | R1 b - /// Pass control to next thread that is in state \b READY.
9 ^- N5 w& p0 G$ L/ |3 u - /// \return status code that indicates the execution status of the function.
0 h5 S2 l: D; X. ]% X1 M - osStatus_t osThreadYield (void);
8 j+ [! t) A! a7 S2 R. @6 u+ V4 I% ~- e -
6 M, r3 K ~# d6 N( O) Z - /// Suspend execution of a thread.1 Y P8 b" u+ Z* u, v0 v, s) i
- /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.+ @ F" C: Q3 h3 q; {" U
- /// \return status code that indicates the execution status of the function.
5 I0 a5 v1 o' s - osStatus_t osThreadSuspend (osThreadId_t thread_id);
2 v: {. U7 a7 k/ \2 [ -
3 r7 ~7 i7 U' k$ }) A% V# Q! s5 U7 S - /// Resume execution of a thread.
8 \- i$ Y# s9 u - /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
* B3 W, j' A1 p; @2 y3 Q - /// \return status code that indicates the execution status of the function.
4 Z* {. ?7 L* o - osStatus_t osThreadResume (osThreadId_t thread_id);
- p2 \6 E' l* z -
) X, t7 e0 Z9 p7 S2 z) u |; {3 c: D - /// Detach a thread (thread storage can be reclaimed when thread terminates).8 Y. n) [2 |$ a& K4 G
- /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
z# A6 u" x6 ?" } h - /// \return status code that indicates the execution status of the function.
- w* @, m4 K4 U2 w/ |* E7 d - osStatus_t osThreadDetach (osThreadId_t thread_id);
8 }; X! o: v [ - 9 b: U4 X* C# j) M4 w
- /// Wait for specified thread to terminate.7 O8 [& ^/ o* l! n8 I$ R
- /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
4 f' s, y ]7 s - /// \return status code that indicates the execution status of the function.$ P7 @8 `* t- _( B- R2 r
- osStatus_t osThreadJoin (osThreadId_t thread_id);
7 ^% [* T; M8 ~0 _ -
* T5 N% \; h& W$ P6 ?5 J! v2 p - /// Terminate execution of current running thread.
* w* U6 h3 m% j - __NO_RETURN void osThreadExit (void);
/ o! X( f- Z4 X# Q: D. D9 q* G$ @ -
% c) {2 c8 l) `. ^, s4 L% f! M - /// Terminate execution of a thread.8 L Z# F, A( o( `+ F/ k7 [
- /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
% y* A* @! E2 R+ |, c3 c* ^* x' ^ - /// \return status code that indicates the execution status of the function.
0 c7 x5 ?6 }# U J! V$ j& b, t - osStatus_t osThreadTerminate (osThreadId_t thread_id);
$ { L& s' z9 z -
* Q) ^* g* k; j' {4 q/ L - /// Get number of active threads.
5 b' G9 K0 t# U7 u: ]$ Z! z - /// \return number of active threads.
* R+ M/ l6 L3 D* c - uint32_t osThreadGetCount (void);
/ Z# ^8 n0 ^2 M* p# |% Z) O& a -
. n& h# R( a+ H3 z7 G - /// Enumerate active threads.9 v6 T9 E- a, y$ x" I Z( A+ I
- /// \param[out] thread_array pointer to array for retrieving thread IDs.
' ^. d" Z0 C6 K; v5 P! r - /// \param[in] array_items maximum number of items in array for retrieving thread IDs.
! w; E& h' H# O% ]4 U7 ~: D - /// \return number of enumerated threads.
3 b" j3 d: k T3 s- m X P - uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items);
' V' K$ t5 i( H8 \ -
" E* R3 F& @* w -
! s- L0 [' U0 E% W* ^9 k - // ==== Thread Flags Functions ====
. G; X1 w( N; @2 M8 T4 ]9 ~ - ; m9 |: x% o3 L# {0 D# h. g9 i; h
- /// Set the specified Thread Flags of a thread.( g% c' F; Z$ L( ~
- /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
2 b+ K9 U' g/ i! p0 \; d - /// \param[in] flags specifies the flags of the thread that shall be set.
* D8 s# T, {. O% ^6 m- b3 n - /// \return thread flags after setting or error code if highest bit set.
! F2 V; _ f6 d( e3 {1 X+ { - uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags);! h; b9 Q O1 M4 ]* ?# G) x
- - E, O+ k8 F* l& b
- /// Clear the specified Thread Flags of current running thread.8 D$ N6 W- i! z1 S( E- h
- /// \param[in] flags specifies the flags of the thread that shall be cleared.
8 ?0 T% U6 \' R7 S4 | - /// \return thread flags before clearing or error code if highest bit set.0 I; P0 w) q: x% T/ p
- uint32_t osThreadFlagsClear (uint32_t flags);
0 }/ C% ?4 ^& ]+ D0 n - 6 R- M/ }* e& v, s. D
- /// Get the current Thread Flags of current running thread.
m) X8 |1 j) _& } - /// \return current thread flags.4 h# U+ Q1 x2 a2 X
- uint32_t osThreadFlagsGet (void);2 N! O) u7 k7 E& U
-
: j9 Y! Z5 m) f% [ - /// Wait for one or more Thread Flags of the current running thread to become signaled., n( T% d5 K0 X5 n2 e' G. f
- /// \param[in] flags specifies the flags to wait for.& N" V, \1 _& J. M+ {6 V
- /// \param[in] options specifies flags options (osFlagsXxxx).6 p8 _- r* v5 _. e' X
- /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.* {% O Y/ K4 z$ W5 ?7 D z
- /// \return thread flags before clearing or error code if highest bit set.
0 i q& d$ G3 K7 t t* ~$ W9 d+ h - uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout);
0 L1 S$ Z# }, T; s& F' H3 c -
4 u. }& X0 }3 X. d% B O -
4 E$ F1 \: h6 j' ]6 _# s% m/ Y - // ==== Generic Wait Functions ====
' I# d& b' I( @8 B -
4 W- j4 S5 n4 R- Z! I2 p - /// Wait for Timeout (Time Delay).
+ T/ @2 e+ \# q5 X; G/ D1 ` - /// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value
& w( A4 ^" `6 l" j( L# ]6 `* T - /// \return status code that indicates the execution status of the function.
# K6 m; C% @) n/ L' `- l- K+ t - osStatus_t osDelay (uint32_t ticks);/ r( p$ a0 F4 `
-
5 I' d2 j& P, O2 b( O" ~; s' C2 z - /// Wait until specified time.
" Y7 n+ l1 r9 b - /// \param[in] ticks absolute time in ticks
1 M2 W$ l3 g/ ]! `" d - /// \return status code that indicates the execution status of the function.
$ L1 V9 \; n5 k# | - osStatus_t osDelayUntil (uint32_t ticks);
' m3 D5 g; u0 r- @$ |' b) R -
6 ^8 S0 S; x: Z9 `; M. J& n- ^: J -
/ M0 k5 x( B F& T# X - // ==== Timer Management Functions ====( `, `) l' m! R1 G( i# K* T
-
; w& t% J- T- v, `7 a& b9 \ - /// Create and Initialize a timer.
8 j1 @, M+ j7 h& @# H3 U - /// \param[in] func function pointer to callback function.
' T f. i, c) Y1 n$ E - /// \param[in] type \ref osTimerOnce for one-shot or \ref osTimerPeriodic for periodic behavior.% q8 ^7 T; s3 M6 t9 c2 \
- /// \param[in] argument argument to the timer callback function.% T7 }1 ]& a5 E: B# N; R! t0 P4 \3 H
- /// \param[in] attr timer attributes; NULL: default values.6 T* E' x- W: |) j* F4 Z2 ?
- /// \return timer ID for reference by other functions or NULL in case of error.8 l# s# R) [ o" O) Z j( ~! v
- osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
# P3 z+ R, p; d; ] -
+ Z3 Q) @% R( V) T: W; E5 C y - /// Get name of a timer.# U# I5 \( L8 f9 e( }, s
- /// \param[in] timer_id timer ID obtained by \ref osTimerNew.
' R! |; y' @7 D( @6 G0 P V - /// \return name as NULL terminated string.
9 X2 r+ }# u/ p' [ - const char *osTimerGetName (osTimerId_t timer_id);0 v! ~) b! @4 P7 }; G
-
+ [) I# L4 q1 y8 u. T6 I% d9 w - /// Start or restart a timer.8 H6 f% _- N- G0 L4 R! n
- /// \param[in] timer_id timer ID obtained by \ref osTimerNew.0 z' x% N7 ^4 |4 l2 i2 e
- /// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value of the timer.! v; h* Z4 ~* v/ }& s
- /// \return status code that indicates the execution status of the function.
5 }1 }$ i" t& Y2 R3 h - osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks); k+ i+ L! p U% {1 g$ }
- # p+ i7 ^2 |; g9 u7 H8 t0 ^/ P
- /// Stop a timer. l' f; I/ w6 s$ D( h! l3 Q" m; O
- /// \param[in] timer_id timer ID obtained by \ref osTimerNew.
7 ?9 P+ ?& v, a/ w% T& F/ B - /// \return status code that indicates the execution status of the function. v2 \ O+ a2 p: @5 M9 O+ y
- osStatus_t osTimerStop (osTimerId_t timer_id);
. H2 ?8 D0 b/ Q7 r; s. [ - . c" j, w$ `0 \; _) _- s) g
- /// Check if a timer is running.
- ?, v1 n' @ t$ k' \2 V: k1 S - /// \param[in] timer_id timer ID obtained by \ref osTimerNew.
$ F8 I |/ N0 n+ N2 `$ r# M& F - /// \return 0 not running, 1 running./ W8 m0 b4 C" n
- uint32_t osTimerIsRunning (osTimerId_t timer_id);
' w' I. X; u# z1 ? - 1 K$ D% v/ | t& N
- /// Delete a timer.( ?9 G7 V0 G: @$ \6 q3 S; o
- /// \param[in] timer_id timer ID obtained by \ref osTimerNew.
0 F4 q: I1 P" U7 B% T: Q2 r2 G* ^! z0 c - /// \return status code that indicates the execution status of the function.: g$ I+ i) W: Z) i/ E
- osStatus_t osTimerDelete (osTimerId_t timer_id);
( j$ r. ]! u& l -
! ~% o& |; X* j; [3 T9 z; C+ i- o3 ? - # ^- g1 v2 o; C" H
- // ==== Event Flags Management Functions ====: y# l. Q/ E" A0 S2 s
- & A. J8 Y5 A6 h
- /// Create and Initialize an Event Flags object.' S. ]9 t% L: J2 o9 H& g1 m
- /// \param[in] attr event flags attributes; NULL: default values.& ?1 B# C: Y5 ?8 [' c- q# Z
- /// \return event flags ID for reference by other functions or NULL in case of error.
. e# L: |' a( s- j; ? - osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr);
0 A! R/ R* }1 e9 G -
7 @) V3 t, p9 a9 ?! ]* b - /// Get name of an Event Flags object.
: p, m/ M. M% _3 }2 [$ A - /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.- X! z! |+ a7 V
- /// \return name as NULL terminated string.
+ V) B& k! }. T$ j - const char *osEventFlagsGetName (osEventFlagsId_t ef_id);
) |0 ]/ [( r6 w$ P - , V- w( f* ]# j* g; H+ H
- /// Set the specified Event Flags.2 w+ g, |" \: h. H& v
- /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
$ I( d0 {* q# q4 t O l" E2 L% k - /// \param[in] flags specifies the flags that shall be set.
" j# j( l3 {. z - /// \return event flags after setting or error code if highest bit set.
5 n9 L. g- E% @* y - uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags);
" P$ Q9 Y% v$ H# t, s* ? - " Q6 @7 N, Q% o% Y5 m+ r: `
- /// Clear the specified Event Flags.1 i+ C) y! g( P/ ^% X v6 R# L
- /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
8 o: z* i+ k: B/ M$ x3 A - /// \param[in] flags specifies the flags that shall be cleared.4 p1 V2 }5 ]4 W& C# E: M
- /// \return event flags before clearing or error code if highest bit set.; r2 L. i2 r( V& u
- uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags);. n4 [3 j' A7 D7 P
- 0 O; M5 m8 S! j5 F6 T( R- M
- /// Get the current Event Flags.
* K W$ ]0 K U t# m! w - /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.$ L7 a- s; {# \! m( t" e
- /// \return current event flags.
, P: \# F" M, j, w* z, w - uint32_t osEventFlagsGet (osEventFlagsId_t ef_id);; v ~4 |% [* ^: l
-
/ x, f0 A3 ^; x. e( n! o8 Y' J - /// Wait for one or more Event Flags to become signaled.
) \, t" k3 Z% T4 y - /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
" w3 P; l0 z* \0 e* ~0 e; R! q8 w4 v - /// \param[in] flags specifies the flags to wait for.
4 H) T3 Y5 S9 D- U- H1 l! W" Q - /// \param[in] options specifies flags options (osFlagsXxxx).' G# m. S3 P) q. D2 ]5 I
- /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.3 K" K4 h1 {/ L2 n6 e
- /// \return event flags before clearing or error code if highest bit set.
- A5 x4 S R0 _4 D$ _, j+ V5 b - uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);. R# ^9 {! s; {3 [9 U* t
-
! {9 `. l1 ~6 ?0 K, c. {$ U. H* N - /// Delete an Event Flags object.
2 a) z5 C0 ^, y+ j2 Y. {7 A - /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.9 j# C- s9 c, b- b' b
- /// \return status code that indicates the execution status of the function.- y* P8 _) ^2 c- l7 S
- osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id);
& p3 u- M2 f1 Q* x -
7 V+ a8 X* @% {& e8 B1 J) x3 Y -
6 y7 z, T* l6 z# m - // ==== Mutex Management Functions ====
4 j4 V6 p1 A/ D8 x* x, X4 i -
$ E2 ~9 G+ _- b: I& A* o - /// Create and Initialize a Mutex object.! p! w. k% \& \* T6 R Z; ^
- /// \param[in] attr mutex attributes; NULL: default values.7 _ y6 w$ l I/ ]9 F8 @1 ^2 N. H
- /// \return mutex ID for reference by other functions or NULL in case of error.
1 ]& }" z' c$ K7 A4 a1 ^- a- q - osMutexId_t osMutexNew (const osMutexAttr_t *attr);
- D9 R& Q' H, B( t0 ?" M7 x - S2 F1 T8 f. g( M% B7 K' ~& h. S" R
- /// Get name of a Mutex object.* ]% {5 v5 m, V5 p0 q& y( Y
- /// \param[in] mutex_id mutex ID obtained by \ref osMutexNew.
' j K$ h& M a) x. ?9 L - /// \return name as NULL terminated string.* x( S$ P U2 G; J
- const char *osMutexGetName (osMutexId_t mutex_id);
* o& _0 V! O) T! z+ C# U -
9 U/ g- h& X9 @* J. Z$ S - /// Acquire a Mutex or timeout if it is locked.8 t; O7 ? s) l6 j; X
- /// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. ?( e4 `! _5 x* P
- /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. Z- I1 V# }2 B3 y" b5 |/ ~
- /// \return status code that indicates the execution status of the function.
! [2 t; v* P8 b - osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout);
2 D3 `2 s$ I1 Y( w, i6 F -
* u$ \7 W0 n1 _6 X. B - /// Release a Mutex that was acquired by \ref osMutexAcquire.
; |' u% y4 _' L4 Z - /// \param[in] mutex_id mutex ID obtained by \ref osMutexNew.
3 ~! i3 o1 m: f) { - /// \return status code that indicates the execution status of the function.
. E6 G8 w. q; r5 p4 w D9 i - osStatus_t osMutexRelease (osMutexId_t mutex_id);
, j* e0 u2 G+ V - 4 }, r7 Q' e- D' j9 n; t! x
- /// Get Thread which owns a Mutex object.
" G& m, f2 s' N. h$ _7 P( t' |$ O, f! H4 e& D - /// \param[in] mutex_id mutex ID obtained by \ref osMutexNew.# h+ f; v3 v* N0 ]0 D7 H
- /// \return thread ID of owner thread or NULL when mutex was not acquired.
6 p3 q& v. ~) { O - osThreadId_t osMutexGetOwner (osMutexId_t mutex_id);* i8 L: z3 Q" D3 b( T3 }& ^. D
- / @* \1 g; z6 t' L
- /// Delete a Mutex object.- q0 Y1 A5 |- ^2 [- n. j
- /// \param[in] mutex_id mutex ID obtained by \ref osMutexNew.
! u# n# n0 Y4 P9 U - /// \return status code that indicates the execution status of the function.- R! f+ I* F! q" R6 v1 G
- osStatus_t osMutexDelete (osMutexId_t mutex_id);
; ?) n* r% A4 E5 M. m5 a; ] - + S! j! i% d# v5 f* F+ M" q
- _6 d m7 s1 N% A
- // ==== Semaphore Management Functions ==== _# {0 b6 m# ]3 B# b9 |; E4 L3 c+ C
-
; K! G0 h) r0 b: {1 `( `# N$ x# h8 g - /// Create and Initialize a Semaphore object.# e7 R$ m. A* ?7 R4 P
- /// \param[in] max_count maximum number of available tokens.
; S' Q; o7 U: ]1 P* A - /// \param[in] initial_count initial number of available tokens.
. T+ c$ p/ ]7 u+ k3 _ - /// \param[in] attr semaphore attributes; NULL: default values.
) l2 y: N. L1 c& b* @! n - /// \return semaphore ID for reference by other functions or NULL in case of error.- @( x8 b$ n8 Z B
- osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr);& K; [6 [* E) ~. f- J0 P! G% z) q
- 7 Q2 h& \: v( U% M* K
- /// Get name of a Semaphore object.
; z7 }& p0 ?4 B# ]" ]3 G - /// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew.
3 r. f# S3 ^2 _+ m( y% I - /// \return name as NULL terminated string.
7 |5 K: M. F, {; E4 S) i+ X - const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id);
* V: `1 [% @- y -
: Z4 {: e2 w- F# Q1 @ - /// Acquire a Semaphore token or timeout if no tokens are available.2 w4 T, f+ u" y) e# @+ n1 a
- /// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew.4 r6 Y- m! k" a0 O/ b
- /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
9 W4 R* _7 T- ~% s- H# l - /// \return status code that indicates the execution status of the function.
+ s" j1 P- \6 h- X d - osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout);: w1 Z5 E' _' A) K0 Q3 v4 f
- " h9 \$ X C' X% o3 A- R
- /// Release a Semaphore token up to the initial maximum count.
* q0 n& P3 ^3 V: k1 d - /// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew.
4 h' S6 m& a- f6 q - /// \return status code that indicates the execution status of the function.
8 [1 X. {7 `( E5 h - osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id);$ Z" J; I" G7 Q! o+ n" ~6 D
-
) o! {. Y4 z9 v ~# G - /// Get current Semaphore token count.( N3 o W' S" X: h7 n+ }$ m
- /// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew.9 y- c$ n9 S! [8 V
- /// \return number of tokens available.
; S( Y& k( F: {2 J - uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id);
! V) w3 i0 N$ k0 p - ) E7 d) r/ c6 F
- /// Delete a Semaphore object.
# c3 ?' Q' |$ b" f4 y7 V( T - /// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew.
- [8 w. w* q/ D# v% Y - /// \return status code that indicates the execution status of the function.# q* m" v+ D1 U. E* U. M: i
- osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id);6 K% |9 `; O/ v. |& ?
- . E7 k& _' r e
-
: r% \0 F% v! N" w! |( \* {4 Y - // ==== Memory Pool Management Functions ====
0 D. `: h5 b6 Y2 r: i -
: k) x( x8 y# y; s% T/ J: ~1 j - /// Create and Initialize a Memory Pool object.$ Q7 j- _+ Y; g& a {
- /// \param[in] block_count maximum number of memory blocks in memory pool.
+ t8 V# \4 V( {! a - /// \param[in] block_size memory block size in bytes.0 `# M; E$ v- j k
- /// \param[in] attr memory pool attributes; NULL: default values.
. V" M0 e6 s& Q, e - /// \return memory pool ID for reference by other functions or NULL in case of error.
8 v" b5 q) z% @: y# ?+ X - osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr);
; s4 A% ?' @* y - . |6 M* _$ f2 {2 Z* }. J
- /// Get name of a Memory Pool object.& r* Q+ ^# \$ u; a" Y8 Y/ r5 a
- /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.
. a" B, P- m& {: R4 ] - /// \return name as NULL terminated string.
4 ]; e* s- W$ r1 Q7 B: p - const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id);7 N! `: c/ O; R3 w ^9 D
- % e0 ]1 r4 L0 x% f
- /// Allocate a memory block from a Memory Pool.9 c; `; ]6 h( a
- /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.9 v- ^( o6 X+ I$ b- B2 w
- /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out." ^# x, |! E8 h; P5 h& \
- /// \return address of the allocated memory block or NULL in case of no memory is available., E; E- ^% M2 N5 n; j/ K* f7 Q* z
- void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout);
2 Y' j, s) y2 b$ n, I& _7 R - 4 a7 j, G4 R# S% F8 w% N
- /// Return an allocated memory block back to a Memory Pool.! ~" w& @, g; P1 T' ?
- /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.
8 A# ~+ ^$ @/ l6 I) G' n - /// \param[in] block address of the allocated memory block to be returned to the memory pool.
o, W8 N" H1 N4 Z - /// \return status code that indicates the execution status of the function.* C1 v8 w; D5 x1 L7 o
- osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block);8 O) J: k: r. y& F l
- 9 c2 j$ u" U! [1 I
- /// Get maximum number of memory blocks in a Memory Pool.
7 C1 w- O4 A/ _) a - /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.
) z$ W j. f: d& _/ _4 F - /// \return maximum number of memory blocks.
9 u7 J' r" w, D! S4 j& W8 i4 W - uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id);
1 ?0 H' c) h. _7 p* i# P. u/ e -
B7 f& F3 A8 Z7 G- x. r+ ^ - /// Get memory block size in a Memory Pool.) Y3 U4 G5 B" [$ n* H
- /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.
, |' [$ x+ w7 n! Y2 c6 _ - /// \return memory block size in bytes.1 V6 l% O5 M! q/ s
- uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id);
, p, H' c9 F5 J - 6 Q4 B" Y M( B- H
- /// Get number of memory blocks used in a Memory Pool.! o& P. Q. k2 P; V& H% ], E
- /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.' p0 T+ I; [; v8 w `
- /// \return number of memory blocks used./ H0 y3 J H# ^6 k
- uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id);( w9 t+ |" M: W: H w3 ]
-
) i6 d+ v i; i- g/ q: ^ - /// Get number of memory blocks available in a Memory Pool. h; g+ O0 F2 K. [+ g) }) `7 {
- /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.; ~, _; j3 m: |
- /// \return number of memory blocks available.
& u" P0 D* U. k1 `0 ?7 N - uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id);
8 u2 D. I( ^8 A/ ]; G' U -
z& G# C% G/ S% s - /// Delete a Memory Pool object.
, ?6 j' c I* ^# E: g( S" d+ B - /// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew.
' C" \+ |' v1 F1 l- q# l - /// \return status code that indicates the execution status of the function.
$ D. L8 l3 K/ b - osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id);' M) s' h. P1 h. @( L
-
1 U1 q9 ~" u6 V. Y' W' } -
/ r/ {: W: O7 m* Q! G - // ==== Message Queue Management Functions ====0 \6 W. v2 w2 S! t- @
- ; m7 p8 K- L8 ]. Q
- /// Create and Initialize a Message Queue object.: j7 s& [0 [% G# e) a
- /// \param[in] msg_count maximum number of messages in queue.
+ ~! g3 _ {' X1 S7 a5 ~3 @ - /// \param[in] msg_size maximum message size in bytes.
! K" Q- Z6 R& g. [2 L - /// \param[in] attr message queue attributes; NULL: default values.
, F/ J4 @! o: H5 j `! k1 ^ - /// \return message queue ID for reference by other functions or NULL in case of error.& M) v+ T5 |0 i! n; s2 g5 ]& m
- osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr);
$ ~7 g' x% _; C: q - 6 @5 q, F. y% F( U! e
- /// Get name of a Message Queue object.: v: O7 ]$ ~: ]
- /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew./ @* n2 G2 d; r: J4 s
- /// \return name as NULL terminated string.
! k5 w- G) U& N( `/ N - const char *osMessageQueueGetName (osMessageQueueId_t mq_id);- t9 x* _! q% b1 D8 |8 I' _
-
. q2 s6 \ H' N! k8 A! d* K - /// Put a Message into a Queue or timeout if Queue is full./ h3 N2 c1 E! ~/ Z) u: @
- /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.
5 s5 y* c0 U% d: ` - /// \param[in] msg_ptr pointer to buffer with message to put into a queue.) k5 `( z! L' ~: d" w
- /// \param[in] msg_prio message priority., q# A, Q7 @2 O: W! i2 |
- /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
, { D9 G' m4 s8 a Q k - /// \return status code that indicates the execution status of the function.- S x2 _) p- A' v, M5 P( R
- osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout);
8 p1 `' ^9 E2 Z6 X5 |) r - % K. L) [# y: x' h
- /// Get a Message from a Queue or timeout if Queue is empty.
& C3 z( ^ W t3 R) d - /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.
) D0 Z# i- w J- j - /// \param[out] msg_ptr pointer to buffer for message to get from a queue.
: E1 H; ^: i/ S# t2 V. t - /// \param[out] msg_prio pointer to buffer for message priority or NULL.1 H/ H6 t, G% r& X
- /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.4 D( p+ M) a9 u
- /// \return status code that indicates the execution status of the function." \) H0 A* o5 C7 x( H9 i
- osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout);
]1 S1 L2 j1 z+ E) W -
4 X; D- U% l; A - /// Get maximum number of messages in a Message Queue.- e6 |7 P- t" J; [; B4 A
- /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.
- w. `6 Q" g) t$ E n9 ~ - /// \return maximum number of messages.
" J7 |/ h' R) i+ |7 P - uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id);
# ^, ]+ B2 w: B. j, e/ | - 7 Q7 H+ t: I/ u7 e$ F
- /// Get maximum message size in a Memory Pool.
{6 u( M( c1 S% M/ y. j - /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.
5 X K% a- z; ^; i/ ~, c - /// \return maximum message size in bytes.
0 ^# ^$ y0 v, x, l9 Q% S - uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id);
8 c2 v% d! _6 x. t. ]( h -
1 \7 j; P a, U - /// Get number of queued messages in a Message Queue.
- D% U/ l$ }" {; T9 G3 X/ Y) q: w; O - /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.0 U: ?4 m5 y/ q& T3 {4 f/ v
- /// \return number of queued messages.
, N" V' } t: R - uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id);
9 r. h2 G6 w N5 C* J q2 Z' Q -
9 Q6 B$ y" H# @* I" o1 \ - /// Get number of available slots for messages in a Message Queue.0 d# f8 @7 u0 M- R
- /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.5 R1 \( B2 s, {3 S; {
- /// \return number of available slots for messages.$ _( x5 g9 g8 r
- uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id);
. @' I. Z3 ~( Q - , R: W% x5 P6 X9 G1 L
- /// Reset a Message Queue to initial empty state.* y5 ^# u" y0 c: m# @7 q8 S# h
- /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.
8 y- p1 V4 W$ b8 F! [ - /// \return status code that indicates the execution status of the function.
" Y2 \5 ]7 U+ J5 m - osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id);: l1 v+ ^' j0 L: R- I! F
-
' Q1 F; K& r' q7 X) y$ p- {7 \6 D - /// Delete a Message Queue object.3 f* L' D' n: O/ J2 C: U7 I
- /// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew.: J3 b/ F6 j2 j4 o5 | q1 {3 C
- /// \return status code that indicates the execution status of the function.
7 @! b+ f+ l' ^2 J - osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id);
5 _" G4 Y, d# Q2 g6 \, w- { -
1 O7 n% G- y) k4 u - ! b- m5 p$ ~5 ?0 {: A. E
- #ifdef __cplusplus% a; Z5 J) K" a' E
- }4 f4 R- V l4 L* S
- #endif
& I0 w! q$ H* | -
2 r" n* c* a4 q# H6 \ - #endif // CMSIS_OS2_H_
复制代码
) {# H7 r5 D/ X) ]7 }归档链接:
, T' F" b+ o% Y5 Q- B: |CMSIS-RTOS2 文档翻译 之 简介 o. Y( x c: W# }* k. ?$ s$ h4 A
CMSIS-RTOS2 文档翻译 之 修订记录( u4 v0 Z& _6 q& m
CMSIS-RTOS2 文档翻译 之 功能概述5 x- ~2 r* ^8 y' x
CMSIS-RTOS2 文档翻译 之 RTOS 验证 |
就是相关的教程和文档比较少,用的人比较少,你很有前瞻性啊。
之前都是自己封装RTOS的接口,发现cmsis_os后,既然都有统一的接口,干脆就拿来用了,比自己封装的要好很多
刚去你 GitHub 逛啦一圈