你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

CMSIS-RTOS2 文档翻译 之 通用 RTOS 接口

[复制链接]
XinLiYF 发布时间:2018-4-21 15:48
本帖最后由 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
代码示例
  1. /*----------------------------------------------------------------------------
    " E; v' e/ |: ^
  2. * CMSIS-RTOS 'main' function template
    1 ~4 D# I: g7 u4 e2 O4 D, }
  3. *---------------------------------------------------------------------------*/- X# V6 y$ V: I' m' F: x, ^

  4. ' U( `5 ^+ f: D( r" j
  5. #include "RTE_Components.h"
    ! h! P, ~, r9 P8 ^! E4 E0 }
  6. #include  CMSIS_device_header2 {1 Q% e5 {, e5 a4 h
  7. #include "cmsis_os2.h"
    ; J6 O% I2 e: y8 k1 L1 R
  8. & j8 Q2 }; D' T# Z% j" V6 ]2 Y, E
  9. /*----------------------------------------------------------------------------
    - v. _: c" A8 n! ?: j7 Z8 K6 @
  10. * Application main thread
    5 {( g: S' X' }; I' u; Z
  11. *---------------------------------------------------------------------------*/9 E# T1 J3 O. X  d5 p
  12. void app_main (void *argument) {3 @& k1 x* o4 F: W! ~  M2 n
  13. 5 K1 D5 C8 G8 ~" ~1 ^
  14.   // ...+ L, R% a1 x! c* Z" o
  15.   for (;;) {}3 y, }6 h1 P  A: A
  16. }
    ! ]$ a0 l2 q0 E3 h! r6 z

  17. , M8 Y* e; W+ J% O6 ~# W
  18. int main (void) {  W$ R- E! }  e3 D2 w  r+ Y

  19. ( F4 Q+ ]" G8 V3 Y" A' B
  20.   // System Initialization
    9 S# D0 Q$ y$ d+ c; j4 w6 P  w
  21.   SystemCoreClockUpdate();) E; c6 Y* g4 ]: T$ G& }
  22. #ifdef RTE_Compiler_EventRecorder  q; M$ z: ?/ c1 p  Y
  23.   // Initialize and start Event Recorder7 R# Y6 q, p, i& g% O+ E! y1 D* V
  24.   EventRecorderInitialize(EventRecordError, 1U);
    & d* J8 J( ^5 N7 c% X
  25. #endif
    " V4 K) q3 x! D- F2 K2 P
  26.   // ...
    ' Y" K. g. X( Q$ t

  27. / \+ F; w& C& ~+ H' G7 z
  28.   osKernelInitialize();                 // Initialize CMSIS-RTOS0 A2 i3 r/ P$ J! w
  29.   osThreadNew(app_main, NULL, NULL);    // Create application main thread
    0 O5 Y, x) t' m+ h  }+ S
  30.   osKernelStart();                      // Start thread execution
    5 S9 p/ p" F# m4 t) |' u9 m' B
  31.   for (;;) {}
    # P* x% S( w) z2 x
  32. }
复制代码

