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