本帖最后由 XinLiYF 于 2018-4-22 21:59 编辑
! [" c6 h0 P7 \3 U- a% }, B+ Y
6 K1 j: f4 W" l6 N: o$ P通用 RTOS 接口
& x1 _+ R3 ^8 y* y8 G* W+ I% U
/ i& r" c- x5 j7 k; J8 P. {% G5 M6 ACMSIS-RTOS2 是一个通用的 API ,不受底层 RTOS 内核的影响。应用程序员在用户代码中调用 CMSIS-RTOS2 API 函数以确保从一个 RTOS 到另一个 RTOS 的最大可移植性。使用 CMSIS-RTOS2 API 的中间件可以避免不必要的移植工作。 X+ v6 v& o D7 S

- H9 e# C3 }; c8 VCMSIS-RTOS API 结构& c# B) ?: S: I4 @ z! c
0 `& L& T5 I* o2 f
典型的 CMSIS-RTOS2 API 实现与现有的实时内核接口。CMSIS-RTOS2 API 提供以下属性和功能:
% e& [6 y( w! Y8 o: c* o; X$ N& |- 函数名称,标识符和参数是描述性的,易于理解的。这些功能强大而灵活,减少了暴露给用户的功能数量。
- 线程管理允许您定义,创建和控制线程。
- 中断服务程序(ISR)可以调用一些 CMSIS-RTOS 功能。 当 CMSIS-RTOS 函数不能从 ISR 上下文中调用时,它会拒绝调用并返回错误代码。
- 三种不同的事件类型支持多个线程和/或 ISR 之间的通信:) r9 N. }$ B9 y! e/ @6 e
- 线程标志: 可用于向线程指示特定条件。
- 事件标志: 可用于向线程或 ISR 指示事件。
- 消息: 可以发送到线程或 ISR 。消息缓冲在队列中。
f# D6 t- u# l8 [4 A) l5 t0 P
- 互斥管理和信号量已合并。
- CPU 时间可以安排以下功能:; h2 o9 X6 o3 ~* |6 V' H5 B0 y& j F
- 超时参数包含在许多 CMSIS-RTOS 功能中,以避免系统锁定。当指定超时时,系统会等待,直到资源可用或发生事件。在等待时,运行其他线程。
- osDelay 和 osDelayUntil 函数将线程置于 WAITING 状态一段指定的时间。
- osThreadYield 提供协作式线程切换并将执行传递给具有相同优先级的另一个线程。
% L0 l7 M4 S, L/ h1 s2 w7 E
- 定时器管理功能用于触发功能的执行。
. b7 F" t6 S% R6 ^0 H% H , R0 t5 D1 O; X0 V7 f. b
CMSIS-RTOS2 API 旨在通过 Cortex-M 存储器保护单元(MPU)选择性地整合多处理器系统和/或访问保护。
3 j& }- k' u+ {" V在一些 RTOS 实现中,线程可能在不同的处理器上执行,因此消息队列可能驻留在共享内存资源中。 1 z* X! j# X1 g6 X5 X, V0 |
CMSIS-RTOS2 API 鼓励软件行业发展现有的 RTOS 实施。实时操作系统的实现可以在针对 Cortex-M 处理器的不同方面进行不同的优化。可选功能可能是例如
( Y( z! {$ \" A/ ?4 \0 ^6 ~- u4 `- 支持 Cortex-M 内存保护单元(MPU)。
- 支持多处理器系统。
- 支持 DMA 控制器。
- 确定性上下文切换。
- 循环上下文切换。
- 避免死锁,例如优先倒置。
- 通过使用 Armv7-M 指令 LDREX 和 STREX 来实现零中断延迟。9 m* k, K$ F' z( _/ }; _0 J; T( {2 s
6 W; @* U% d* r% B% o) [" _; @
使用 CMSIS-RTOS2 实现* F$ ~) W+ X4 R* I/ }# ?* K
CMSIS-RTOS2 实现通常作为库提供。要将 RTOS 功能添加到现有的基于 CMSIS 的应用程序中,需要添加 RTOS 库(通常是一个或多个配置文件)。有一个新的头文件 cmsis_os2.h 可用。这是完全可移植应用程序所需的唯一头文件。在这种情况下,不能使用用户为控制块,对象数据和线程堆栈提供的内存。或者,您可以包含一个实现特定的头文件(例如 rtx_os.h),该文件还提供了用于资源分配的定义(例如控制块的大小,对象数据和线程堆栈所需的内存)。 这是可选的,意味着应用程序代码不是完全可移植的。 7 n" ~7 N9 l7 ^; U6 G2 N, r

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