( 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
  1. /*
    " b# N( j' {) ]4 c9 A
  2. * Copyright (c) 2013-2017 ARM Limited. All rights reserved.
    ( j  G7 b' y3 }& k! f
  3. *4 f9 s' {9 e9 T6 d) M  T# q$ `8 f
  4. * SPDX-License-Identifier: Apache-2.0+ l' l. k6 p8 c: ]
  5. *7 g5 z& q# G' Y+ g: L) N
  6. * Licensed under the Apache License, Version 2.0 (the License); you may7 a; T6 v0 q/ T% p
  7. * not use this file except in compliance with the License., W) ]% w  i0 _& ]) G
  8. * You may obtain a copy of the License at
    ( a) k0 E, E8 l9 h
  9. *
    " q! X6 k. H7 V( @/ B4 Z
  10. * www.apache.org/licenses/LICENSE-2.0. L  Z+ `4 @0 _; T8 ^; r1 P+ I
  11. *
    - ]3 \# _8 v* y0 N/ T- y7 l
  12. * Unless required by applicable law or agreed to in writing, software# ^3 Z/ M" |- f0 v  A
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
    " E% ?$ f  h: ]* G: W6 ?
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    $ B* x5 a2 E5 q$ C: b/ g
  15. * See the License for the specific language governing permissions and( Z* j% b& \8 m) X9 p
  16. * limitations under the License.
    / K- s; k5 ]0 G$ r! Q( o4 H
  17. *
    & j! d. V% L1 k  @: `
  18. * ----------------------------------------------------------------------' ?& R/ U( V+ J6 |
  19. *
    ! l3 O4 G7 J, X% M3 }* t
  20. * $Date:        30. October 2017) N+ z2 N6 {2 }) ~* o  g$ a8 M
  21. * $Revision:    V2.1.2
    3 ?' _# u( z$ N5 n) @
  22. *
    7 j# p) h- K/ B5 g9 e. L
  23. * Project:      CMSIS-RTOS2 API
    . s; E' @0 H- p) L  c
  24. * Title:        cmsis_os2.h header file
    0 Z0 e% `! e7 M/ _
  25. *& R% A* }5 P. l( `4 @3 R
  26. * Version 2.1.2
    : o; c5 e; `8 F2 \! Y, ?3 q
  27. *    Additional functions allowed to be called from Interrupt Service Routines:
    5 ~: P0 G$ k$ j; Q2 I1 K
  28. *    - osKernelGetInfo, osKernelGetState
    $ Y! U9 y5 m8 T3 h
  29. * Version 2.1.1+ @" }' f* D, b( H: l) |
  30. *    Additional functions allowed to be called from Interrupt Service Routines:5 i* b8 m! p$ t/ {+ o6 e
  31. *    - osKernelGetTickCount, osKernelGetTickFreq
    ! r0 I+ I3 G2 c. v3 Q
  32. *    Changed Kernel Tick type to uint32_t:
    4 i0 g& B2 I/ r2 p3 u
  33. *    - updated: osKernelGetTickCount, osDelayUntil3 ]0 _' u2 T: z5 t4 P$ f
  34. * Version 2.1.06 h* U/ A' Y+ i  |5 J  V4 J2 H! [
  35. *    Support for critical and uncritical sections (nesting safe):& j! X& g! o) ]& X; Q2 d
  36. *    - updated: osKernelLock, osKernelUnlock
    2 K3 X' Q6 Y) y; I( c4 h
  37. *    - added: osKernelRestoreLock
    5 K( Z% K; q/ F( d7 y
  38. *    Updated Thread and Event Flags:
    ) Y2 y$ l- B2 k# X. T1 W
  39. *    - changed flags parameter and return type from int32_t to uint32_t
    & R: O, X& U& d/ F2 t& G5 n
  40. * Version 2.0.0
    # ?1 s! I2 `1 y9 p
  41. *    Initial Release
    * ~0 M" o! K' D9 S* \
  42. *---------------------------------------------------------------------------*/. }8 Z, U; \- L. [% H

  43. & x# a/ v6 j+ v, _. |2 K' q
  44. #ifndef CMSIS_OS2_H_% U7 W& A" }9 A3 q$ H3 S8 M
  45. #define CMSIS_OS2_H_
    7 s3 T  a& v% k0 z7 P5 i

  46. ! Y: r2 P& m* A
  47. #ifndef __NO_RETURN
    1 Q4 g3 q2 c8 @
  48. #if   defined(__CC_ARM)
    " C1 G8 @+ Z& v# y; C1 r* U
  49. #define __NO_RETURN __declspec(noreturn)
    2 Z& ]2 X% K' n% f0 r$ ^
  50. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)7 e4 |, I$ j/ I$ B$ J3 p# z
  51. #define __NO_RETURN __attribute__((__noreturn__))
    3 E8 Z4 _+ {# s% d/ v
  52. #elif defined(__GNUC__)
    7 i1 T8 U2 `( S4 ^. a
  53. #define __NO_RETURN __attribute__((__noreturn__))3 ^4 \2 i, N) |6 P3 [" `
  54. #elif defined(__ICCARM__)
    6 e" |7 \' m) y5 P) t; p1 Q
  55. #define __NO_RETURN __noreturn) @( n7 X& R7 G: m% s0 n
  56. #else6 I8 Q' V: c, N# I# y: @
  57. #define __NO_RETURN' z7 P% K4 y$ q! |
  58. #endif
    ) \! v+ y, c- r6 j
  59. #endif7 M" p* s/ j7 T
  60. ) ]9 f% ]0 p8 }, J
  61. #include <stdint.h>
    $ E4 N$ S3 {& i/ X/ }5 b  k! a
  62. #include <stddef.h>- i  `5 X  l3 f) h! T( N
  63. + m& C: J& U8 n. X! j/ G* W. s
  64. #ifdef  __cplusplus: X* @! Y+ S& w+ b
  65. extern "C"
    % p9 J6 k  A, e3 P7 J
  66. {9 C  L: {7 c4 l. h
  67. #endif* q- ^3 y) W( S4 o& g! p
  68. 0 j7 P/ H# |* \$ E2 j! b- W+ V

  69. 9 k0 D8 m0 W* d/ N- d$ h
  70. //  ==== Enumerations, structures, defines ====. o8 I, C  S" k
  71. 7 {  z' a% L  K; C
  72. /// Version information.. \: Y" z- T0 }, H3 |
  73. typedef struct {2 z5 o4 v1 q* t7 P. ^
  74.   uint32_t                       api;   ///< API version (major.minor.rev: mmnnnrrrr dec).
    * [9 i8 G8 q5 j* c& H7 l# w
  75.   uint32_t                    kernel;   ///< Kernel version (major.minor.rev: mmnnnrrrr dec).2 P1 _, Z2 F7 R8 [! ~2 _" h
  76. } osVersion_t;
    $ }9 S) o& ]* G9 o

  77. & ?6 S3 B. F( x, L6 P  O9 z: o* P
  78. /// Kernel state.0 H* k7 H; z0 a/ h' l
  79. typedef enum {) c! a" J+ t) f
  80.   osKernelInactive        =  0,         ///< Inactive.6 e7 i2 o/ k# F4 {- x6 j5 T
  81.   osKernelReady           =  1,         ///< Ready.
    . Y! y3 R  b: T4 X: R0 F' h
  82.   osKernelRunning         =  2,         ///< Running.% Q) o% q7 i7 ?$ o
  83.   osKernelLocked          =  3,         ///< Locked.
    9 D: E0 f  S7 H
  84.   osKernelSuspended       =  4,         ///< Suspended.
    7 N) k1 ^/ M# h. E  C1 J( b8 p* Q: E
  85.   osKernelError           = -1,         ///< Error.  l. }# Y( |' O
  86.   osKernelReserved        = 0x7FFFFFFFU ///< Prevents enum down-size compiler optimization.0 a) [7 j5 c5 Q' C2 T! r0 c' F
  87. } osKernelState_t;
    9 `* E1 x) I( r5 C5 e* H# Y8 E

  88. ! Q* U6 y5 x6 z% D
  89. /// Thread state.! O& }# W. @9 }- Y) i1 C- _1 t
  90. typedef enum {; H* p' H- S$ U/ Y3 S, y
  91.   osThreadInactive        =  0,         ///< Inactive.) e0 I- ^1 Q# c
  92.   osThreadReady           =  1,         ///< Ready.+ X+ p# E) z# k" x$ R# [5 s1 d/ Y0 i
  93.   osThreadRunning         =  2,         ///< Running.4 f3 m9 V/ {' S4 P4 Q' w
  94.   osThreadBlocked         =  3,         ///< Blocked.
    1 P$ B! y$ q! D, v7 R0 g
  95.   osThreadTerminated      =  4,         ///< Terminated.
    : E( [+ |, g$ B- K$ x  b
  96.   osThreadError           = -1,         ///< Error.
    5 e$ s6 ?/ s& G" |' u* B6 K
  97.   osThreadReserved        = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.
    7 h9 i7 m! d8 h. `7 F
  98. } osThreadState_t;
      _8 @- P: O+ ?, W, S: @5 e* q% r& p
  99.   j/ h6 v+ a  A; R. D* g# ~
  100. /// Priority values.
    6 y- n* U' X' z9 [/ y; V
  101. typedef enum {
      `! ~1 m6 U# R) N! q
  102.   osPriorityNone          =  0,         ///< No priority (not initialized).
    * d0 E+ n4 h- |2 Q4 b- ^
  103.   osPriorityIdle          =  1,         ///< Reserved for Idle thread.
    ) g! g: p9 d' y6 \/ x
  104.   osPriorityLow           =  8,         ///< Priority: low
    8 m/ C& P, |/ W  Z
  105.   osPriorityLow1          =  8+1,       ///< Priority: low + 1
    . s$ ~; o/ S; e% \" |0 x; A% }
  106.   osPriorityLow2          =  8+2,       ///< Priority: low + 26 }1 c. U2 ^7 J! _/ C* x' r
  107.   osPriorityLow3          =  8+3,       ///< Priority: low + 3
    4 w8 {+ `: }, K7 e6 r- ?6 c; G' z
  108.   osPriorityLow4          =  8+4,       ///< Priority: low + 4
    ( C8 a7 d6 t4 P" ?8 S# ]0 L, _
  109.   osPriorityLow5          =  8+5,       ///< Priority: low + 5" T& b. D0 ~' Z$ n- R
  110.   osPriorityLow6          =  8+6,       ///< Priority: low + 65 ?9 I4 O6 k' ]! S' w9 U4 Q7 u
  111.   osPriorityLow7          =  8+7,       ///< Priority: low + 7
    0 d% D4 h4 _% B1 M- `1 A
  112.   osPriorityBelowNormal   = 16,         ///< Priority: below normal( z) w* f) R; n9 i% b* V
  113.   osPriorityBelowNormal1  = 16+1,       ///< Priority: below normal + 1
    0 S5 l6 H8 g. X1 e) o% |3 C. e
  114.   osPriorityBelowNormal2  = 16+2,       ///< Priority: below normal + 2. ~  I/ F" G  ]' _) J' V! f
  115.   osPriorityBelowNormal3  = 16+3,       ///< Priority: below normal + 3
    , Q" B0 q4 D( }
  116.   osPriorityBelowNormal4  = 16+4,       ///< Priority: below normal + 4
    5 h* `  u- Q  a% n' W% Q
  117.   osPriorityBelowNormal5  = 16+5,       ///< Priority: below normal + 5: n+ C' r6 r" C- G# T
  118.   osPriorityBelowNormal6  = 16+6,       ///< Priority: below normal + 6) o% t. z* C' F- C" Q
  119.   osPriorityBelowNormal7  = 16+7,       ///< Priority: below normal + 7
    1 T  j) W, g4 |
  120.   osPriorityNormal        = 24,         ///< Priority: normal0 ?) o$ D. |# a4 U2 g* u1 y
  121.   osPriorityNormal1       = 24+1,       ///< Priority: normal + 1
    ( }2 z2 f* Y  U: \' [
  122.   osPriorityNormal2       = 24+2,       ///< Priority: normal + 28 [; F+ K" A2 M4 j; a. x: h( d0 ]
  123.   osPriorityNormal3       = 24+3,       ///< Priority: normal + 37 z; ^8 S; H/ c( r
  124.   osPriorityNormal4       = 24+4,       ///< Priority: normal + 4
    , d  C* `7 o: Y3 J# K& ^/ d4 O8 `5 ]5 Z
  125.   osPriorityNormal5       = 24+5,       ///< Priority: normal + 54 ?# _$ U: n0 J' p1 y: x( i
  126.   osPriorityNormal6       = 24+6,       ///< Priority: normal + 68 y$ F- o- m) ~
  127.   osPriorityNormal7       = 24+7,       ///< Priority: normal + 7
    % f( I# M% D! H8 ^  |$ M/ }3 r4 x1 y
  128.   osPriorityAboveNormal   = 32,         ///< Priority: above normal
    3 S: s/ S1 }# s$ ]0 P  O/ m( V0 Y
  129.   osPriorityAboveNormal1  = 32+1,       ///< Priority: above normal + 1
    2 m2 r3 C  S, d
  130.   osPriorityAboveNormal2  = 32+2,       ///< Priority: above normal + 2* m" i# I0 ]' g* }
  131.   osPriorityAboveNormal3  = 32+3,       ///< Priority: above normal + 3  `5 n( b) r2 \$ ?' V9 F
  132.   osPriorityAboveNormal4  = 32+4,       ///< Priority: above normal + 4
    1 [: e' A/ g* p9 O3 v
  133.   osPriorityAboveNormal5  = 32+5,       ///< Priority: above normal + 5* n( z0 b3 z5 `; T: t' p
  134.   osPriorityAboveNormal6  = 32+6,       ///< Priority: above normal + 6
    ! L4 L0 p% S! Z& {" \
  135.   osPriorityAboveNormal7  = 32+7,       ///< Priority: above normal + 7, ~: A" e3 |+ S- s# c5 k8 o
  136.   osPriorityHigh          = 40,         ///< Priority: high
    ( l+ D* ~; }* S- ]# K5 H# E4 r
  137.   osPriorityHigh1         = 40+1,       ///< Priority: high + 16 {8 P# X$ g' b, r
  138.   osPriorityHigh2         = 40+2,       ///< Priority: high + 2
    ( n7 L& A0 M4 p# k* B6 g4 f
  139.   osPriorityHigh3         = 40+3,       ///< Priority: high + 3' j8 m- N1 K# w; v* F9 v
  140.   osPriorityHigh4         = 40+4,       ///< Priority: high + 4
    . j$ F* g0 B- m) }
  141.   osPriorityHigh5         = 40+5,       ///< Priority: high + 51 V5 e7 ]7 U) w, B: c
  142.   osPriorityHigh6         = 40+6,       ///< Priority: high + 6
    0 A% c, d2 p/ J8 Y- C3 A
  143.   osPriorityHigh7         = 40+7,       ///< Priority: high + 7
    2 l1 G1 V: q5 @. a" q
  144.   osPriorityRealtime      = 48,         ///< Priority: realtime
    / y' L5 \  k4 |5 G, u
  145.   osPriorityRealtime1     = 48+1,       ///< Priority: realtime + 1. p3 Z# u6 M" p6 d6 @7 f0 r% M
  146.   osPriorityRealtime2     = 48+2,       ///< Priority: realtime + 28 {5 }& H8 @8 L- w
  147.   osPriorityRealtime3     = 48+3,       ///< Priority: realtime + 3( n4 h9 t; i+ {. ?* S: X
  148.   osPriorityRealtime4     = 48+4,       ///< Priority: realtime + 4
    ( ~6 C, J/ _& N( M1 f- k
  149.   osPriorityRealtime5     = 48+5,       ///< Priority: realtime + 5
    8 Z7 q5 J0 U8 V6 }
  150.   osPriorityRealtime6     = 48+6,       ///< Priority: realtime + 6- H9 G( |5 i8 g7 e3 u) j
  151.   osPriorityRealtime7     = 48+7,       ///< Priority: realtime + 7
    1 c$ B7 M) [8 A: q2 u- `
  152.   osPriorityISR           = 56,         ///< Reserved for ISR deferred thread.+ U6 ]. F; d) y) `" ]: t
  153.   osPriorityError         = -1,         ///< System cannot determine priority or illegal priority.3 A1 ^" |9 c7 H- w( R8 U
  154.   osPriorityReserved      = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.$ y; X3 I" E" ?- }
  155. } osPriority_t;
    0 [8 j, y. p( j3 p3 V! l
  156. ) _: N: B; A' k/ [, N( k
  157. /// Entry point of a thread.  T6 c3 Y  {/ p  C# i* C
  158. typedef void (*osThreadFunc_t) (void *argument);7 z7 l/ o0 A! {5 C

  159. 1 V& x1 U3 t: i$ j; j% u1 A9 w8 A8 S
  160. /// Timer callback function.
    $ }( ^" d# S' i5 \3 @, G1 f3 ^
  161. typedef void (*osTimerFunc_t) (void *argument);8 c% P: y* [0 m( {$ w, G) \3 W
  162. ' E7 ?2 R0 H7 z$ O
  163. /// Timer type.7 @4 U0 |, s- V) w6 d; `
  164. typedef enum {
    1 z! |9 c& T# @& Z
  165.   osTimerOnce               = 0,          ///< One-shot timer.
    9 d0 n: m/ e" h! D
  166.   osTimerPeriodic           = 1           ///< Repeating timer.! F' E. B- G/ b- K4 C/ Z" a  `
  167. } osTimerType_t;
    ! r6 @$ r; @# ~2 k

  168. 1 A& ^& w( [3 G8 M$ q
  169. // Timeout value.
    * K& l0 \# r/ H. M3 J! |
  170. #define osWaitForever         0xFFFFFFFFU ///< Wait forever timeout value.
    # u0 M: p4 Q9 o3 C7 j
  171. 1 T% }1 J- T! l3 |' w  L
  172. // Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait).8 x- R$ h' b4 ]  o3 S
  173. #define osFlagsWaitAny        0x00000000U ///< Wait for any flag (default).7 r; F/ J! [: Z6 j# M
  174. #define osFlagsWaitAll        0x00000001U ///< Wait for all flags.
    9 H" f, R9 y. u5 {+ c
  175. #define osFlagsNoClear        0x00000002U ///< Do not clear flags which have been specified to wait for.
    6 H. x0 e1 {- _- F3 i8 y
  176. + z/ ?  H3 y, F5 C
  177. // Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx).
    2 E" y8 ~2 M( |" Z& ^$ l: j
  178. #define osFlagsError          0x80000000U ///< Error indicator.
    5 k0 K8 V0 Y  c: C& j- H# m8 {
  179. #define osFlagsErrorUnknown   0xFFFFFFFFU ///< osError (-1).6 E# R8 X2 z+ y/ Y. l
  180. #define osFlagsErrorTimeout   0xFFFFFFFEU ///< osErrorTimeout (-2).
    * V! `. v% w- l' |5 W8 L
  181. #define osFlagsErrorResource  0xFFFFFFFDU ///< osErrorResource (-3).
    . v$ X& I4 j1 w' S2 V
  182. #define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4).8 c# c3 r) I* }0 G3 L
  183. #define osFlagsErrorISR       0xFFFFFFFAU ///< osErrorISR (-6).
    : \* P4 M  H( R  K& V
  184. & `( q: Y* m9 s0 Z0 a
  185. // Thread attributes (attr_bits in \ref osThreadAttr_t).( `1 ]' ^0 M, p5 w3 n2 I
  186. #define osThreadDetached      0x00000000U ///< Thread created in detached mode (default); e& f! U9 P# b9 [" P6 B$ E6 e
  187. #define osThreadJoinable      0x00000001U ///< Thread created in joinable mode
    0 y3 g' x, n& Z4 x
  188. / b/ @2 E0 l7 J
  189. // Mutex attributes (attr_bits in \ref osMutexAttr_t).
    % e3 D( b9 P9 C; ?+ e- @% x
  190. #define osMutexRecursive      0x00000001U ///< Recursive mutex.
    - J7 i" l- W( Y' S1 ?6 A
  191. #define osMutexPrioInherit    0x00000002U ///< Priority inherit protocol.8 s1 A- |* ]1 q8 f- k
  192. #define osMutexRobust         0x00000008U ///< Robust mutex.
    . _2 N8 \: {: {5 w
  193. 1 Z% j$ U8 F1 `# Q; j2 r
  194. /// Status code values returned by CMSIS-RTOS functions.) ]+ p" G+ i& i; ^$ X. a. V
  195. typedef enum {
    ' B+ F, n. @* ^- d! z) A" e
  196.   osOK                      =  0,         ///< Operation completed successfully.
    8 r; ?7 v6 W) t1 p' O2 X
  197.   osError                   = -1,         ///< Unspecified RTOS error: run-time error but no other error message fits./ |! @9 ?9 m! y2 e- f5 J
  198.   osErrorTimeout            = -2,         ///< Operation not completed within the timeout period.
    $ W+ J5 j) O% {/ [4 P0 [/ T
  199.   osErrorResource           = -3,         ///< Resource not available.& k8 u* Z! f* O/ r
  200.   osErrorParameter          = -4,         ///< Parameter error.
    ' }% F" t) H2 t# e% s
  201.   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
  202.   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 |* {
  203.   osStatusReserved          = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.
    % F* F7 T: S& |( a8 q7 p
  204. } osStatus_t;) R6 }8 U3 P8 ?
  205. * T$ m( i9 r% J1 q2 A
  206. 2 T1 C$ L2 S; j$ b0 W; O/ v
  207. /// \details Thread ID identifies the thread.6 R; H% p/ F1 d
  208. typedef void *osThreadId_t;
      b" D* x4 f. v" ^7 Q/ v

  209. ; O" n0 }- ]* ~, A
  210. /// \details Timer ID identifies the timer.
    + _; {" n; k0 G5 c! ~% h4 a
  211. typedef void *osTimerId_t;
    2 l3 p. _7 X! q, Y  P" h
  212. 9 V* Y$ d/ Y& _; ]' B
  213. /// \details Event Flags ID identifies the event flags.
    ( z, S* {2 L! i3 k, _
  214. typedef void *osEventFlagsId_t;  r! f) ~! b& T: S

  215. + E" R4 {* V$ F0 b. j7 c1 o; F
  216. /// \details Mutex ID identifies the mutex.) B9 o- w- g0 w6 p4 S# C
  217. typedef void *osMutexId_t;" l: [& Y- k3 S/ h- }2 H0 c1 O

  218. ( n" q: N. U$ A' n3 o9 e
  219. /// \details Semaphore ID identifies the semaphore.
    + l0 I( o) F; ^2 q/ w6 P
  220. typedef void *osSemaphoreId_t;- H; n- R# S- F0 x3 d4 q& J

  221. 5 S6 p. |1 x, z) Z
  222. /// \details Memory Pool ID identifies the memory pool.0 O+ [) i' T- O* k& x
  223. typedef void *osMemoryPoolId_t;3 H2 ^) l5 g% W+ W
  224. 5 g- A% b) h1 |9 a1 f# }
  225. /// \details Message Queue ID identifies the message queue.. s2 \% C8 M2 W. M. }1 n
  226. typedef void *osMessageQueueId_t;6 a& C1 U/ O  o. z6 J9 n
  227. , U2 S1 U1 B! B# Z9 o
  228. ! ~9 [4 y+ z; m* Y4 X" q) q3 U
  229. #ifndef TZ_MODULEID_T
    ' [; d/ ]- \# j& f
  230. #define TZ_MODULEID_T' e. m* a" q4 M) ^* ~  r
  231. /// \details Data type that identifies secure software modules called by a process.; F5 j! `% f+ v, K3 g" }# s) t
  232. typedef uint32_t TZ_ModuleId_t;1 ^8 }6 W7 Z! e8 z( I/ o# s! r$ ^
  233. #endif# K& N7 N, p# i' u& ]
  234. 5 E. E) R6 J' t/ h. z! J2 V0 A  R
  235. ) E+ _/ X# L" I1 E+ t' c, t
  236. /// Attributes structure for thread.
    $ L0 J5 j9 g$ C( e% v
  237. typedef struct {; J. P$ L8 s( |
  238.   const char                   *name;   ///< name of the thread) y" ]- k- N/ `0 r
  239.   uint32_t                 attr_bits;   ///< attribute bits
    ( S3 {8 Z( ], D8 h
  240.   void                      *cb_mem;    ///< memory for control block1 q0 h& I) h* m3 ]  p8 J- ]1 q
  241.   uint32_t                   cb_size;   ///< size of provided memory for control block) i( V9 o6 b* w9 V% ]2 ?; [! k
  242.   void                   *stack_mem;    ///< memory for stack6 |$ ?2 R5 l. L
  243.   uint32_t                stack_size;   ///< size of stack" q( S) f. F& V# }  [0 J
  244.   osPriority_t              priority;   ///< initial thread priority (default: osPriorityNormal)9 z% A: }7 n3 V6 O0 s5 v
  245.   TZ_ModuleId_t            tz_module;   ///< TrustZone module identifier
    * ^" G/ [4 u: |
  246.   uint32_t                  reserved;   ///< reserved (must be 0)/ E6 r- L+ o0 \2 c
  247. } osThreadAttr_t;
    ' l2 e2 |$ g; }  l# q

  248. ( n1 ]6 g* B1 z+ I- S- B# \
  249. /// Attributes structure for timer.- u  r) M  U! R. t9 u; ?; M& d
  250. typedef struct {# V* t3 P! X. w4 B4 r
  251.   const char                   *name;   ///< name of the timer" m  h5 N7 {% y
  252.   uint32_t                 attr_bits;   ///< attribute bits
    8 {1 F) \1 `- E' Q2 v
  253.   void                      *cb_mem;    ///< memory for control block: L: w5 Y! f- [# x( m
  254.   uint32_t                   cb_size;   ///< size of provided memory for control block5 M$ Z$ ~7 C) ?2 [$ D# S  t
  255. } osTimerAttr_t;
    - t+ ?% z. o; c4 t1 `

  256. / Q4 K8 M  g6 D
  257. /// Attributes structure for event flags.% [: v( a: B# k8 g! K, q: U
  258. typedef struct {
    6 @0 C! `( E7 t6 {
  259.   const char                   *name;   ///< name of the event flags3 X! M0 h! _5 S% h
  260.   uint32_t                 attr_bits;   ///< attribute bits
    # v- N, N, C. A& u7 {' @
  261.   void                      *cb_mem;    ///< memory for control block, }6 p* R; G: U; V' ?
  262.   uint32_t                   cb_size;   ///< size of provided memory for control block' {; c8 g2 e9 [3 X% c- [$ `8 X
  263. } osEventFlagsAttr_t;$ F+ r6 g3 g8 H2 h' n7 m& k

  264. & c5 o0 H  _" s7 W
  265. /// Attributes structure for mutex.6 B2 e9 a) R+ ?5 a1 C: }
  266. typedef struct {2 W+ Q2 Y9 W* F; N/ ?& d
  267.   const char                   *name;   ///< name of the mutex
    0 P3 V/ M- Z; a! n8 c
  268.   uint32_t                 attr_bits;   ///< attribute bits
    : e+ p$ a& h( f  N. ^& ?
  269.   void                      *cb_mem;    ///< memory for control block0 ]- l0 e$ A3 w0 k3 n- j  k
  270.   uint32_t                   cb_size;   ///< size of provided memory for control block3 U5 P3 j3 g( e5 d4 q! U6 Z  _
  271. } osMutexAttr_t;
    & A2 j) T% K( r9 N6 B

  272. 9 G! s9 l2 m$ E+ @
  273. /// Attributes structure for semaphore.1 o8 Y7 a5 C1 M: H/ U9 l
  274. typedef struct {& X8 n: @, Y* a3 p2 g6 W
  275.   const char                   *name;   ///< name of the semaphore
    4 o# R" C# |: B: P' L; A/ F
  276.   uint32_t                 attr_bits;   ///< attribute bits
    2 F. F# H$ d* m; l" i
  277.   void                      *cb_mem;    ///< memory for control block
    / z6 ~/ C. _' U! X* N
  278.   uint32_t                   cb_size;   ///< size of provided memory for control block, k# x$ D0 |+ U8 G# ?% }1 w. h7 p
  279. } osSemaphoreAttr_t;
    3 \! p/ ^+ ]1 N" H8 Y
  280. " \% {$ ?  }% r5 W" ^, b4 q
  281. /// Attributes structure for memory pool.3 b7 S/ M+ B/ @- H# u1 {; D
  282. typedef struct {7 M1 V: T- M. y  r8 ]
  283.   const char                   *name;   ///< name of the memory pool
    / v: k( X2 C- S& Q  s8 T
  284.   uint32_t                 attr_bits;   ///< attribute bits2 d3 x3 F, b; [4 ^
  285.   void                      *cb_mem;    ///< memory for control block$ T( `- R+ `6 K- _% g4 x' j% R
  286.   uint32_t                   cb_size;   ///< size of provided memory for control block
    $ k, G/ {3 d4 \
  287.   void                      *mp_mem;    ///< memory for data storage
    , n: \3 x' D- b- [+ C
  288.   uint32_t                   mp_size;   ///< size of provided memory for data storage
    " g6 A9 L$ ], ~& ?9 `  I$ Y
  289. } osMemoryPoolAttr_t;
    # c4 p8 _: ^( w' o0 R
  290. 2 m8 a6 o' ?4 J* t. U
  291. /// Attributes structure for message queue.; W3 X# E, P2 a; I" \
  292. typedef struct {
    $ t9 `' ~5 t" I
  293.   const char                   *name;   ///< name of the message queue9 U( s! ~3 Q0 `! F
  294.   uint32_t                 attr_bits;   ///< attribute bits$ y0 X- n4 N5 j' H% q- F
  295.   void                      *cb_mem;    ///< memory for control block
    " C4 d6 q- A9 o, @: q0 j
  296.   uint32_t                   cb_size;   ///< size of provided memory for control block
    . C% h- O% d7 y6 e9 I- p
  297.   void                      *mq_mem;    ///< memory for data storage& F! ]% M4 w  f7 j
  298.   uint32_t                   mq_size;   ///< size of provided memory for data storage & g' O/ e$ j" b, U4 H
  299. } osMessageQueueAttr_t;
    ' j* f! A$ e; Y+ d
  300. * F% d; K  ^4 t9 n6 z% j. r! K
  301. $ w1 O0 \" W, y# w
  302. //  ==== Kernel Management Functions ====% h4 t; j; A' G2 Z. h$ @# x
  303. . M0 J$ T& D/ \1 l, S8 x
  304. /// Initialize the RTOS Kernel.
    5 p) L( Q4 ^$ P. d3 e# o; I
  305. /// \return status code that indicates the execution status of the function.) I- K( o2 R) z
  306. osStatus_t osKernelInitialize (void);3 t2 x, O5 w: @

  307. % R$ @0 }: \2 w6 c' ^4 ~$ t/ e
  308. ///  Get RTOS Kernel Information.1 Z5 x- n9 g, u; r6 j9 D
  309. /// \param[out]    version       pointer to buffer for retrieving version information.
    8 F$ d- {  \4 J/ a. `3 _
  310. /// \param[out]    id_buf        pointer to buffer for retrieving kernel identification string.
      ~7 g( ^! u! `3 o! _% X, M  r
  311. /// \param[in]     id_size       size of buffer for kernel identification string.5 y: u$ x+ N8 `3 d6 E. i
  312. /// \return status code that indicates the execution status of the function.
    ! Q3 b. O" ~1 g3 M7 k
  313. osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size);
    # d8 e* u$ v7 o9 U
  314. . v! w" [$ o7 y! ]/ @
  315. /// Get the current RTOS Kernel state.& A* I+ `) f$ u5 @8 g
  316. /// \return current RTOS Kernel state.' D: {5 k, V2 W+ ?! _( o
  317. osKernelState_t osKernelGetState (void);
    ( r3 [: Z. r+ n, z9 Z6 q6 ?
  318. ; Q' p4 Q8 Z% G0 E! `" ~
  319. /// Start the RTOS Kernel scheduler.% x' F8 l# W0 n; d) P  O/ q4 h
  320. /// \return status code that indicates the execution status of the function.. y1 C' h  Y, @" H+ V- D- v) k
  321. osStatus_t osKernelStart (void);
    - R! I- Y& g3 v; Y: @( p

  322. 1 l* S3 f% N/ w" Q" P3 V* P3 p
  323. /// Lock the RTOS Kernel scheduler.$ }' u, |" B  _. p2 k
  324. /// \return previous lock state (1 - locked, 0 - not locked, error code if negative).7 I9 E' ^! I: W: n, u, Y! x& `
  325. int32_t osKernelLock (void);
    / k$ k8 n0 t' I# B/ h

  326. 3 U  l; U' `$ T/ `- t& }. }+ j( A5 h- g
  327. /// Unlock the RTOS Kernel scheduler.
    : I# a# a7 `3 T' Y
  328. /// \return previous lock state (1 - locked, 0 - not locked, error code if negative).
    ' L- }/ B# |# Q1 j
  329. int32_t osKernelUnlock (void);, N% o) e9 n8 L% y6 r8 C
  330. " @" E* j8 D8 C
  331. /// Restore the RTOS Kernel scheduler lock state.: Y' o! J+ J1 j
  332. /// \param[in]     lock          lock state obtained by \ref osKernelLock or \ref osKernelUnlock.
    . O: }& |+ o, G( p# ]( `. B
  333. /// \return new lock state (1 - locked, 0 - not locked, error code if negative).
    * k5 ~- W! U% ^5 P* j; y* D( ~: U0 {
  334. int32_t osKernelRestoreLock (int32_t lock);
    & ]. |4 \1 ?* K" A

  335. 0 F* E0 u9 a7 S4 Y% s1 I4 S
  336. /// Suspend the RTOS Kernel scheduler.- _' i: z7 j* K- s5 @$ W& ?
  337. /// \return time in ticks, for how long the system can sleep or power-down.# ?) W6 C4 H( N2 e* T) x
  338. uint32_t osKernelSuspend (void);, B) H8 f. P  z* G7 I; e
  339. & W# C" z  Y" K9 O
  340. /// Resume the RTOS Kernel scheduler.
    8 t  N2 h8 v3 q* N
  341. /// \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/ \
  342. void osKernelResume (uint32_t sleep_ticks);
    : @+ b, I. v& N/ y. k/ v  j* k

  343. / u/ K+ P; U5 g
  344. /// Get the RTOS kernel tick count.
    ( O. ?  F0 P4 _5 ^# k
  345. /// \return RTOS kernel current tick count.' p7 @6 Q- C  S0 L
  346. uint32_t osKernelGetTickCount (void);0 [4 B3 ]3 ^( s( W$ F. p

  347. - g8 S8 O9 A, ?& r; u& y$ h% l
  348. /// Get the RTOS kernel tick frequency.
    # M" z# e  Y- x: }, _' [, n3 ^
  349. /// \return frequency of the kernel tick in hertz, i.e. kernel ticks per second.
    + Q7 i- `  |+ P# v, E; U7 c
  350. uint32_t osKernelGetTickFreq (void);0 s9 Y+ I. Q, j4 T. B1 x

  351. 0 c' _( `. w9 ]0 F' s( [- e3 l( b
  352. /// Get the RTOS kernel system timer count.1 d  \) p7 X$ W- g( I* L
  353. /// \return RTOS kernel current system timer count as 32-bit value.% \4 e- H( E8 c$ |$ d
  354. uint32_t osKernelGetSysTimerCount (void);# P# C7 v8 I" `4 a" n! M
  355. ! c- U, s/ d: H6 s3 i
  356. /// Get the RTOS kernel system timer frequency.. j9 |' Q/ C, d# p4 J$ B" S
  357. /// \return frequency of the system timer in hertz, i.e. timer ticks per second.
    5 M3 Y7 n8 M4 S' A, p
  358. uint32_t osKernelGetSysTimerFreq (void);
    # s# v& q) f6 f  `' d$ P

  359. 9 i: P" H0 v3 W: ?4 }

  360. ( @5 Y  Y9 D+ x5 e. J7 z5 v. F
  361. //  ==== Thread Management Functions ====# \! y8 X) N4 B8 a  O. q
  362. ! |: {" }, C- {; b4 E4 G, B; [4 M+ p& x
  363. /// Create a thread and add it to Active Threads.
    " L, x' s1 J! }: |0 A
  364. /// \param[in]     func          thread function.) q' t2 Y1 [, V% P0 i* e
  365. /// \param[in]     argument      pointer that is passed to the thread function as start argument.1 I( R( D# \4 m5 Q* {
  366. /// \param[in]     attr          thread attributes; NULL: default values.
    ) u1 }- N( M* }
  367. /// \return thread ID for reference by other functions or NULL in case of error.  T: Z+ G: Z  F
  368. osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);. R, Y5 x# E5 k- M6 `

  369. , X% t; i& p' j; A; X$ ?/ g& i
  370. /// Get name of a thread.
    " X' y+ \4 Z! O
  371. /// \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
  372. /// \return name as NULL terminated string.
    0 X' K  F: Y2 ^& u, f
  373. const char *osThreadGetName (osThreadId_t thread_id);
    " n. S2 k" O9 v. P

  374. + L# U3 \# s/ ~! X3 H
  375. /// Return the thread ID of the current running thread.
    ) J. ]( ]  z6 g# J  N7 }4 R$ w
  376. /// \return thread ID for reference by other functions or NULL in case of error.
      i9 f5 F5 e4 l4 b
  377. osThreadId_t osThreadGetId (void);& e6 u) ?1 Y: e3 L- N3 z/ A

  378. / |1 i8 v- {' V( w& F9 {
  379. /// Get current thread state of a thread.
    $ Q$ ~8 u/ ~; {4 r) p" i1 w/ a
  380. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId., G7 l3 i2 D3 \9 z/ B
  381. /// \return current thread state of the specified thread.
    ) g  d# M& L; B
  382. osThreadState_t osThreadGetState (osThreadId_t thread_id);
    : s0 P8 k; I. e! H: c5 P3 ]
  383. 5 C- u$ X$ Z! l9 ?( T, x
  384. /// Get stack size of a thread.2 y0 u" d0 g& K! x
  385. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
    , X9 P5 H/ X2 u( d# x
  386. /// \return stack size in bytes.0 d/ g  o" s* K* D: E. b
  387. uint32_t osThreadGetStackSize (osThreadId_t thread_id);
    - l! b# B+ r% l( @
  388. 2 g" a0 ?: C2 K: b( ]
  389. /// Get available stack space of a thread based on stack watermark recording during execution.; B! n' u* n. [
  390. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.: g, T- y- c( v% e
  391. /// \return remaining stack space in bytes.
    ) U" [5 e0 l  q
  392. uint32_t osThreadGetStackSpace (osThreadId_t thread_id);0 {' Y4 c! B. M1 _% Y$ _  ]
  393. $ g' j  S5 }4 ?) w6 P
  394. /// Change priority of a thread." q& i0 b- R! U# @5 d# ^
  395. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.& \( g: K. T" A; b6 f# Y
  396. /// \param[in]     priority      new priority value for the thread function.2 w- a4 _$ f! z; ~  Y
  397. /// \return status code that indicates the execution status of the function.
    ( l0 M4 D* V  U: w
  398. osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority);
    ; k) F& k7 S+ ~; h: C0 z; Z# x2 N

  399. 3 \: k, m( l4 y3 q" {% |+ e" d5 f
  400. /// Get current priority of a thread.
    5 ]9 M- w& y# c% r( n7 O! K
  401. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
    7 Y4 F( Y" Y6 _' Q6 T
  402. /// \return current priority value of the specified thread., y4 T& c5 ?( u
  403. osPriority_t osThreadGetPriority (osThreadId_t thread_id);1 c* C1 r! k! t# l) c0 F
  404. & s  l1 N: |2 C/ A& u3 _& p, @' {
  405. /// Pass control to next thread that is in state \b READY.
    % U- U9 A' I2 k( k0 v( ~
  406. /// \return status code that indicates the execution status of the function.
    4 J# B* }1 m' O1 }! G8 @2 ?3 j
  407. osStatus_t osThreadYield (void);' E" E+ M7 G4 N

  408.   c: }3 f* [  d
  409. /// Suspend execution of a thread.
    8 w- P0 @3 M1 M. \3 C* w* }; ^4 x
  410. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.. P3 n+ B7 @4 R/ B) p
  411. /// \return status code that indicates the execution status of the function.  B0 K/ `4 P7 S. w6 y5 I2 i1 I
  412. osStatus_t osThreadSuspend (osThreadId_t thread_id);
    9 J  P0 n8 ^7 b
  413. 5 P- H) ^- [/ x: m
  414. /// Resume execution of a thread.% ?2 L" r2 _/ @( y/ N" m* i- o
  415. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.: e+ W) H& o# o, ~+ w4 T+ M
  416. /// \return status code that indicates the execution status of the function.( T9 w& Z: O9 w+ J$ g3 C/ W
  417. osStatus_t osThreadResume (osThreadId_t thread_id);
    $ I! m( T( O- X$ q6 [  ^
  418. : \4 d% d9 {# K6 Q$ W) a! u+ p
  419. /// Detach a thread (thread storage can be reclaimed when thread terminates).
    5 _* d, N4 m, x- n4 b# X% M; _1 {
  420. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
    2 L  t, j6 s3 b4 ]) n+ d$ {+ ~
  421. /// \return status code that indicates the execution status of the function." F  p' \% {5 h7 e+ q; ~* O+ G+ |
  422. osStatus_t osThreadDetach (osThreadId_t thread_id);, I# Q8 x3 Q3 ]! t8 P4 F' M. x

  423. " Z4 M$ c! P* W3 F2 g# ~2 t
  424. /// Wait for specified thread to terminate.
    ( w' N, @  Y2 b! a* r+ z+ i5 Z. X
  425. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.* `: c  |. h) }1 ]  x3 I1 g
  426. /// \return status code that indicates the execution status of the function.* E7 j# t+ o! L  {) c
  427. osStatus_t osThreadJoin (osThreadId_t thread_id);
    . T' j1 f; \9 F4 O' G+ ]( x

  428.   ^; H' t! b  D/ n1 N1 _1 |( E: ^
  429. /// Terminate execution of current running thread.
    7 e5 m4 Z7 S" Z
  430. __NO_RETURN void osThreadExit (void);
    . P6 Q3 d  h/ E; E# f* {

  431. ; |- K% x+ N" w1 g, z, U+ k# o( \
  432. /// Terminate execution of a thread.# |! Y- X- Y0 R3 ?; v7 V  {1 N; T3 V
  433. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
    - _- e% p8 c3 I0 P5 F
  434. /// \return status code that indicates the execution status of the function.
    3 X/ B% z0 J9 H4 I! N9 L! \- G
  435. osStatus_t osThreadTerminate (osThreadId_t thread_id);
    * X7 y5 D* Q6 j$ J
  436. 0 P/ o9 t1 j2 R/ q2 r0 c. k+ }, j
  437. /// Get number of active threads.: m5 f) g( m+ P4 y% C# n. ]
  438. /// \return number of active threads.# Z/ j8 P, Q8 n  _
  439. uint32_t osThreadGetCount (void);9 \" l+ Q; A2 }- j6 n( ?
  440.   @, E9 S- V2 V
  441. /// Enumerate active threads.
    : x) i+ y- C2 E: `6 s) Y
  442. /// \param[out]    thread_array  pointer to array for retrieving thread IDs.+ c, [- R  \. @$ o* k$ C
  443. /// \param[in]     array_items   maximum number of items in array for retrieving thread IDs.
    ( [) H) |2 ]9 }; D
  444. /// \return number of enumerated threads.2 D; e/ [" O/ L/ }0 k4 t  F
  445. uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items);. e$ t9 E# _" L, A4 ?9 Q
  446. # p+ Y* m. b0 T+ e

  447. ; @7 |4 w9 c8 D
  448. //  ==== Thread Flags Functions ====  H4 T5 ^2 a  s
  449. 2 f8 I3 W) H: s+ B& q0 a
  450. /// Set the specified Thread Flags of a thread.
    : U' v! v" _/ `5 V% \, Z1 D) R- P
  451. /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.0 `# H& `1 @3 ]2 `- g
  452. /// \param[in]     flags         specifies the flags of the thread that shall be set.$ m( D. h& c4 {. s( g* {$ ]2 K# \
  453. /// \return thread flags after setting or error code if highest bit set.4 u1 [2 {5 b$ \7 X  z9 Y" C
  454. uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags);* \& s9 O# b8 [# n, k2 b

  455. ; H+ o% M/ R. k* C* @  i5 T
  456. /// Clear the specified Thread Flags of current running thread.; N1 b1 {, A6 X! v
  457. /// \param[in]     flags         specifies the flags of the thread that shall be cleared.; }7 k& D- j1 K; w
  458. /// \return thread flags before clearing or error code if highest bit set., g2 ^9 D. m- ~$ A
  459. uint32_t osThreadFlagsClear (uint32_t flags);( g! S7 a& ]9 Y1 P6 {

  460. / R' s. ]5 g# h7 i0 |3 e
  461. /// Get the current Thread Flags of current running thread.4 a+ ?# F- t$ I9 l$ p6 ~
  462. /// \return current thread flags.3 X" n& b, @1 A6 Y
  463. uint32_t osThreadFlagsGet (void);
    . |# T: A1 ^. L6 }: p$ o% }7 Z& g
  464. , m  x* w3 f* S9 C7 Y* \
  465. /// Wait for one or more Thread Flags of the current running thread to become signaled.
    ! s- q& s2 t& I, F
  466. /// \param[in]     flags         specifies the flags to wait for.0 M  p/ l; U% x7 n8 k- d
  467. /// \param[in]     options       specifies flags options (osFlagsXxxx).
    1 G: j, I& T0 n8 A* |  N
  468. /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
    0 t9 @& J% S. R5 e4 a
  469. /// \return thread flags before clearing or error code if highest bit set.
    8 b6 S$ N2 U) [" V
  470. uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout);  D. B8 S6 H! R5 p8 I; B# [

  471. / Q; z% v1 u9 ?! q* J$ W) s6 g

  472. % q! e# G' Z1 u1 C
  473. //  ==== Generic Wait Functions ====8 Q0 X* ~' I9 M2 c. \& _
  474. 5 s5 e) b0 @) R
  475. /// Wait for Timeout (Time Delay).
    7 F$ m4 G% T, T5 i  D! q
  476. /// \param[in]     ticks         \ref CMSIS_RTOS_TimeOutValue "time ticks" value. L5 i. j( y/ F/ V: ?  `+ n5 h6 o
  477. /// \return status code that indicates the execution status of the function.
    / V7 d* I; h# H* o7 i* L* V  N1 W; `
  478. osStatus_t osDelay (uint32_t ticks);  X' i4 o) f" m( w' N
  479. 8 q% U3 Y: f7 s
  480. /// Wait until specified time.
    ; }& s  Y/ O1 o! y
  481. /// \param[in]     ticks         absolute time in ticks8 H0 u- n; K6 I- d6 {
  482. /// \return status code that indicates the execution status of the function.
    4 w+ c$ ~& [: |
  483. osStatus_t osDelayUntil (uint32_t ticks);
    9 j' b/ v& F2 \5 D
  484. 5 H0 H- L" d% n9 n: r. O

  485. " v5 S8 @3 \* j2 F* S/ [
  486. //  ==== Timer Management Functions ====
    * S! p2 U5 |6 T9 ]5 g3 d
  487. ' t& ]" ?: u! V+ t2 U7 U; F' L+ {
  488. /// Create and Initialize a timer.) }& s6 p5 c) B  F/ {7 X! w6 S
  489. /// \param[in]     func          function pointer to callback function.' b, V) s5 w/ S# v2 A3 Y
  490. /// \param[in]     type          \ref osTimerOnce for one-shot or \ref osTimerPeriodic for periodic behavior.0 c8 X; H- Z) L7 b2 H1 Z* W
  491. /// \param[in]     argument      argument to the timer callback function.: G7 |5 G4 q- b$ D: Z! H. K2 _
  492. /// \param[in]     attr          timer attributes; NULL: default values.& p2 r( L4 l& N3 V( ?
  493. /// \return timer ID for reference by other functions or NULL in case of error.
    5 ?# f! O  U7 M/ d- r% L6 {8 D
  494. osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
    , r2 G$ k$ M/ C9 w
  495. ( X. ~) G- D6 }. q  r. M
  496. /// Get name of a timer.0 U) N; Q# D& p6 I! G# y/ R
  497. /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.- @- \4 [$ ~; G* v2 ~2 ~8 P1 q
  498. /// \return name as NULL terminated string.
    6 `7 V! d5 e4 K$ Y/ l% `: b# w
  499. const char *osTimerGetName (osTimerId_t timer_id);4 H9 w; u5 @3 e) h

  500. , B9 Q" k+ J9 b" t( \% `
  501. /// Start or restart a timer.( {: B; ~. _5 d- }; f
  502. /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
    : H" q  w2 x) V3 s* b0 ?8 K: C
  503. /// \param[in]     ticks         \ref CMSIS_RTOS_TimeOutValue "time ticks" value of the timer.
    . e+ f9 Y! v0 f8 i2 p% @; n
  504. /// \return status code that indicates the execution status of the function.
    . C  M$ y% q+ @
  505. osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks);: C: D- p4 S1 M+ C
  506. 5 i  k. N2 Z5 G. k& l- d1 K* p, D
  507. /// Stop a timer.3 W. w% u! Y) O8 L/ S% C  [
  508. /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
    ( f& h" @2 X. ?
  509. /// \return status code that indicates the execution status of the function.
    ' U- [' [; S5 @7 w! }. o+ R4 K
  510. osStatus_t osTimerStop (osTimerId_t timer_id);$ h. E5 g6 }& o1 q. n1 B
  511. ; _! J+ O6 c. J! F+ Q, N3 P
  512. /// Check if a timer is running.+ k& B  {3 ^5 o4 a8 a7 z
  513. /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
    ' i5 P* g4 B9 r8 h; e
  514. /// \return 0 not running, 1 running.
    6 D) p" Y, c- ~, N, T
  515. uint32_t osTimerIsRunning (osTimerId_t timer_id);
    : E4 _( _8 n& R# S6 [$ [

  516. 1 f! N* E) J" \2 q& `
  517. /// Delete a timer.
    1 o4 T/ r5 m% C; E% o6 W; [
  518. /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
    4 e; y3 V6 p* l' J0 q" F
  519. /// \return status code that indicates the execution status of the function.
    # F$ z" r9 d( K
  520. osStatus_t osTimerDelete (osTimerId_t timer_id);
    ! G/ ^" {6 m9 ], F! H

  521. 0 D, S$ P/ Q- b# O( p& \

  522. / P2 O7 D5 m4 F6 S4 s4 J% C  D( F
  523. //  ==== Event Flags Management Functions ====# }: Y! N, m4 U5 _

  524. & O' m) O! w% |& f( d# V' C
  525. /// Create and Initialize an Event Flags object.
    . e+ \% j; w( @/ q% ]
  526. /// \param[in]     attr          event flags attributes; NULL: default values.
    6 B( s6 m+ Y% U) n  r# N
  527. /// \return event flags ID for reference by other functions or NULL in case of error.' j; e# B4 f  B, a& z& m' w4 }
  528. osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr);
    ; Z* {$ q. V& A- E3 s, N3 C1 P: _
  529. # ^8 N8 y/ E8 W% j0 U. j
  530. /// Get name of an Event Flags object.
    , g, v) u: {$ v" x6 V3 g$ M: t
  531. /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.! k( y. d- U3 T
  532. /// \return name as NULL terminated string.
    ; `1 }6 |& Z3 N0 I, M* _" ^' H
  533. const char *osEventFlagsGetName (osEventFlagsId_t ef_id);, P8 |' |; J& n" }. p& `
  534. ) K+ @7 B( v3 u9 H9 o, ~6 {
  535. /// Set the specified Event Flags.- T# `6 @; T& C3 i
  536. /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
    6 d: d! X& u2 k" b5 b5 T6 r
  537. /// \param[in]     flags         specifies the flags that shall be set.& e6 }( k9 E  p  O# C' b+ O9 ?
  538. /// \return event flags after setting or error code if highest bit set.& ~! P# w( H$ p' ?1 }! `9 y
  539. uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags);) F1 f! S( ]# R

  540. 6 Z/ }4 l8 e4 T6 ?0 U9 ?1 J* |4 \
  541. /// Clear the specified Event Flags.& ?' e+ _0 W; X
  542. /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
    5 _) k% g& z" n! n5 t( r$ I
  543. /// \param[in]     flags         specifies the flags that shall be cleared.9 g4 y6 x8 i0 D! e( L2 A' X% n
  544. /// \return event flags before clearing or error code if highest bit set.2 `: P; B. H( O( W# g  e4 k) Y2 ]
  545. uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags);6 j5 }1 b! s. [8 K

  546. ' d( H1 `( t6 P+ p3 Y1 l
  547. /// Get the current Event Flags." T+ u4 Q+ ^1 P! r& u- W
  548. /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
    ! Q* y2 s1 {  K, o0 h: `
  549. /// \return current event flags.. H: s9 H% D; Y+ ~: J# f* {9 `/ q
  550. uint32_t osEventFlagsGet (osEventFlagsId_t ef_id);6 N) h  |9 R2 V/ w6 m3 A/ j

  551. " `7 ]& S& k$ `6 T6 j, Z
  552. /// Wait for one or more Event Flags to become signaled.
    2 Z( b. u$ o4 y1 H1 s2 m
  553. /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
    4 l; K7 ]7 O( }3 N
  554. /// \param[in]     flags         specifies the flags to wait for.- ^7 A1 I) O* ?1 z
  555. /// \param[in]     options       specifies flags options (osFlagsXxxx).# V( w" g, v0 w4 e4 R4 ?3 E1 l" f
  556. /// \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
  557. /// \return event flags before clearing or error code if highest bit set.
    9 ]9 z, d& l3 _8 a' R" H4 F3 n% l
  558. uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);' n& F7 O7 x% }" F( \
  559. ! r8 O5 |& n" A( \
  560. /// Delete an Event Flags object.
    2 L& ~6 E- U' _$ v
  561. /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
      b! t) t7 @" e9 F
  562. /// \return status code that indicates the execution status of the function.
    8 S# R% a, \) r7 s) H5 s$ A! Z
  563. osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id);
    , ]3 _: ~: T$ P1 [# j

  564. , z: N* N; r7 d8 u, p4 E
  565. # H) A  A$ D+ F/ X1 @0 `
  566. //  ==== Mutex Management Functions ====/ `' y9 u9 Q* X/ Q  Y. `

  567. & |& m6 ]2 `, L( U* |
  568. /// Create and Initialize a Mutex object.
    % P3 ~1 ]* c, _$ K
  569. /// \param[in]     attr          mutex attributes; NULL: default values.
    0 X/ R5 o* {+ h" z
  570. /// \return mutex ID for reference by other functions or NULL in case of error.
    0 L7 ?3 P" ^  F; _) N" {+ D
  571. osMutexId_t osMutexNew (const osMutexAttr_t *attr);
    3 k0 C' m8 s3 x* C, K' p

  572. : v8 I2 a$ l1 P& z! I+ X7 `
  573. /// Get name of a Mutex object.
    0 \: F# Z  L4 A0 h7 ~3 m6 H
  574. /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
    7 X  u( f  b; {  W9 X) G+ x/ d
  575. /// \return name as NULL terminated string.
    , h, z8 L0 w4 a, B
  576. const char *osMutexGetName (osMutexId_t mutex_id);; p$ P  Z9 P) S2 o( Y

  577. ! M2 Z2 {, n4 J) z1 q
  578. /// Acquire a Mutex or timeout if it is locked.
    - s: C7 n: ]. [5 K  Q' a- z3 N' V
  579. /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
    " C- J' X; n! i( s" x# S$ M6 n
  580. /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out." z3 y$ N7 Y; a1 L
  581. /// \return status code that indicates the execution status of the function.
    ; ?# {# p" O8 e! {5 K
  582. osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout);
    ; f% v, n0 U8 U8 z9 G' @

  583. 9 r+ K4 g  z; k6 Y7 G, n
  584. /// Release a Mutex that was acquired by \ref osMutexAcquire.
    # E) i1 }9 l& S  x
  585. /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
    ' C8 U, L4 O* ]% b  z( |" O
  586. /// \return status code that indicates the execution status of the function.
    ' J8 w' @$ Z9 ^5 c: n. S
  587. osStatus_t osMutexRelease (osMutexId_t mutex_id);
    - v( R2 ^8 M9 l7 E) p6 m

  588. : P9 N8 m/ w8 a) c1 F& G, C, Q
  589. /// Get Thread which owns a Mutex object., c7 @; r" Z' U7 {3 _* W
  590. /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.) a* \" E/ a8 ]( b! g5 ^; V
  591. /// \return thread ID of owner thread or NULL when mutex was not acquired.* j  H" k% }$ Y, l( ?' W1 z
  592. osThreadId_t osMutexGetOwner (osMutexId_t mutex_id);# w# O  r# r1 p) K' Q

  593. ; \0 L' M  @' i5 d8 L" V. }
  594. /// Delete a Mutex object.: r8 E- P  C4 d
  595. /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.& O6 T' v& {7 `% R" X) Y
  596. /// \return status code that indicates the execution status of the function.2 K  c  L( n; x5 a6 K7 @& x( T
  597. osStatus_t osMutexDelete (osMutexId_t mutex_id);
    . l" S( ^( p% G

  598. ( [- _) y# n! {& u
  599. + @- J& i8 P% j! J
  600. //  ==== Semaphore Management Functions ====6 A/ W" R: i. I$ j4 h3 q
  601. ! N. a4 ]" q( t+ _
  602. /// Create and Initialize a Semaphore object.2 ?- h5 S+ g' e. A. b4 v  K$ T! w* X
  603. /// \param[in]     max_count     maximum number of available tokens.
    , }: b1 m( R9 T* x8 p" g/ W! }. x1 \
  604. /// \param[in]     initial_count initial number of available tokens.
    , {2 G3 X  t+ B
  605. /// \param[in]     attr          semaphore attributes; NULL: default values.
    * m- W" `* ]7 _! `" _5 v' _
  606. /// \return semaphore ID for reference by other functions or NULL in case of error.
    5 z5 u9 f- I$ l( u( Y9 ~% ~/ l
  607. osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr);* j' v- U1 `4 _0 W: @3 \) ]7 z
  608. & s) U) F. ~: h8 W
  609. /// Get name of a Semaphore object." h' L8 i$ |5 I7 x4 y6 X
  610. /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.6 a& C  i1 A3 P/ [# G
  611. /// \return name as NULL terminated string.9 p% C8 }) Z6 ]3 M5 P
  612. const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id);& b0 l* i8 Z; p, |
  613. ' j/ B" b+ Z& u' ^
  614. /// Acquire a Semaphore token or timeout if no tokens are available.* T0 |: d$ }0 c* I7 h* `5 b3 f6 ]
  615. /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.8 V- V! V% X7 Z
  616. /// \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
  617. /// \return status code that indicates the execution status of the function.
    2 }# q3 J1 z% Z2 h9 z9 V
  618. osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout);
    $ z7 D- }! u+ ]$ {2 b: r

  619. 7 g: S4 ^7 j9 ^* L
  620. /// Release a Semaphore token up to the initial maximum count.1 n$ s( X$ y; x. Q
  621. /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.0 }# _3 W" d9 Q
  622. /// \return status code that indicates the execution status of the function.
    7 w# ?8 M/ ?% S* e3 R
  623. osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id);
    4 f: ?( t; O" }* p

  624. % ?6 H& `8 E% w$ U- a
  625. /// Get current Semaphore token count.3 L/ X4 b) j% i( X5 y$ I. P
  626. /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
      k" e7 a0 e, g9 g' w, M
  627. /// \return number of tokens available.
    ! ~2 o  O" w! k# y
  628. uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id);
    7 d: U) \' q9 a; G# L8 V( F

  629. 3 T, L# K+ ]# d2 R8 m  d
  630. /// Delete a Semaphore object.
    4 i8 g& E# ~& H" t
  631. /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.  e' c. d2 M' u  q( t' `
  632. /// \return status code that indicates the execution status of the function.4 {: _- P7 T; H$ P2 r
  633. osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id);
    " {$ ^2 ~: }: K8 z  y
  634. $ D' a* E- B4 |9 h2 q8 t
  635. : o" t1 _4 p$ E7 o5 }
  636. //  ==== Memory Pool Management Functions ====- C  H9 B- s  |7 H
  637. ! r) |+ M+ @. J; X, O; g  ~$ A2 }
  638. /// Create and Initialize a Memory Pool object.
    1 O( [% h, f5 Q
  639. /// \param[in]     block_count   maximum number of memory blocks in memory pool.# J, [7 \* O& d6 N  p5 _
  640. /// \param[in]     block_size    memory block size in bytes.
      d# m4 e. Z3 h
  641. /// \param[in]     attr          memory pool attributes; NULL: default values.
    8 }1 f0 `2 k1 \8 M! C
  642. /// \return memory pool ID for reference by other functions or NULL in case of error.0 p2 L/ l- |+ ?9 j: l
  643. 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

  644. * @' v8 R" S7 t7 ]# S9 I- L
  645. /// Get name of a Memory Pool object.
    ' r, }9 U8 F* l5 k& a
  646. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
    ) y# _; s+ ^1 P9 G: G5 r
  647. /// \return name as NULL terminated string.' N- Q1 L, r, T9 O+ V
  648. const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id);
    ) w1 j5 U- Z- V9 q6 |
  649. ( P- N) x9 Z! @
  650. /// Allocate a memory block from a Memory Pool.0 V" P# F  W7 ^+ c
  651. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
    1 H. q) H6 K  u  a! q- j  W! k- }6 |$ V
  652. /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.! l( {& a$ v: z2 d. o
  653. /// \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
  654. void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout);7 o& O0 A+ _5 ]. O3 g; i

  655. , q$ ]1 ~* J+ S* d
  656. /// Return an allocated memory block back to a Memory Pool.: L; k, z* L8 H+ I" \1 _
  657. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.5 N  y" P$ a% _6 A
  658. /// \param[in]     block         address of the allocated memory block to be returned to the memory pool.8 {0 A- P: R3 q; X
  659. /// \return status code that indicates the execution status of the function.6 B  a' A! M  o3 S6 A. j
  660. osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block);
    5 o5 E# |9 `- t) ?. f" }2 B3 c5 T

  661. 0 a4 r$ p$ J+ l/ }
  662. /// Get maximum number of memory blocks in a Memory Pool.
    7 o4 H! N( j9 |, ]3 |: q
  663. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
    . ]+ @' G' X) D1 r. e/ x- T0 d
  664. /// \return maximum number of memory blocks.
    . Q& x' i; ~' e, ^2 ^# E2 y
  665. uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id);
    9 v; v6 U1 d3 k/ a+ Z  r
  666. 0 x' x) Y8 c& D8 }
  667. /// Get memory block size in a Memory Pool.
    $ v8 v% }0 M6 h0 ]
  668. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.' z7 W2 z. {1 i6 |- q% v* D
  669. /// \return memory block size in bytes.( j4 D# q  k8 @. i% E& V, \$ W3 H
  670. uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id);
    " }! Y: x* `( O
  671. 2 ?* B: F1 Z% J7 q
  672. /// Get number of memory blocks used in a Memory Pool.0 ]6 G- w: w8 f- s  c" q; k
  673. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
    % W, Y; O% T$ _$ E2 N, s
  674. /// \return number of memory blocks used.3 H* d* H, o& P* l# C( G* x" a; b
  675. uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id);
    3 T. i& z, H7 [2 H% f
  676. ! k& ^% |) ^& W8 B
  677. /// Get number of memory blocks available in a Memory Pool.
    1 i* A; S2 s0 ~8 h5 V- p4 z
  678. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.( q! Z: r3 S9 ]& c1 O: G
  679. /// \return number of memory blocks available.+ P$ j0 q7 w9 o$ ]
  680. uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id);
      D4 a* x- f( v; e2 v

  681. $ H& k) z* L6 p  p- \8 e! g- j  u# l- V
  682. /// Delete a Memory Pool object.: B- y% _; [# U' M
  683. /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.! K$ C: k+ }6 Z  W( F5 u& i
  684. /// \return status code that indicates the execution status of the function.
    " Z; H& Y6 K1 e1 H
  685. osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id);- Q- a4 s7 j6 @: }
  686. : _/ `) Q" T( v6 V7 D  T3 h6 A+ B

  687. 7 d! u6 W7 K# \  U
  688. //  ==== Message Queue Management Functions ====$ F  ]; V" c- o5 l8 J, A$ E

  689. : S& P0 l" I4 `' Z" m. ^$ R; ^% B7 L
  690. /// Create and Initialize a Message Queue object.5 w9 T# _5 Q# X# k* u) I* {
  691. /// \param[in]     msg_count     maximum number of messages in queue.0 p: H/ m" R! ~
  692. /// \param[in]     msg_size      maximum message size in bytes.
    & R8 p5 W2 d" q; G6 c" m
  693. /// \param[in]     attr          message queue attributes; NULL: default values.- k9 j+ Y5 J* R  d- y, F
  694. /// \return message queue ID for reference by other functions or NULL in case of error.& Q( W: n' D( q% A
  695. osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr);3 U; Y" X+ u4 ^4 j- _3 e

  696. # C9 ^' j; Q! d. M! P" a% U- s
  697. /// Get name of a Message Queue object.
    6 V/ r; {1 r/ d
  698. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
    * |$ |' d5 J$ J7 p( ?: \/ P
  699. /// \return name as NULL terminated string.! U9 e! G9 U2 ]% q* X. O# _( s' A
  700. const char *osMessageQueueGetName (osMessageQueueId_t mq_id);
    % Y! V& R+ X4 E1 [

  701. 9 X8 _& _% n0 x7 i0 @2 I( f  u* [
  702. /// Put a Message into a Queue or timeout if Queue is full.
    ; i: _: [# Z2 ^9 B( s
  703. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.& l! p& R2 j6 G6 ^
  704. /// \param[in]     msg_ptr       pointer to buffer with message to put into a queue.% i' p: }4 Y. V6 f9 b) X+ i1 N
  705. /// \param[in]     msg_prio      message priority.
      e% K" S' r( C1 m1 f' ]2 e# }
  706. /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.; J7 H' e9 M) ]4 }  {8 S; y' ^, j
  707. /// \return status code that indicates the execution status of the function.+ B. r$ c  r( ~2 x
  708. 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
  709. 4 u% f1 V9 x. K( [; @2 F7 P
  710. /// Get a Message from a Queue or timeout if Queue is empty.
    ! |4 Q8 x" s. \. j9 G5 r+ O& _/ l
  711. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
    , K; k1 T8 I1 ?; i8 a  E) h+ ?
  712. /// \param[out]    msg_ptr       pointer to buffer for message to get from a queue.
    7 L5 \" e$ m1 t% U4 @1 P, l
  713. /// \param[out]    msg_prio      pointer to buffer for message priority or NULL.' E0 `- F- h( G5 n' u" D
  714. /// \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
  715. /// \return status code that indicates the execution status of the function.  I/ ~1 _2 z% M
  716. 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
  717. % V  ?: {5 i- Z
  718. /// Get maximum number of messages in a Message Queue.9 |  s* i( B/ Y0 z1 r
  719. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.# O' g, {2 e9 o# i8 c  x4 N7 Y1 I
  720. /// \return maximum number of messages.
    # {. F' P# I7 b
  721. uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id);, n9 D2 R* K/ f# p+ U

  722. 4 Q! ]6 ^: b: |, Q. E3 O! G: k, Z
  723. /// Get maximum message size in a Memory Pool.  o. y# P( {0 R) h5 N8 Q
  724. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.+ Q/ a1 ?' p1 b7 P2 l
  725. /// \return maximum message size in bytes.
    - b' D2 P- x- |" C
  726. uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id);4 E+ H  [; z$ |. k3 G) G6 b* K& z
  727. 8 }3 A; M# j8 k$ C% j) V
  728. /// Get number of queued messages in a Message Queue.; E/ G1 v4 ~1 p3 T6 C. l
  729. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
    : d6 X9 v# t1 e
  730. /// \return number of queued messages.- Q5 F. c* e) V" W+ M1 D
  731. uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id);3 p* E8 H1 f4 @& y& Y  `/ V  u0 s5 f
  732. & K7 S) q* ^' {
  733. /// Get number of available slots for messages in a Message Queue.$ A+ l5 F, X, T+ T
  734. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.% l- d. Q, C  k" E, M9 o% w/ r5 T$ @
  735. /// \return number of available slots for messages.
    6 \/ W6 E$ _4 q6 p
  736. uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id);
    ( G+ p  C3 b; f* z. ^
  737. ' R/ R  a4 |; i& c1 t3 B# b
  738. /// Reset a Message Queue to initial empty state.
    * t" V4 C+ J* f9 l4 R7 d! \" L
  739. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
      F8 d: e* G" [. r$ |
  740. /// \return status code that indicates the execution status of the function.2 r& Q+ {/ Q* t6 @* X
  741. osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id);
    % R; x9 u  M* ~. i& f$ T8 `5 E
  742.   ?3 h* o* `8 I7 [% ~8 t8 s9 G
  743. /// Delete a Message Queue object.) z  E8 D& d2 n+ m& m: _9 R
  744. /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.! D' t) R" g* g
  745. /// \return status code that indicates the execution status of the function.( a( R2 J. R' G
  746. osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id);6 E5 \' W; Y& ?6 z: t# r, u- W' X

  747. / T- C. p" `* ~: T- }( u, Q

  748. 1 D$ S, M1 I) Z, x  h
  749. #ifdef  __cplusplus
    ) C' n4 \& ]8 v- Z  b: [
  750. }
    . K5 o) I/ R: N! S3 B/ }
  751. #endif1 G: V. s) N6 c. r  R

  752. $ r7 W, k- ?' H! }6 w0 d/ u: I/ u* d
  753. #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 验证
