本帖最后由 XinLiYF 于 2018-4-22 21:59 编辑 5 J* Y8 `9 w/ E. {
) z+ ?8 X/ j/ G" r S
通用 RTOS 接口
+ D4 [0 b: @, A2 A, G+ f% j8 _ + h5 w. p9 [4 u
CMSIS-RTOS2 是一个通用的 API ,不受底层 RTOS 内核的影响。应用程序员在用户代码中调用 CMSIS-RTOS2 API 函数以确保从一个 RTOS 到另一个 RTOS 的最大可移植性。使用 CMSIS-RTOS2 API 的中间件可以避免不必要的移植工作。
3 B9 c/ S. Q u6 w9 J U
1 k9 M9 q" M) D- @! X w/ X1 fCMSIS-RTOS API 结构3 ?; Y. m3 u; t1 m9 _5 h
( z( Z4 P+ r' q) O
典型的 CMSIS-RTOS2 API 实现与现有的实时内核接口。CMSIS-RTOS2 API 提供以下属性和功能:
7 |% k& h+ ^7 ~' m- k- 函数名称,标识符和参数是描述性的,易于理解的。这些功能强大而灵活,减少了暴露给用户的功能数量。
- 线程管理允许您定义,创建和控制线程。
- 中断服务程序(ISR)可以调用一些 CMSIS-RTOS 功能。 当 CMSIS-RTOS 函数不能从 ISR 上下文中调用时,它会拒绝调用并返回错误代码。
- 三种不同的事件类型支持多个线程和/或 ISR 之间的通信:
5 V% I- a6 g- L6 ?& ^- Z; h7 K- 线程标志: 可用于向线程指示特定条件。
- 事件标志: 可用于向线程或 ISR 指示事件。
- 消息: 可以发送到线程或 ISR 。消息缓冲在队列中。" O1 y! I+ z8 T8 b; U& r( m& w
- 互斥管理和信号量已合并。
- CPU 时间可以安排以下功能:
( }& b+ c5 Q* e/ j- 超时参数包含在许多 CMSIS-RTOS 功能中,以避免系统锁定。当指定超时时,系统会等待,直到资源可用或发生事件。在等待时,运行其他线程。
- osDelay 和 osDelayUntil 函数将线程置于 WAITING 状态一段指定的时间。
- osThreadYield 提供协作式线程切换并将执行传递给具有相同优先级的另一个线程。7 L9 G# M2 M/ e/ F1 O% O& s
- 定时器管理功能用于触发功能的执行。
+ \/ _+ N0 K2 c3 A. L- ? 8 Z/ G! s2 C/ w. w. R6 k" s
CMSIS-RTOS2 API 旨在通过 Cortex-M 存储器保护单元(MPU)选择性地整合多处理器系统和/或访问保护。 & i3 a& q$ a# R
在一些 RTOS 实现中,线程可能在不同的处理器上执行,因此消息队列可能驻留在共享内存资源中。 : b/ |0 b6 W8 F4 z; O' E8 ~6 Q: Y
CMSIS-RTOS2 API 鼓励软件行业发展现有的 RTOS 实施。实时操作系统的实现可以在针对 Cortex-M 处理器的不同方面进行不同的优化。可选功能可能是例如 8 M' s2 p; ?: ^4 i' i' A
- 支持 Cortex-M 内存保护单元(MPU)。
- 支持多处理器系统。
- 支持 DMA 控制器。
- 确定性上下文切换。
- 循环上下文切换。
- 避免死锁,例如优先倒置。
- 通过使用 Armv7-M 指令 LDREX 和 STREX 来实现零中断延迟。
, Q z' i& z# Z9 s& e& z8 y 2 d4 e3 E, e* ^5 L+ Q* Z
使用 CMSIS-RTOS2 实现* C0 ^% @: i- c% U% K0 S
CMSIS-RTOS2 实现通常作为库提供。要将 RTOS 功能添加到现有的基于 CMSIS 的应用程序中,需要添加 RTOS 库(通常是一个或多个配置文件)。有一个新的头文件 cmsis_os2.h 可用。这是完全可移植应用程序所需的唯一头文件。在这种情况下,不能使用用户为控制块,对象数据和线程堆栈提供的内存。或者,您可以包含一个实现特定的头文件(例如 rtx_os.h),该文件还提供了用于资源分配的定义(例如控制块的大小,对象数据和线程堆栈所需的内存)。 这是可选的,意味着应用程序代码不是完全可移植的。
) j P8 X9 s: _2 r; p0 B# g

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