赞 收藏 评论4 发布时间:2018-4-21 15:48

举报

4个回答
黑皮男 回答时间:2018-4-21 16:36:17
支持,我现在用的是cmsis_os接口
XinLiYF 回答时间:2018-4-22 09:14:50
黑皮男 发表于 2018-4-21 16:36
3 K- d1 d( x9 g6 F( R支持,我现在用的是cmsis_os接口
3 Q, w( @$ i3 s' P
就是相关的教程和文档比较少,用的人比较少,你很有前瞻性啊。
黑皮男 回答时间:2018-4-22 09:42:30
XinLiYF 发表于 2018-4-22 09:14  Z" `( [/ W+ l# o! G9 W* J( f
就是相关的教程和文档比较少,用的人比较少,你很有前瞻性啊。
8 R* ~7 Z9 r& e2 L4 K& Z
之前都是自己封装RTOS的接口,发现cmsis_os后,既然都有统一的接口,干脆就拿来用了,比自己封装的要好很多
XinLiYF 回答时间:2018-4-22 10:26:00
黑皮男 发表于 2018-4-22 09:42
/ e- L, [4 }6 B之前都是自己封装RTOS的接口,发现cmsis_os后,既然都有统一的接口,干脆就拿来用了,比自己封装的要好很 ...

3 a/ n/ |7 [- L3 R9 U" x8 p刚去你 GitHub 逛啦一圈 ,你肯定是一个外表粗犷内心细腻的人 ,GitHub 上关注你了
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版