11bd4fe43Sopenharmony_ci/*
21bd4fe43Sopenharmony_ci * Copyright (c) 2013-2018 Arm Limited. All rights reserved.
31bd4fe43Sopenharmony_ci *
41bd4fe43Sopenharmony_ci * SPDX-License-Identifier: Apache-2.0
51bd4fe43Sopenharmony_ci *
61bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the License); you may
71bd4fe43Sopenharmony_ci * not use this file except in compliance with the License.
81bd4fe43Sopenharmony_ci * You may obtain a copy of the License at
91bd4fe43Sopenharmony_ci *
101bd4fe43Sopenharmony_ci * www.apache.org/licenses/LICENSE-2.0
111bd4fe43Sopenharmony_ci *
121bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
131bd4fe43Sopenharmony_ci * distributed under the License is distributed on an AS IS BASIS, WITHOUT
141bd4fe43Sopenharmony_ci * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
151bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and
161bd4fe43Sopenharmony_ci * limitations under the License.
171bd4fe43Sopenharmony_ci *
181bd4fe43Sopenharmony_ci * ----------------------------------------------------------------------
191bd4fe43Sopenharmony_ci *
201bd4fe43Sopenharmony_ci * $Date:        18. June 2018
211bd4fe43Sopenharmony_ci * $Revision:    V2.1.3
221bd4fe43Sopenharmony_ci *
231bd4fe43Sopenharmony_ci * Project:      CMSIS-RTOS2 API
241bd4fe43Sopenharmony_ci * Title:        cmsis_os2.h header file
251bd4fe43Sopenharmony_ci *
261bd4fe43Sopenharmony_ci * Version 2.1.3
271bd4fe43Sopenharmony_ci *    Additional functions allowed to be called from Interrupt Service Routines:
281bd4fe43Sopenharmony_ci *    - osThreadGetId
291bd4fe43Sopenharmony_ci * Version 2.1.2
301bd4fe43Sopenharmony_ci *    Additional functions allowed to be called from Interrupt Service Routines:
311bd4fe43Sopenharmony_ci *    - osKernelGetInfo, osKernelGetState
321bd4fe43Sopenharmony_ci * Version 2.1.1
331bd4fe43Sopenharmony_ci *    Additional functions allowed to be called from Interrupt Service Routines:
341bd4fe43Sopenharmony_ci *    - osKernelGetTickCount, osKernelGetTickFreq
351bd4fe43Sopenharmony_ci *    Changed Kernel Tick type to uint32_t:
361bd4fe43Sopenharmony_ci *    - updated: osKernelGetTickCount, osDelayUntil
371bd4fe43Sopenharmony_ci * Version 2.1.0
381bd4fe43Sopenharmony_ci *    Support for critical and uncritical sections (nesting safe):
391bd4fe43Sopenharmony_ci *    - updated: osKernelLock, osKernelUnlock
401bd4fe43Sopenharmony_ci *    - added: osKernelRestoreLock
411bd4fe43Sopenharmony_ci *    Updated Thread and Event Flags:
421bd4fe43Sopenharmony_ci *    - changed flags parameter and return type from int32_t to uint32_t
431bd4fe43Sopenharmony_ci * Version 2.0.0
441bd4fe43Sopenharmony_ci *    Initial Release
451bd4fe43Sopenharmony_ci *---------------------------------------------------------------------------*/
461bd4fe43Sopenharmony_ci
471bd4fe43Sopenharmony_ci/**
481bd4fe43Sopenharmony_ci * @addtogroup CMSIS
491bd4fe43Sopenharmony_ci * @{
501bd4fe43Sopenharmony_ci *
511bd4fe43Sopenharmony_ci * @brief Provides standard, universal real-time operating system (RTOS) APIs.
521bd4fe43Sopenharmony_ci *
531bd4fe43Sopenharmony_ci * CMSIS Module may contain portions from ARM Cortex Microcontroller Software Interface Standard (CMSIS) licensed under Apache License v2.0.
541bd4fe43Sopenharmony_ci *
551bd4fe43Sopenharmony_ci * @since 1.0
561bd4fe43Sopenharmony_ci * @version 1.0
571bd4fe43Sopenharmony_ci */
581bd4fe43Sopenharmony_ci
591bd4fe43Sopenharmony_ci#ifndef CMSIS_OS2_H_
601bd4fe43Sopenharmony_ci#define CMSIS_OS2_H_
611bd4fe43Sopenharmony_ci
621bd4fe43Sopenharmony_ci#ifndef __NO_RETURN
631bd4fe43Sopenharmony_ci#if   defined(__CC_ARM)
641bd4fe43Sopenharmony_ci#define __NO_RETURN __declspec(noreturn)
651bd4fe43Sopenharmony_ci#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
661bd4fe43Sopenharmony_ci#define __NO_RETURN __attribute__((__noreturn__))
671bd4fe43Sopenharmony_ci#elif defined(__GNUC__)
681bd4fe43Sopenharmony_ci#define __NO_RETURN __attribute__((__noreturn__))
691bd4fe43Sopenharmony_ci#elif defined(__ICCARM__)
701bd4fe43Sopenharmony_ci#define __NO_RETURN __noreturn
711bd4fe43Sopenharmony_ci#else
721bd4fe43Sopenharmony_ci#define __NO_RETURN
731bd4fe43Sopenharmony_ci#endif
741bd4fe43Sopenharmony_ci#endif
751bd4fe43Sopenharmony_ci
761bd4fe43Sopenharmony_ci#include <stdint.h>
771bd4fe43Sopenharmony_ci#include <stddef.h>
781bd4fe43Sopenharmony_ci
791bd4fe43Sopenharmony_ci#ifdef __cplusplus
801bd4fe43Sopenharmony_ciextern "C" {
811bd4fe43Sopenharmony_ci#endif
821bd4fe43Sopenharmony_ci
831bd4fe43Sopenharmony_ci
841bd4fe43Sopenharmony_ci//  ==== Enumerations, structures, defines ====
851bd4fe43Sopenharmony_ci
861bd4fe43Sopenharmony_ci/**
871bd4fe43Sopenharmony_ci* @brief Describes the system version.
881bd4fe43Sopenharmony_ci*
891bd4fe43Sopenharmony_ci* @since 1.0
901bd4fe43Sopenharmony_ci* @version 1.0
911bd4fe43Sopenharmony_ci*/
921bd4fe43Sopenharmony_citypedef struct {
931bd4fe43Sopenharmony_ci  /** API version */
941bd4fe43Sopenharmony_ci  uint32_t                       api;
951bd4fe43Sopenharmony_ci  /** Kernel version */
961bd4fe43Sopenharmony_ci  uint32_t                    kernel;
971bd4fe43Sopenharmony_ci} osVersion_t;
981bd4fe43Sopenharmony_ci
991bd4fe43Sopenharmony_ci/**
1001bd4fe43Sopenharmony_ci* @brief Enumerates kernel states.
1011bd4fe43Sopenharmony_ci*
1021bd4fe43Sopenharmony_ci*/
1031bd4fe43Sopenharmony_citypedef enum {
1041bd4fe43Sopenharmony_ci  /** The kernel is inactive. */
1051bd4fe43Sopenharmony_ci  osKernelInactive        =  0,
1061bd4fe43Sopenharmony_ci  /** The kernel is ready. */
1071bd4fe43Sopenharmony_ci  osKernelReady           =  1,
1081bd4fe43Sopenharmony_ci  /** The kernel is running. */
1091bd4fe43Sopenharmony_ci  osKernelRunning         =  2,
1101bd4fe43Sopenharmony_ci  /** The kernel is locked. */
1111bd4fe43Sopenharmony_ci  osKernelLocked          =  3,
1121bd4fe43Sopenharmony_ci  /** The kernel is suspended. */
1131bd4fe43Sopenharmony_ci  osKernelSuspended       =  4,
1141bd4fe43Sopenharmony_ci  /** The kernel is abnormal. */
1151bd4fe43Sopenharmony_ci  osKernelError           = -1,
1161bd4fe43Sopenharmony_ci  /** Reserved */
1171bd4fe43Sopenharmony_ci  osKernelReserved        = 0x7FFFFFFFU
1181bd4fe43Sopenharmony_ci} osKernelState_t;
1191bd4fe43Sopenharmony_ci
1201bd4fe43Sopenharmony_ci/**
1211bd4fe43Sopenharmony_ci* @brief Enumerates thread states.
1221bd4fe43Sopenharmony_ci*
1231bd4fe43Sopenharmony_ci*/
1241bd4fe43Sopenharmony_citypedef enum {
1251bd4fe43Sopenharmony_ci  /** The thread is inactive. */
1261bd4fe43Sopenharmony_ci  osThreadInactive        =  0,
1271bd4fe43Sopenharmony_ci  /** The thread is ready. */
1281bd4fe43Sopenharmony_ci  osThreadReady           =  1,
1291bd4fe43Sopenharmony_ci  /** The thread is running. */
1301bd4fe43Sopenharmony_ci  osThreadRunning         =  2,
1311bd4fe43Sopenharmony_ci  /** The thread is blocked. */
1321bd4fe43Sopenharmony_ci  osThreadBlocked         =  3,
1331bd4fe43Sopenharmony_ci  /** The thread is terminated. */
1341bd4fe43Sopenharmony_ci  osThreadTerminated      =  4,
1351bd4fe43Sopenharmony_ci  /** The thread is abnormal. */
1361bd4fe43Sopenharmony_ci  osThreadError           = -1,
1371bd4fe43Sopenharmony_ci  /** Reserved */
1381bd4fe43Sopenharmony_ci  osThreadReserved        = 0x7FFFFFFF
1391bd4fe43Sopenharmony_ci} osThreadState_t;
1401bd4fe43Sopenharmony_ci
1411bd4fe43Sopenharmony_ci/**
1421bd4fe43Sopenharmony_ci* @brief Enumerates thread priorities.
1431bd4fe43Sopenharmony_ci*
1441bd4fe43Sopenharmony_ci*/
1451bd4fe43Sopenharmony_citypedef enum {
1461bd4fe43Sopenharmony_ci  /** Undefined */
1471bd4fe43Sopenharmony_ci  osPriorityNone          =  0,
1481bd4fe43Sopenharmony_ci  /** Reserved for idle threads */
1491bd4fe43Sopenharmony_ci  osPriorityIdle          =  1,
1501bd4fe43Sopenharmony_ci  /** Low (unsupported) */
1511bd4fe43Sopenharmony_ci  osPriorityLow           =  8,
1521bd4fe43Sopenharmony_ci  /** Low + 1 */
1531bd4fe43Sopenharmony_ci  osPriorityLow1          =  8+1,
1541bd4fe43Sopenharmony_ci  /** Low + 2 */
1551bd4fe43Sopenharmony_ci  osPriorityLow2          =  8+2,
1561bd4fe43Sopenharmony_ci  /** Low + 3 */
1571bd4fe43Sopenharmony_ci  osPriorityLow3          =  8+3,
1581bd4fe43Sopenharmony_ci  /** Low + 4 */
1591bd4fe43Sopenharmony_ci  osPriorityLow4          =  8+4,
1601bd4fe43Sopenharmony_ci  /** Low + 5 */
1611bd4fe43Sopenharmony_ci  osPriorityLow5          =  8+5,
1621bd4fe43Sopenharmony_ci  /** Low + 6 */
1631bd4fe43Sopenharmony_ci  osPriorityLow6          =  8+6,
1641bd4fe43Sopenharmony_ci  /** Low + 7 */
1651bd4fe43Sopenharmony_ci  osPriorityLow7          =  8+7,
1661bd4fe43Sopenharmony_ci  /** Below normal */
1671bd4fe43Sopenharmony_ci  osPriorityBelowNormal   = 16,
1681bd4fe43Sopenharmony_ci  /** Below normal + 1 */
1691bd4fe43Sopenharmony_ci  osPriorityBelowNormal1  = 16+1,
1701bd4fe43Sopenharmony_ci  /** Below normal + 2 */
1711bd4fe43Sopenharmony_ci  osPriorityBelowNormal2  = 16+2,
1721bd4fe43Sopenharmony_ci  /** Below normal + 3 */
1731bd4fe43Sopenharmony_ci  osPriorityBelowNormal3  = 16+3,
1741bd4fe43Sopenharmony_ci  /** Below normal + 4 */
1751bd4fe43Sopenharmony_ci  osPriorityBelowNormal4  = 16+4,
1761bd4fe43Sopenharmony_ci  /** Below normal + 5 */
1771bd4fe43Sopenharmony_ci  osPriorityBelowNormal5  = 16+5,
1781bd4fe43Sopenharmony_ci  /** Below normal + 6 */
1791bd4fe43Sopenharmony_ci  osPriorityBelowNormal6  = 16+6,
1801bd4fe43Sopenharmony_ci  /** Below normal + 7 */
1811bd4fe43Sopenharmony_ci  osPriorityBelowNormal7  = 16+7,
1821bd4fe43Sopenharmony_ci  /** Normal */
1831bd4fe43Sopenharmony_ci  osPriorityNormal        = 24,
1841bd4fe43Sopenharmony_ci  /** Normal + 1 */
1851bd4fe43Sopenharmony_ci  osPriorityNormal1       = 24+1,
1861bd4fe43Sopenharmony_ci  /** Normal + 2 */
1871bd4fe43Sopenharmony_ci  osPriorityNormal2       = 24+2,
1881bd4fe43Sopenharmony_ci  /** Normal + 3 */
1891bd4fe43Sopenharmony_ci  osPriorityNormal3       = 24+3,
1901bd4fe43Sopenharmony_ci  /** Normal + 4 */
1911bd4fe43Sopenharmony_ci  osPriorityNormal4       = 24+4,
1921bd4fe43Sopenharmony_ci  /** Normal + 5 */
1931bd4fe43Sopenharmony_ci  osPriorityNormal5       = 24+5,
1941bd4fe43Sopenharmony_ci  /** Normal + 6 */
1951bd4fe43Sopenharmony_ci  osPriorityNormal6       = 24+6,
1961bd4fe43Sopenharmony_ci  /** Normal + 7 */
1971bd4fe43Sopenharmony_ci  osPriorityNormal7       = 24+7,
1981bd4fe43Sopenharmony_ci  /** Above normal */
1991bd4fe43Sopenharmony_ci  osPriorityAboveNormal   = 32,
2001bd4fe43Sopenharmony_ci  /** Above normal + 1 */
2011bd4fe43Sopenharmony_ci  osPriorityAboveNormal1  = 32+1,
2021bd4fe43Sopenharmony_ci  /** Above normal + 2 */
2031bd4fe43Sopenharmony_ci  osPriorityAboveNormal2  = 32+2,
2041bd4fe43Sopenharmony_ci  /** Above normal + 3 */
2051bd4fe43Sopenharmony_ci  osPriorityAboveNormal3  = 32+3,
2061bd4fe43Sopenharmony_ci  /** Above normal + 4 */
2071bd4fe43Sopenharmony_ci  osPriorityAboveNormal4  = 32+4,
2081bd4fe43Sopenharmony_ci  /** Above normal + 5 */
2091bd4fe43Sopenharmony_ci  osPriorityAboveNormal5  = 32+5,
2101bd4fe43Sopenharmony_ci  /** Above normal + 6 */
2111bd4fe43Sopenharmony_ci  osPriorityAboveNormal6  = 32+6,
2121bd4fe43Sopenharmony_ci  /** Above normal + 7 (unsupported) */
2131bd4fe43Sopenharmony_ci  osPriorityAboveNormal7  = 32+7,
2141bd4fe43Sopenharmony_ci  /** High (unsupported) */
2151bd4fe43Sopenharmony_ci  osPriorityHigh          = 40,
2161bd4fe43Sopenharmony_ci  /** High + 1 (unsupported) */
2171bd4fe43Sopenharmony_ci  osPriorityHigh1         = 40+1,
2181bd4fe43Sopenharmony_ci  /** High + 2 (unsupported)  */
2191bd4fe43Sopenharmony_ci  osPriorityHigh2         = 40+2,
2201bd4fe43Sopenharmony_ci  /** High + 3 (unsupported)  */
2211bd4fe43Sopenharmony_ci  osPriorityHigh3         = 40+3,
2221bd4fe43Sopenharmony_ci  /** High + 4 (unsupported)  */
2231bd4fe43Sopenharmony_ci  osPriorityHigh4         = 40+4,
2241bd4fe43Sopenharmony_ci  /** High + 5 (unsupported)  */
2251bd4fe43Sopenharmony_ci  osPriorityHigh5         = 40+5,
2261bd4fe43Sopenharmony_ci  /** High + 6 (unsupported)  */
2271bd4fe43Sopenharmony_ci  osPriorityHigh6         = 40+6,
2281bd4fe43Sopenharmony_ci  /** High + 7 (unsupported)  */
2291bd4fe43Sopenharmony_ci  osPriorityHigh7         = 40+7,
2301bd4fe43Sopenharmony_ci  /** Real-time (unsupported)  */
2311bd4fe43Sopenharmony_ci  osPriorityRealtime      = 48,
2321bd4fe43Sopenharmony_ci  /** Real-time + 1 (unsupported) */
2331bd4fe43Sopenharmony_ci  osPriorityRealtime1     = 48+1,
2341bd4fe43Sopenharmony_ci  /** Real-time + 2 (unsupported) */
2351bd4fe43Sopenharmony_ci  osPriorityRealtime2     = 48+2,
2361bd4fe43Sopenharmony_ci  /** Real-time + 3 (unsupported) */
2371bd4fe43Sopenharmony_ci  osPriorityRealtime3     = 48+3,
2381bd4fe43Sopenharmony_ci  /** Real-time + 4 (unsupported) */
2391bd4fe43Sopenharmony_ci  osPriorityRealtime4     = 48+4,
2401bd4fe43Sopenharmony_ci  /** Real-time + 5 (unsupported) */
2411bd4fe43Sopenharmony_ci  osPriorityRealtime5     = 48+5,
2421bd4fe43Sopenharmony_ci  /** Real-time + 6 (unsupported) */
2431bd4fe43Sopenharmony_ci  osPriorityRealtime6     = 48+6,
2441bd4fe43Sopenharmony_ci  /** Real-time + 7 (unsupported) */
2451bd4fe43Sopenharmony_ci  osPriorityRealtime7     = 48+7,
2461bd4fe43Sopenharmony_ci  /** Reserved for ISR deferred threads (unsupported) */
2471bd4fe43Sopenharmony_ci  osPriorityISR           = 56,
2481bd4fe43Sopenharmony_ci  /** Invalid */
2491bd4fe43Sopenharmony_ci  osPriorityError         = -1,
2501bd4fe43Sopenharmony_ci  /** Reserved. It enables the compiler to identify enumeration variables as 32-bit numbers and prevents the enumeration variables from being optimized. */
2511bd4fe43Sopenharmony_ci  osPriorityReserved      = 0x7FFFFFFF
2521bd4fe43Sopenharmony_ci} osPriority_t;
2531bd4fe43Sopenharmony_ci
2541bd4fe43Sopenharmony_ci/**
2551bd4fe43Sopenharmony_ci* @brief Callback for thread scheduling
2561bd4fe43Sopenharmony_ci*
2571bd4fe43Sopenharmony_ci*/
2581bd4fe43Sopenharmony_citypedef void (*osThreadFunc_t) (void *argument);
2591bd4fe43Sopenharmony_ci
2601bd4fe43Sopenharmony_ci/**
2611bd4fe43Sopenharmony_ci* @brief Callback for timer triggering
2621bd4fe43Sopenharmony_ci*
2631bd4fe43Sopenharmony_ci*/
2641bd4fe43Sopenharmony_citypedef void (*osTimerFunc_t) (void *argument);
2651bd4fe43Sopenharmony_ci
2661bd4fe43Sopenharmony_ci/**
2671bd4fe43Sopenharmony_ci* @brief Enumerates timer types.
2681bd4fe43Sopenharmony_ci*
2691bd4fe43Sopenharmony_ci*/
2701bd4fe43Sopenharmony_citypedef enum {
2711bd4fe43Sopenharmony_ci  /** One-shot timer */
2721bd4fe43Sopenharmony_ci  osTimerOnce               = 0,
2731bd4fe43Sopenharmony_ci  /** Repeating timer */
2741bd4fe43Sopenharmony_ci  osTimerPeriodic           = 1
2751bd4fe43Sopenharmony_ci} osTimerType_t;
2761bd4fe43Sopenharmony_ci
2771bd4fe43Sopenharmony_ci/**
2781bd4fe43Sopenharmony_ci* @brief Indicates that the RTOS waits forever unless an event flag is received.
2791bd4fe43Sopenharmony_ci*
2801bd4fe43Sopenharmony_ci*/
2811bd4fe43Sopenharmony_ci#define osWaitForever         0xFFFFFFFFU
2821bd4fe43Sopenharmony_ci
2831bd4fe43Sopenharmony_ci/**
2841bd4fe43Sopenharmony_ci* @brief Indicates that the RTOS does not wait.
2851bd4fe43Sopenharmony_ci*
2861bd4fe43Sopenharmony_ci*/
2871bd4fe43Sopenharmony_ci#define osNoWait              0x0U
2881bd4fe43Sopenharmony_ci
2891bd4fe43Sopenharmony_ci/**
2901bd4fe43Sopenharmony_ci* @brief Indicates that the RTOS waits until any event flag is triggered.
2911bd4fe43Sopenharmony_ci*
2921bd4fe43Sopenharmony_ci*/
2931bd4fe43Sopenharmony_ci#define osFlagsWaitAny        0x00000000U
2941bd4fe43Sopenharmony_ci
2951bd4fe43Sopenharmony_ci/**
2961bd4fe43Sopenharmony_ci* @brief Indicates that the system waits until all event flags are triggered.
2971bd4fe43Sopenharmony_ci*
2981bd4fe43Sopenharmony_ci*/
2991bd4fe43Sopenharmony_ci#define osFlagsWaitAll        0x00000001U
3001bd4fe43Sopenharmony_ci
3011bd4fe43Sopenharmony_ci/**
3021bd4fe43Sopenharmony_ci* @brief Indicates that defined flags are not cleared.
3031bd4fe43Sopenharmony_ci*
3041bd4fe43Sopenharmony_ci*/
3051bd4fe43Sopenharmony_ci#define osFlagsNoClear        0x00000002U
3061bd4fe43Sopenharmony_ci
3071bd4fe43Sopenharmony_ci/**
3081bd4fe43Sopenharmony_ci* @brief Indicates a flag error.
3091bd4fe43Sopenharmony_ci*
3101bd4fe43Sopenharmony_ci*/
3111bd4fe43Sopenharmony_ci#define osFlagsError          0x80000000U
3121bd4fe43Sopenharmony_ci
3131bd4fe43Sopenharmony_ci/**
3141bd4fe43Sopenharmony_ci* @brief Indicates an unknown error.
3151bd4fe43Sopenharmony_ci*
3161bd4fe43Sopenharmony_ci*/
3171bd4fe43Sopenharmony_ci#define osFlagsErrorUnknown   0xFFFFFFFFU
3181bd4fe43Sopenharmony_ci
3191bd4fe43Sopenharmony_ci/**
3201bd4fe43Sopenharmony_ci* @brief Indicates a timeout.
3211bd4fe43Sopenharmony_ci*
3221bd4fe43Sopenharmony_ci*/
3231bd4fe43Sopenharmony_ci#define osFlagsErrorTimeout   0xFFFFFFFEU
3241bd4fe43Sopenharmony_ci
3251bd4fe43Sopenharmony_ci/**
3261bd4fe43Sopenharmony_ci* @brief Indicates a resource error.
3271bd4fe43Sopenharmony_ci*
3281bd4fe43Sopenharmony_ci*/
3291bd4fe43Sopenharmony_ci#define osFlagsErrorResource  0xFFFFFFFDU
3301bd4fe43Sopenharmony_ci
3311bd4fe43Sopenharmony_ci/**
3321bd4fe43Sopenharmony_ci* @brief Indicates an incorrect parameter.
3331bd4fe43Sopenharmony_ci*
3341bd4fe43Sopenharmony_ci*/
3351bd4fe43Sopenharmony_ci#define osFlagsErrorParameter 0xFFFFFFFCU
3361bd4fe43Sopenharmony_ci#define osFlagsErrorISR       0xFFFFFFFAU
3371bd4fe43Sopenharmony_ci
3381bd4fe43Sopenharmony_ci// Thread attributes (attr_bits in \ref osThreadAttr_t).
3391bd4fe43Sopenharmony_ci#define osThreadDetached      0x00000000U
3401bd4fe43Sopenharmony_ci#define osThreadJoinable      0x00000001U
3411bd4fe43Sopenharmony_ci
3421bd4fe43Sopenharmony_ci// Mutex attributes (attr_bits in \ref osMutexAttr_t).
3431bd4fe43Sopenharmony_ci#define osMutexRecursive      0x00000001U
3441bd4fe43Sopenharmony_ci#define osMutexPrioInherit    0x00000002U
3451bd4fe43Sopenharmony_ci#define osMutexRobust         0x00000008U
3461bd4fe43Sopenharmony_ci
3471bd4fe43Sopenharmony_ci/**
3481bd4fe43Sopenharmony_ci* @brief Enumerates return values of CMSIS-RTOS.
3491bd4fe43Sopenharmony_ci*
3501bd4fe43Sopenharmony_ci*/
3511bd4fe43Sopenharmony_citypedef enum {
3521bd4fe43Sopenharmony_ci  /** Operation completed successfully */
3531bd4fe43Sopenharmony_ci  osOK                      =  0,
3541bd4fe43Sopenharmony_ci  /** Unspecified error */
3551bd4fe43Sopenharmony_ci  osError                   = -1,
3561bd4fe43Sopenharmony_ci  /** Timeout */
3571bd4fe43Sopenharmony_ci  osErrorTimeout            = -2,
3581bd4fe43Sopenharmony_ci  /** Resource error */
3591bd4fe43Sopenharmony_ci  osErrorResource           = -3,
3601bd4fe43Sopenharmony_ci  /** Incorrect parameter */
3611bd4fe43Sopenharmony_ci  osErrorParameter          = -4,
3621bd4fe43Sopenharmony_ci  /** Insufficient memory */
3631bd4fe43Sopenharmony_ci  osErrorNoMemory           = -5,
3641bd4fe43Sopenharmony_ci  /** Service interruption */
3651bd4fe43Sopenharmony_ci  osErrorISR                = -6,
3661bd4fe43Sopenharmony_ci  /** Reserved. It is used to prevent the compiler from optimizing enumerations. */
3671bd4fe43Sopenharmony_ci  osStatusReserved          = 0x7FFFFFFF
3681bd4fe43Sopenharmony_ci} osStatus_t;
3691bd4fe43Sopenharmony_ci
3701bd4fe43Sopenharmony_ci/**
3711bd4fe43Sopenharmony_ci* @brief Identifies a thread.
3721bd4fe43Sopenharmony_ci*
3731bd4fe43Sopenharmony_ci*/
3741bd4fe43Sopenharmony_citypedef void *osThreadId_t;
3751bd4fe43Sopenharmony_ci
3761bd4fe43Sopenharmony_ci/**
3771bd4fe43Sopenharmony_ci* @brief Identifies a timer.
3781bd4fe43Sopenharmony_ci*
3791bd4fe43Sopenharmony_ci*/
3801bd4fe43Sopenharmony_citypedef void *osTimerId_t;
3811bd4fe43Sopenharmony_ci
3821bd4fe43Sopenharmony_ci/**
3831bd4fe43Sopenharmony_ci* @brief Identifies an event flag.
3841bd4fe43Sopenharmony_ci*
3851bd4fe43Sopenharmony_ci*/
3861bd4fe43Sopenharmony_citypedef void *osEventFlagsId_t;
3871bd4fe43Sopenharmony_ci
3881bd4fe43Sopenharmony_ci/**
3891bd4fe43Sopenharmony_ci* @brief Identifies a mutex.
3901bd4fe43Sopenharmony_ci*
3911bd4fe43Sopenharmony_ci*/
3921bd4fe43Sopenharmony_citypedef void *osMutexId_t;
3931bd4fe43Sopenharmony_ci
3941bd4fe43Sopenharmony_ci/**
3951bd4fe43Sopenharmony_ci* @brief Identifies a semaphore object.
3961bd4fe43Sopenharmony_ci*
3971bd4fe43Sopenharmony_ci*/
3981bd4fe43Sopenharmony_citypedef void *osSemaphoreId_t;
3991bd4fe43Sopenharmony_ci
4001bd4fe43Sopenharmony_ci
4011bd4fe43Sopenharmony_citypedef void *osMemoryPoolId_t;
4021bd4fe43Sopenharmony_ci
4031bd4fe43Sopenharmony_ci/**
4041bd4fe43Sopenharmony_ci* @brief Identifies a message queue.
4051bd4fe43Sopenharmony_ci*
4061bd4fe43Sopenharmony_ci*/
4071bd4fe43Sopenharmony_citypedef void *osMessageQueueId_t;
4081bd4fe43Sopenharmony_ci
4091bd4fe43Sopenharmony_ci
4101bd4fe43Sopenharmony_ci#ifndef TZ_MODULEID_T
4111bd4fe43Sopenharmony_ci#define TZ_MODULEID_T
4121bd4fe43Sopenharmony_ci
4131bd4fe43Sopenharmony_ci/**
4141bd4fe43Sopenharmony_ci* @brief Identifies a TrustZone module call process.
4151bd4fe43Sopenharmony_ci*
4161bd4fe43Sopenharmony_ci*/
4171bd4fe43Sopenharmony_citypedef uint32_t TZ_ModuleId_t;
4181bd4fe43Sopenharmony_ci#endif
4191bd4fe43Sopenharmony_ci
4201bd4fe43Sopenharmony_ci/**
4211bd4fe43Sopenharmony_ci* @brief Describes thread attributes.
4221bd4fe43Sopenharmony_ci*
4231bd4fe43Sopenharmony_ci* @since 1.0
4241bd4fe43Sopenharmony_ci* @version 1.0
4251bd4fe43Sopenharmony_ci*/
4261bd4fe43Sopenharmony_citypedef struct {
4271bd4fe43Sopenharmony_ci  /** Thread name */
4281bd4fe43Sopenharmony_ci  const char                   *name;
4291bd4fe43Sopenharmony_ci  /** Thread attribute bits */
4301bd4fe43Sopenharmony_ci  uint32_t                 attr_bits;
4311bd4fe43Sopenharmony_ci  /** Memory for the thread control block */
4321bd4fe43Sopenharmony_ci  void                      *cb_mem;
4331bd4fe43Sopenharmony_ci  /** Size of the memory for the thread control block */
4341bd4fe43Sopenharmony_ci  uint32_t                   cb_size;
4351bd4fe43Sopenharmony_ci  /** Memory for the thread stack */
4361bd4fe43Sopenharmony_ci  void                   *stack_mem;
4371bd4fe43Sopenharmony_ci  /** Size of the thread stack */
4381bd4fe43Sopenharmony_ci  uint32_t                stack_size;
4391bd4fe43Sopenharmony_ci  /** Thread priority */
4401bd4fe43Sopenharmony_ci  osPriority_t              priority;
4411bd4fe43Sopenharmony_ci  /** TrustZone module of the thread */
4421bd4fe43Sopenharmony_ci  TZ_ModuleId_t            tz_module;
4431bd4fe43Sopenharmony_ci  /** Reserved */
4441bd4fe43Sopenharmony_ci  uint32_t                  reserved;
4451bd4fe43Sopenharmony_ci} osThreadAttr_t;
4461bd4fe43Sopenharmony_ci
4471bd4fe43Sopenharmony_ci/**
4481bd4fe43Sopenharmony_ci* @brief Describes timer attributes.
4491bd4fe43Sopenharmony_ci*
4501bd4fe43Sopenharmony_ci* @since 1.0
4511bd4fe43Sopenharmony_ci* @version 1.0
4521bd4fe43Sopenharmony_ci*/
4531bd4fe43Sopenharmony_citypedef struct {
4541bd4fe43Sopenharmony_ci  /** Timer name */
4551bd4fe43Sopenharmony_ci  const char                   *name;
4561bd4fe43Sopenharmony_ci  /** Reserved attribute bits */
4571bd4fe43Sopenharmony_ci  uint32_t                 attr_bits;
4581bd4fe43Sopenharmony_ci  /** Memory for the timer control block */
4591bd4fe43Sopenharmony_ci  void                      *cb_mem;
4601bd4fe43Sopenharmony_ci  /** Size of the memory for the timer control block */
4611bd4fe43Sopenharmony_ci  uint32_t                   cb_size;
4621bd4fe43Sopenharmony_ci} osTimerAttr_t;
4631bd4fe43Sopenharmony_ci
4641bd4fe43Sopenharmony_ci/**
4651bd4fe43Sopenharmony_ci* @brief Describes event attributes.
4661bd4fe43Sopenharmony_ci*
4671bd4fe43Sopenharmony_ci* @since 1.0
4681bd4fe43Sopenharmony_ci* @version 1.0
4691bd4fe43Sopenharmony_ci*/
4701bd4fe43Sopenharmony_citypedef struct {
4711bd4fe43Sopenharmony_ci  /** Event name */
4721bd4fe43Sopenharmony_ci  const char                   *name;
4731bd4fe43Sopenharmony_ci  /** Reserved attribute bits */
4741bd4fe43Sopenharmony_ci  uint32_t                 attr_bits;
4751bd4fe43Sopenharmony_ci  /** Memory for the event control block */
4761bd4fe43Sopenharmony_ci  void                      *cb_mem;
4771bd4fe43Sopenharmony_ci  /** Size of the memory for the event control block */
4781bd4fe43Sopenharmony_ci  uint32_t                   cb_size;
4791bd4fe43Sopenharmony_ci} osEventFlagsAttr_t;
4801bd4fe43Sopenharmony_ci
4811bd4fe43Sopenharmony_ci/**
4821bd4fe43Sopenharmony_ci* @brief Describes mutex attributes.
4831bd4fe43Sopenharmony_ci*
4841bd4fe43Sopenharmony_ci* @since 1.0
4851bd4fe43Sopenharmony_ci* @version 1.0
4861bd4fe43Sopenharmony_ci*/
4871bd4fe43Sopenharmony_citypedef struct {
4881bd4fe43Sopenharmony_ci  /** Mutex name */
4891bd4fe43Sopenharmony_ci  const char                   *name;
4901bd4fe43Sopenharmony_ci  /** Reserved attribute bits */
4911bd4fe43Sopenharmony_ci  uint32_t                 attr_bits;
4921bd4fe43Sopenharmony_ci  /** Memory for the mutex control block */
4931bd4fe43Sopenharmony_ci  void                      *cb_mem;
4941bd4fe43Sopenharmony_ci  /** Size of the memory for the mutex control block */
4951bd4fe43Sopenharmony_ci  uint32_t                   cb_size;
4961bd4fe43Sopenharmony_ci} osMutexAttr_t;
4971bd4fe43Sopenharmony_ci
4981bd4fe43Sopenharmony_ci/**
4991bd4fe43Sopenharmony_ci* @brief Describes semaphore attributes.
5001bd4fe43Sopenharmony_ci*
5011bd4fe43Sopenharmony_ci* @since 1.0
5021bd4fe43Sopenharmony_ci* @version 1.0
5031bd4fe43Sopenharmony_ci*/
5041bd4fe43Sopenharmony_citypedef struct {
5051bd4fe43Sopenharmony_ci  /** Semaphore name */
5061bd4fe43Sopenharmony_ci  const char                   *name;
5071bd4fe43Sopenharmony_ci  /** Reserved attribute bits */
5081bd4fe43Sopenharmony_ci  uint32_t                 attr_bits;
5091bd4fe43Sopenharmony_ci  /** Memory for the semaphore control block */
5101bd4fe43Sopenharmony_ci  void                      *cb_mem;
5111bd4fe43Sopenharmony_ci  /** Size of the memory for the semaphore control block */
5121bd4fe43Sopenharmony_ci  uint32_t                   cb_size;
5131bd4fe43Sopenharmony_ci} osSemaphoreAttr_t;
5141bd4fe43Sopenharmony_ci
5151bd4fe43Sopenharmony_ci
5161bd4fe43Sopenharmony_citypedef struct {
5171bd4fe43Sopenharmony_ci  const char                   *name;
5181bd4fe43Sopenharmony_ci  uint32_t                 attr_bits;
5191bd4fe43Sopenharmony_ci  void                      *cb_mem;
5201bd4fe43Sopenharmony_ci  uint32_t                   cb_size;
5211bd4fe43Sopenharmony_ci  void                      *mp_mem;
5221bd4fe43Sopenharmony_ci  uint32_t                   mp_size;
5231bd4fe43Sopenharmony_ci} osMemoryPoolAttr_t;
5241bd4fe43Sopenharmony_ci
5251bd4fe43Sopenharmony_ci/**
5261bd4fe43Sopenharmony_ci* @brief Describes message queue attributes.
5271bd4fe43Sopenharmony_ci*
5281bd4fe43Sopenharmony_ci* @since 1.0
5291bd4fe43Sopenharmony_ci* @version 1.0
5301bd4fe43Sopenharmony_ci*/
5311bd4fe43Sopenharmony_citypedef struct {
5321bd4fe43Sopenharmony_ci  /** Message queue name */
5331bd4fe43Sopenharmony_ci  const char                   *name;
5341bd4fe43Sopenharmony_ci  /** Reserved attribute bits */
5351bd4fe43Sopenharmony_ci  uint32_t                 attr_bits;
5361bd4fe43Sopenharmony_ci  /** Memory for the message queue control block */
5371bd4fe43Sopenharmony_ci  void                      *cb_mem;
5381bd4fe43Sopenharmony_ci  /** Size of the memory for the message queue control block */
5391bd4fe43Sopenharmony_ci  uint32_t                   cb_size;
5401bd4fe43Sopenharmony_ci  /** Memory for storing data in the message queue */
5411bd4fe43Sopenharmony_ci  void                      *mq_mem;
5421bd4fe43Sopenharmony_ci  /** Size of the memory for storing data in the message queue */
5431bd4fe43Sopenharmony_ci  uint32_t                   mq_size;
5441bd4fe43Sopenharmony_ci} osMessageQueueAttr_t;
5451bd4fe43Sopenharmony_ci
5461bd4fe43Sopenharmony_ci
5471bd4fe43Sopenharmony_ci//  ==== Kernel Management Functions ====
5481bd4fe43Sopenharmony_ci
5491bd4fe43Sopenharmony_ci/**
5501bd4fe43Sopenharmony_ci* @brief Initializes the RTOS kernel.
5511bd4fe43Sopenharmony_ci*
5521bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
5531bd4fe43Sopenharmony_ci* @since 1.0
5541bd4fe43Sopenharmony_ci* @version 1.0
5551bd4fe43Sopenharmony_ci*/
5561bd4fe43Sopenharmony_ciosStatus_t osKernelInitialize (void);
5571bd4fe43Sopenharmony_ci
5581bd4fe43Sopenharmony_ci/**
5591bd4fe43Sopenharmony_ci* @brief Obtains the system version and name.
5601bd4fe43Sopenharmony_ci*
5611bd4fe43Sopenharmony_ci* @param version Indicates the pointer to the buffer for storing the version.
5621bd4fe43Sopenharmony_ci* @param id_buf Indicates the pointer to the buffer for storing the kernel ID.
5631bd4fe43Sopenharmony_ci* @param id_size Indicates the size of the buffer for storing the kernel ID.
5641bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
5651bd4fe43Sopenharmony_ci* @since 1.0
5661bd4fe43Sopenharmony_ci* @version 1.0
5671bd4fe43Sopenharmony_ci*/
5681bd4fe43Sopenharmony_ciosStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size);
5691bd4fe43Sopenharmony_ci
5701bd4fe43Sopenharmony_ci/**
5711bd4fe43Sopenharmony_ci* @brief Obtains the kernel state.
5721bd4fe43Sopenharmony_ci*
5731bd4fe43Sopenharmony_ci* @return Returns the kernel state.
5741bd4fe43Sopenharmony_ci* @since 1.0
5751bd4fe43Sopenharmony_ci* @version 1.0
5761bd4fe43Sopenharmony_ci*/
5771bd4fe43Sopenharmony_ciosKernelState_t osKernelGetState (void);
5781bd4fe43Sopenharmony_ci
5791bd4fe43Sopenharmony_ci/**
5801bd4fe43Sopenharmony_ci* @brief Starts the kernel.
5811bd4fe43Sopenharmony_ci*
5821bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
5831bd4fe43Sopenharmony_ci* @since 1.0
5841bd4fe43Sopenharmony_ci* @version 1.0
5851bd4fe43Sopenharmony_ci*/
5861bd4fe43Sopenharmony_ciosStatus_t osKernelStart (void);
5871bd4fe43Sopenharmony_ci
5881bd4fe43Sopenharmony_ci/**
5891bd4fe43Sopenharmony_ci* @brief Locks the kernel.
5901bd4fe43Sopenharmony_ci*
5911bd4fe43Sopenharmony_ci* @return Returns 1 if the kernel is locked successfully; returns 0 if the lock starts; returns a negative value in the case of an error.
5921bd4fe43Sopenharmony_ci* @since 1.0
5931bd4fe43Sopenharmony_ci* @version 1.0
5941bd4fe43Sopenharmony_ci*/
5951bd4fe43Sopenharmony_ciint32_t osKernelLock (void);
5961bd4fe43Sopenharmony_ci
5971bd4fe43Sopenharmony_ci/**
5981bd4fe43Sopenharmony_ci* @brief Unlocks the kernel.
5991bd4fe43Sopenharmony_ci*
6001bd4fe43Sopenharmony_ci* @return Returns 1 if the kernel is unlocked successfully; returns 0 if the kernel is not locked; returns a negative value in the case of an error.
6011bd4fe43Sopenharmony_ci* @since 1.0
6021bd4fe43Sopenharmony_ci* @version 1.0
6031bd4fe43Sopenharmony_ci*/
6041bd4fe43Sopenharmony_ciint32_t osKernelUnlock (void);
6051bd4fe43Sopenharmony_ci
6061bd4fe43Sopenharmony_ci/**
6071bd4fe43Sopenharmony_ci* @brief Restores the previous lock state of the kernel.
6081bd4fe43Sopenharmony_ci*
6091bd4fe43Sopenharmony_ci* @param lock Indicates the lock state to restore to. The value 1 indicates the locked state, and 0 indicates the unlocked state.
6101bd4fe43Sopenharmony_ci* @return Returns 1 if the kernel is locked; returns 0 if the kernel is not locked; returns a negative value in the case of an error.
6111bd4fe43Sopenharmony_ci* @since 1.0
6121bd4fe43Sopenharmony_ci* @version 1.0
6131bd4fe43Sopenharmony_ci*/
6141bd4fe43Sopenharmony_ciint32_t osKernelRestoreLock (int32_t lock);
6151bd4fe43Sopenharmony_ci
6161bd4fe43Sopenharmony_ciuint32_t osKernelSuspend (void);
6171bd4fe43Sopenharmony_ci
6181bd4fe43Sopenharmony_civoid osKernelResume (uint32_t sleep_ticks);
6191bd4fe43Sopenharmony_ci
6201bd4fe43Sopenharmony_ci/// Get the RTOS kernel tick count.
6211bd4fe43Sopenharmony_ci/// \return RTOS kernel current tick count.
6221bd4fe43Sopenharmony_ciuint32_t osKernelGetTickCount (void);
6231bd4fe43Sopenharmony_ci
6241bd4fe43Sopenharmony_ci
6251bd4fe43Sopenharmony_ci
6261bd4fe43Sopenharmony_ci/**
6271bd4fe43Sopenharmony_ci* @brief Obtains the number of kernel ticks per second.
6281bd4fe43Sopenharmony_ci*
6291bd4fe43Sopenharmony_ci* @return Returns the number of kernel ticks.
6301bd4fe43Sopenharmony_ci* @since 1.0
6311bd4fe43Sopenharmony_ci* @version 1.0
6321bd4fe43Sopenharmony_ci*/
6331bd4fe43Sopenharmony_ciuint32_t osKernelGetTickFreq (void);
6341bd4fe43Sopenharmony_ci
6351bd4fe43Sopenharmony_ci/**
6361bd4fe43Sopenharmony_ci* @brief Obtains the kernel system timer.
6371bd4fe43Sopenharmony_ci*
6381bd4fe43Sopenharmony_ci* @return Returns the kernel system timer.
6391bd4fe43Sopenharmony_ci* @since 1.0
6401bd4fe43Sopenharmony_ci* @version 1.0
6411bd4fe43Sopenharmony_ci*/
6421bd4fe43Sopenharmony_ciuint32_t osKernelGetSysTimerCount (void);
6431bd4fe43Sopenharmony_ci
6441bd4fe43Sopenharmony_ci/**
6451bd4fe43Sopenharmony_ci* @brief Obtains the frequency of the system timer.
6461bd4fe43Sopenharmony_ci*
6471bd4fe43Sopenharmony_ci* @return Returns the system timer frequency.
6481bd4fe43Sopenharmony_ci* @since 1.0
6491bd4fe43Sopenharmony_ci* @version 1.0
6501bd4fe43Sopenharmony_ci*/
6511bd4fe43Sopenharmony_ciuint32_t osKernelGetSysTimerFreq (void);
6521bd4fe43Sopenharmony_ci
6531bd4fe43Sopenharmony_ci
6541bd4fe43Sopenharmony_ci//  ==== Thread Management Functions ====
6551bd4fe43Sopenharmony_ci
6561bd4fe43Sopenharmony_ci/**
6571bd4fe43Sopenharmony_ci* @brief Creates an active thread.
6581bd4fe43Sopenharmony_ci*
6591bd4fe43Sopenharmony_ci* The priority ranges from 9 to 38. Select a proper priority as required.
6601bd4fe43Sopenharmony_ci* The maximum of tasks is LOSCFG_BASE_CORE_TSK_LIMIT(LOSCFG_BASE_CORE_TSK_LIMIT is defined in the traget_config.h).
6611bd4fe43Sopenharmony_ci* @param func Indicates the entry of the thread callback function.
6621bd4fe43Sopenharmony_ci* @param argument Indicates the pointer to the argument passed to the thread.
6631bd4fe43Sopenharmony_ci* @param attr Indicates the thread attributes.
6641bd4fe43Sopenharmony_ci* @return Returns the thread ID; returns NULL in the case of an error.
6651bd4fe43Sopenharmony_ci* @since 1.0
6661bd4fe43Sopenharmony_ci* @version 1.0
6671bd4fe43Sopenharmony_ci*/
6681bd4fe43Sopenharmony_ciosThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
6691bd4fe43Sopenharmony_ci
6701bd4fe43Sopenharmony_ci/**
6711bd4fe43Sopenharmony_ci* @brief Obtains the name of a thread.
6721bd4fe43Sopenharmony_ci*
6731bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
6741bd4fe43Sopenharmony_ci* @return Returns the thread name; returns NULL in the case of an error.
6751bd4fe43Sopenharmony_ci* @since 1.0
6761bd4fe43Sopenharmony_ci* @version 1.0
6771bd4fe43Sopenharmony_ci*/
6781bd4fe43Sopenharmony_ciconst char *osThreadGetName (osThreadId_t thread_id);
6791bd4fe43Sopenharmony_ci
6801bd4fe43Sopenharmony_ci/**
6811bd4fe43Sopenharmony_ci* @brief Obtains the ID of the currently running thread.
6821bd4fe43Sopenharmony_ci*
6831bd4fe43Sopenharmony_ci* @return Returns the thread ID; returns NULL in the case of an error.
6841bd4fe43Sopenharmony_ci* @since 1.0
6851bd4fe43Sopenharmony_ci* @version 1.0
6861bd4fe43Sopenharmony_ci*/
6871bd4fe43Sopenharmony_ciosThreadId_t osThreadGetId (void);
6881bd4fe43Sopenharmony_ci
6891bd4fe43Sopenharmony_ci
6901bd4fe43Sopenharmony_ci/**
6911bd4fe43Sopenharmony_ci* @brief Obtains the state of a thread.
6921bd4fe43Sopenharmony_ci*
6931bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
6941bd4fe43Sopenharmony_ci* @return Returns the thread state.
6951bd4fe43Sopenharmony_ci* @since 1.0
6961bd4fe43Sopenharmony_ci* @version 1.0
6971bd4fe43Sopenharmony_ci*/
6981bd4fe43Sopenharmony_ciosThreadState_t osThreadGetState (osThreadId_t thread_id);
6991bd4fe43Sopenharmony_ci
7001bd4fe43Sopenharmony_ci/**
7011bd4fe43Sopenharmony_ci* @brief Obtains the stack size of a thread.
7021bd4fe43Sopenharmony_ci*
7031bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
7041bd4fe43Sopenharmony_ci* @return Returns the stack size, in bytes; returns 0 in the case of an error.
7051bd4fe43Sopenharmony_ci* @since 1.0
7061bd4fe43Sopenharmony_ci* @version 1.0
7071bd4fe43Sopenharmony_ci*/
7081bd4fe43Sopenharmony_ciuint32_t osThreadGetStackSize (osThreadId_t thread_id);
7091bd4fe43Sopenharmony_ci
7101bd4fe43Sopenharmony_ci/**
7111bd4fe43Sopenharmony_ci* @brief Obtains the size of the available stack space for a thread based on the stack watermark.
7121bd4fe43Sopenharmony_ci*
7131bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
7141bd4fe43Sopenharmony_ci* @return Returns the available stack size, in bytes; returns 0 in the case of an error.
7151bd4fe43Sopenharmony_ci* @since 1.0
7161bd4fe43Sopenharmony_ci* @version 1.0
7171bd4fe43Sopenharmony_ci*/
7181bd4fe43Sopenharmony_ciuint32_t osThreadGetStackSpace (osThreadId_t thread_id);
7191bd4fe43Sopenharmony_ci
7201bd4fe43Sopenharmony_ci/**
7211bd4fe43Sopenharmony_ci* @brief Changes the priority of a thread.
7221bd4fe43Sopenharmony_ci*
7231bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
7241bd4fe43Sopenharmony_ci* @param priority Indicates the new priority.
7251bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
7261bd4fe43Sopenharmony_ci* @since 1.0
7271bd4fe43Sopenharmony_ci* @version 1.0
7281bd4fe43Sopenharmony_ci*/
7291bd4fe43Sopenharmony_ciosStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority);
7301bd4fe43Sopenharmony_ci
7311bd4fe43Sopenharmony_ci/**
7321bd4fe43Sopenharmony_ci* @brief Gets the prority of an active thread.
7331bd4fe43Sopenharmony_ci*
7341bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
7351bd4fe43Sopenharmony_ci* @return Returns the prority of the thread.
7361bd4fe43Sopenharmony_ci* @since 1.0
7371bd4fe43Sopenharmony_ci* @version 1.0
7381bd4fe43Sopenharmony_ci*/
7391bd4fe43Sopenharmony_ciosPriority_t osThreadGetPriority (osThreadId_t thread_id);
7401bd4fe43Sopenharmony_ci
7411bd4fe43Sopenharmony_ci/**
7421bd4fe43Sopenharmony_ci* @brief Sets the currently running thread to the ready state.
7431bd4fe43Sopenharmony_ci*
7441bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
7451bd4fe43Sopenharmony_ci* @since 1.0
7461bd4fe43Sopenharmony_ci* @version 1.0
7471bd4fe43Sopenharmony_ci*/
7481bd4fe43Sopenharmony_ciosStatus_t osThreadYield (void);
7491bd4fe43Sopenharmony_ci
7501bd4fe43Sopenharmony_ci/**
7511bd4fe43Sopenharmony_ci* @brief Suspends a thread.
7521bd4fe43Sopenharmony_ci*
7531bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
7541bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
7551bd4fe43Sopenharmony_ci* @since 1.0
7561bd4fe43Sopenharmony_ci* @version 1.0
7571bd4fe43Sopenharmony_ci*/
7581bd4fe43Sopenharmony_ciosStatus_t osThreadSuspend (osThreadId_t thread_id);
7591bd4fe43Sopenharmony_ci
7601bd4fe43Sopenharmony_ci/**
7611bd4fe43Sopenharmony_ci* @brief Resumes a thread from the suspended state.
7621bd4fe43Sopenharmony_ci*
7631bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
7641bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
7651bd4fe43Sopenharmony_ci* @since 1.0
7661bd4fe43Sopenharmony_ci* @version 1.0
7671bd4fe43Sopenharmony_ci*/
7681bd4fe43Sopenharmony_ciosStatus_t osThreadResume (osThreadId_t thread_id);
7691bd4fe43Sopenharmony_ci
7701bd4fe43Sopenharmony_ciosStatus_t osThreadDetach (osThreadId_t thread_id);
7711bd4fe43Sopenharmony_ci
7721bd4fe43Sopenharmony_ciosStatus_t osThreadJoin (osThreadId_t thread_id);
7731bd4fe43Sopenharmony_ci
7741bd4fe43Sopenharmony_civoid osThreadExit (void);
7751bd4fe43Sopenharmony_ci
7761bd4fe43Sopenharmony_ci/**
7771bd4fe43Sopenharmony_ci* @brief Terminates a thread.
7781bd4fe43Sopenharmony_ci*
7791bd4fe43Sopenharmony_ci* @param thread_id Indicates the thread ID, which is obtained using osThreadNew or osThreadGetId.
7801bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
7811bd4fe43Sopenharmony_ci* @since 1.0
7821bd4fe43Sopenharmony_ci* @version 1.0
7831bd4fe43Sopenharmony_ci*/
7841bd4fe43Sopenharmony_ciosStatus_t osThreadTerminate (osThreadId_t thread_id);
7851bd4fe43Sopenharmony_ci
7861bd4fe43Sopenharmony_ci/**
7871bd4fe43Sopenharmony_ci* @brief Obtains the number of active threads.
7881bd4fe43Sopenharmony_ci*
7891bd4fe43Sopenharmony_ci* @return Returns the number; returns 0 in the case of an error.
7901bd4fe43Sopenharmony_ci* @since 1.0
7911bd4fe43Sopenharmony_ci* @version 1.0
7921bd4fe43Sopenharmony_ci*/
7931bd4fe43Sopenharmony_ciuint32_t osThreadGetCount (void);
7941bd4fe43Sopenharmony_ci
7951bd4fe43Sopenharmony_ciuint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items);
7961bd4fe43Sopenharmony_ci
7971bd4fe43Sopenharmony_ci
7981bd4fe43Sopenharmony_ci//  ==== Thread Flags Functions ====
7991bd4fe43Sopenharmony_ci
8001bd4fe43Sopenharmony_ciuint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags);
8011bd4fe43Sopenharmony_ci
8021bd4fe43Sopenharmony_ciuint32_t osThreadFlagsClear (uint32_t flags);
8031bd4fe43Sopenharmony_ci
8041bd4fe43Sopenharmony_ciuint32_t osThreadFlagsGet (void);
8051bd4fe43Sopenharmony_ci
8061bd4fe43Sopenharmony_ciuint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout);
8071bd4fe43Sopenharmony_ci
8081bd4fe43Sopenharmony_ci
8091bd4fe43Sopenharmony_ci//  ==== Generic Wait Functions ====
8101bd4fe43Sopenharmony_ci
8111bd4fe43Sopenharmony_ci/**
8121bd4fe43Sopenharmony_ci* @brief Waits for a period of time.
8131bd4fe43Sopenharmony_ci*
8141bd4fe43Sopenharmony_ci* @param ticks Indicates the number of ticks to wait for.
8151bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
8161bd4fe43Sopenharmony_ci* @since 1.0
8171bd4fe43Sopenharmony_ci* @version 1.0
8181bd4fe43Sopenharmony_ci*/
8191bd4fe43Sopenharmony_ciosStatus_t osDelay (uint32_t ticks);
8201bd4fe43Sopenharmony_ci
8211bd4fe43Sopenharmony_ci/**
8221bd4fe43Sopenharmony_ci* @brief Waits until a specified time arrives.
8231bd4fe43Sopenharmony_ci*
8241bd4fe43Sopenharmony_ci* This function handles the overflow of the system timer. Note that the maximum value of this parameter is (2^31 - 1) ticks.
8251bd4fe43Sopenharmony_ci* @param ticks Indicates the number of ticks converted from the absolute time.
8261bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
8271bd4fe43Sopenharmony_ci* @since 1.0
8281bd4fe43Sopenharmony_ci* @version 1.0
8291bd4fe43Sopenharmony_ci*/
8301bd4fe43Sopenharmony_ciosStatus_t osDelayUntil (uint32_t ticks);
8311bd4fe43Sopenharmony_ci
8321bd4fe43Sopenharmony_ci
8331bd4fe43Sopenharmony_ci//  ==== Timer Management Functions ====
8341bd4fe43Sopenharmony_ci
8351bd4fe43Sopenharmony_ci/**
8361bd4fe43Sopenharmony_ci* @brief Creates and initializes a timer.
8371bd4fe43Sopenharmony_ci*
8381bd4fe43Sopenharmony_ci* This function creates a timer associated with the arguments callback function. The timer stays in the stopped state until OSTimerStart is used to start the timer.
8391bd4fe43Sopenharmony_ci* The timer precision is 1000 / LOSCFG_BASE_CORE_TICK_PER_SECOND ms(LOSCFG_BASE_CORE_TICK_PER_SECOND is defined in the traget_config.h).
8401bd4fe43Sopenharmony_ci* @param func Indicates the entry of the timer callback function.
8411bd4fe43Sopenharmony_ci* @param type Indicates the timer type.
8421bd4fe43Sopenharmony_ci* @param argument Indicates the pointer to the argument used in timer callback.
8431bd4fe43Sopenharmony_ci* @param attr Indicates the pointer to the timer attributes. This parameter is not used.
8441bd4fe43Sopenharmony_ci* @return Returns the timer ID; returns NULL in the case of an error.
8451bd4fe43Sopenharmony_ci* @since 1.0
8461bd4fe43Sopenharmony_ci* @version 1.0
8471bd4fe43Sopenharmony_ci*/
8481bd4fe43Sopenharmony_ciosTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
8491bd4fe43Sopenharmony_ci
8501bd4fe43Sopenharmony_ci/**
8511bd4fe43Sopenharmony_ci* @brief Obtains the timer name.
8521bd4fe43Sopenharmony_ci*
8531bd4fe43Sopenharmony_ci* @param timer_id Indicates the timer ID, which is obtained using osTimerNew.
8541bd4fe43Sopenharmony_ci* @return Returns the timer name; returns NULL in the case of an error.
8551bd4fe43Sopenharmony_ci* @since 1.0
8561bd4fe43Sopenharmony_ci* @version 1.0
8571bd4fe43Sopenharmony_ci*/
8581bd4fe43Sopenharmony_ciconst char *osTimerGetName (osTimerId_t timer_id);
8591bd4fe43Sopenharmony_ci
8601bd4fe43Sopenharmony_ci/**
8611bd4fe43Sopenharmony_ci* @brief Starts or restarts a timer.
8621bd4fe43Sopenharmony_ci*
8631bd4fe43Sopenharmony_ci* @param timer_id Indicates the timer ID, which is obtained using osTimerNew.
8641bd4fe43Sopenharmony_ci* @param ticks Indicates the number of ticks since the timer starts running.
8651bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
8661bd4fe43Sopenharmony_ci* @since 1.0
8671bd4fe43Sopenharmony_ci* @version 1.0
8681bd4fe43Sopenharmony_ci*/
8691bd4fe43Sopenharmony_ciosStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks);
8701bd4fe43Sopenharmony_ci
8711bd4fe43Sopenharmony_ci/**
8721bd4fe43Sopenharmony_ci* @brief Stops a timer.
8731bd4fe43Sopenharmony_ci*
8741bd4fe43Sopenharmony_ci* @param timer_id Indicates the timer ID, which is obtained using osTimerNew.
8751bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
8761bd4fe43Sopenharmony_ci* @since 1.0
8771bd4fe43Sopenharmony_ci* @version 1.0
8781bd4fe43Sopenharmony_ci*/
8791bd4fe43Sopenharmony_ciosStatus_t osTimerStop (osTimerId_t timer_id);
8801bd4fe43Sopenharmony_ci
8811bd4fe43Sopenharmony_ci/**
8821bd4fe43Sopenharmony_ci* @brief Checks whether a timer is running.
8831bd4fe43Sopenharmony_ci*
8841bd4fe43Sopenharmony_ci* @param timer_id Indicates the timer ID, which is obtained using osTimerNew.
8851bd4fe43Sopenharmony_ci* @return Returns 1 if the timer is running; returns 0 otherwise.
8861bd4fe43Sopenharmony_ci* @since 1.0
8871bd4fe43Sopenharmony_ci* @version 1.0
8881bd4fe43Sopenharmony_ci*/
8891bd4fe43Sopenharmony_ciuint32_t osTimerIsRunning (osTimerId_t timer_id);
8901bd4fe43Sopenharmony_ci
8911bd4fe43Sopenharmony_ci/**
8921bd4fe43Sopenharmony_ci* @brief Deletes a timer.
8931bd4fe43Sopenharmony_ci*
8941bd4fe43Sopenharmony_ci* @param timer_id Indicates the timer ID, which is obtained using osTimerNew.
8951bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
8961bd4fe43Sopenharmony_ci* @since 1.0
8971bd4fe43Sopenharmony_ci* @version 1.0
8981bd4fe43Sopenharmony_ci*/
8991bd4fe43Sopenharmony_ciosStatus_t osTimerDelete (osTimerId_t timer_id);
9001bd4fe43Sopenharmony_ci
9011bd4fe43Sopenharmony_ci
9021bd4fe43Sopenharmony_ci//  ==== Event Flags Management Functions ====
9031bd4fe43Sopenharmony_ci
9041bd4fe43Sopenharmony_ci/**
9051bd4fe43Sopenharmony_ci* @brief Creates and initializes an event flags object.
9061bd4fe43Sopenharmony_ci*
9071bd4fe43Sopenharmony_ci* @param attr Indicates the pointer to the event flags attributes. This parameter is not used.
9081bd4fe43Sopenharmony_ci* @return Returns the event flags ID; returns NULL in the case of an error.
9091bd4fe43Sopenharmony_ci* @since 1.0
9101bd4fe43Sopenharmony_ci* @version 1.0
9111bd4fe43Sopenharmony_ci*/
9121bd4fe43Sopenharmony_ciosEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr);
9131bd4fe43Sopenharmony_ci
9141bd4fe43Sopenharmony_ci/**
9151bd4fe43Sopenharmony_ci* @brief Obtains the name of an event flags object.
9161bd4fe43Sopenharmony_ci*
9171bd4fe43Sopenharmony_ci* @param ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
9181bd4fe43Sopenharmony_ci* @return Returns the event flags name; returns NULL in the case of an error.
9191bd4fe43Sopenharmony_ci* @since 1.0
9201bd4fe43Sopenharmony_ci* @version 1.0
9211bd4fe43Sopenharmony_ci*/
9221bd4fe43Sopenharmony_ciconst char *osEventFlagsGetName (osEventFlagsId_t ef_id);
9231bd4fe43Sopenharmony_ci
9241bd4fe43Sopenharmony_ci/**
9251bd4fe43Sopenharmony_ci* @brief Sets event flags.
9261bd4fe43Sopenharmony_ci*
9271bd4fe43Sopenharmony_ci* @param ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
9281bd4fe43Sopenharmony_ci* @param flags Indicates the event flags to set.
9291bd4fe43Sopenharmony_ci* @return Returns the event flags; returns osFlagsErrorParameter in the case of an error.
9301bd4fe43Sopenharmony_ci* @since 1.0
9311bd4fe43Sopenharmony_ci* @version 1.0
9321bd4fe43Sopenharmony_ci*/
9331bd4fe43Sopenharmony_ciuint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags);
9341bd4fe43Sopenharmony_ci
9351bd4fe43Sopenharmony_ci/**
9361bd4fe43Sopenharmony_ci* @brief Clears event flags.
9371bd4fe43Sopenharmony_ci*
9381bd4fe43Sopenharmony_ci* @param ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
9391bd4fe43Sopenharmony_ci* @param flags Indicates the event flags to clear.
9401bd4fe43Sopenharmony_ci* @return Returns the event flags; returns osFlagsErrorParameter in the case of an error.
9411bd4fe43Sopenharmony_ci* @since 1.0
9421bd4fe43Sopenharmony_ci* @version 1.0
9431bd4fe43Sopenharmony_ci*/
9441bd4fe43Sopenharmony_ciuint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags);
9451bd4fe43Sopenharmony_ci
9461bd4fe43Sopenharmony_ci/**
9471bd4fe43Sopenharmony_ci* @brief Obtains event flags.
9481bd4fe43Sopenharmony_ci*
9491bd4fe43Sopenharmony_ci* @param ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
9501bd4fe43Sopenharmony_ci* @return Returns the event flags triggered.
9511bd4fe43Sopenharmony_ci* @since 1.0
9521bd4fe43Sopenharmony_ci* @version 1.0
9531bd4fe43Sopenharmony_ci*/
9541bd4fe43Sopenharmony_ciuint32_t osEventFlagsGet (osEventFlagsId_t ef_id);
9551bd4fe43Sopenharmony_ci
9561bd4fe43Sopenharmony_ci/**
9571bd4fe43Sopenharmony_ci* @brief Waits for event flags to trigger.
9581bd4fe43Sopenharmony_ci*
9591bd4fe43Sopenharmony_ci* When the specified flag of the event is set, the function returns immediately. Otherwise, the thread is blocked.
9601bd4fe43Sopenharmony_ci* @param ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
9611bd4fe43Sopenharmony_ci* @param flags Indicates the event flags to trigger.
9621bd4fe43Sopenharmony_ci* @param options Indicates the configuration of the event flags to trigger.
9631bd4fe43Sopenharmony_ci* @param timeout Indicates the timeout duration.
9641bd4fe43Sopenharmony_ci* @return Returns the triggered event flags; returns an error value in the case of an error.
9651bd4fe43Sopenharmony_ci* @since 1.0
9661bd4fe43Sopenharmony_ci* @version 1.0
9671bd4fe43Sopenharmony_ci*/
9681bd4fe43Sopenharmony_ciuint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);
9691bd4fe43Sopenharmony_ci
9701bd4fe43Sopenharmony_ci/**
9711bd4fe43Sopenharmony_ci* @brief Deletes an event flags object.
9721bd4fe43Sopenharmony_ci*
9731bd4fe43Sopenharmony_ci* @param ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
9741bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
9751bd4fe43Sopenharmony_ci* @since 1.0
9761bd4fe43Sopenharmony_ci* @version 1.0
9771bd4fe43Sopenharmony_ci*/
9781bd4fe43Sopenharmony_ciosStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id);
9791bd4fe43Sopenharmony_ci
9801bd4fe43Sopenharmony_ci
9811bd4fe43Sopenharmony_ci//  ==== Mutex Management Functions ====
9821bd4fe43Sopenharmony_ci
9831bd4fe43Sopenharmony_ci/**
9841bd4fe43Sopenharmony_ci* @brief Creates and initializes a mutex.
9851bd4fe43Sopenharmony_ci*
9861bd4fe43Sopenharmony_ci* @param attr Indicates the pointer to the mutex attributes. This parameter is not used.
9871bd4fe43Sopenharmony_ci* @return Returns the mutex ID; returns NULL in the case of an error.
9881bd4fe43Sopenharmony_ci* @since 1.0
9891bd4fe43Sopenharmony_ci* @version 1.0
9901bd4fe43Sopenharmony_ci*/
9911bd4fe43Sopenharmony_ciosMutexId_t osMutexNew (const osMutexAttr_t *attr);
9921bd4fe43Sopenharmony_ci
9931bd4fe43Sopenharmony_ciconst char *osMutexGetName (osMutexId_t mutex_id);
9941bd4fe43Sopenharmony_ci
9951bd4fe43Sopenharmony_ci/**
9961bd4fe43Sopenharmony_ci* @brief Obtains a mutex.
9971bd4fe43Sopenharmony_ci*
9981bd4fe43Sopenharmony_ci* @param mutex_id Indicates the mutex ID, which is obtained using osMutexNew.
9991bd4fe43Sopenharmony_ci* @param timeout Indicates the timeout duration.
10001bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
10011bd4fe43Sopenharmony_ci* @since 1.0
10021bd4fe43Sopenharmony_ci* @version 1.0
10031bd4fe43Sopenharmony_ci*/
10041bd4fe43Sopenharmony_ciosStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout);
10051bd4fe43Sopenharmony_ci
10061bd4fe43Sopenharmony_ci/**
10071bd4fe43Sopenharmony_ci* @brief Releases a mutex.
10081bd4fe43Sopenharmony_ci*
10091bd4fe43Sopenharmony_ci* @param mutex_id Indicates the mutex ID, which is obtained using osMutexNew.
10101bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
10111bd4fe43Sopenharmony_ci* @since 1.0
10121bd4fe43Sopenharmony_ci* @version 1.0
10131bd4fe43Sopenharmony_ci*/
10141bd4fe43Sopenharmony_ciosStatus_t osMutexRelease (osMutexId_t mutex_id);
10151bd4fe43Sopenharmony_ci
10161bd4fe43Sopenharmony_ci/**
10171bd4fe43Sopenharmony_ci* @brief Obtains the thread ID of the currently acquired mutex.
10181bd4fe43Sopenharmony_ci*
10191bd4fe43Sopenharmony_ci* @param mutex_id Indicates the mutex ID, which is obtained using osMutexNew.
10201bd4fe43Sopenharmony_ci* @return Returns the thread ID.
10211bd4fe43Sopenharmony_ci* @since 1.0
10221bd4fe43Sopenharmony_ci* @version 1.0
10231bd4fe43Sopenharmony_ci*/
10241bd4fe43Sopenharmony_ciosThreadId_t osMutexGetOwner (osMutexId_t mutex_id);
10251bd4fe43Sopenharmony_ci
10261bd4fe43Sopenharmony_ci/**
10271bd4fe43Sopenharmony_ci* @brief Deletes a mutex.
10281bd4fe43Sopenharmony_ci*
10291bd4fe43Sopenharmony_ci* @param mutex_id Indicates the mutex ID, which is obtained using osMutexNew.
10301bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
10311bd4fe43Sopenharmony_ci* @since 1.0
10321bd4fe43Sopenharmony_ci* @version 1.0
10331bd4fe43Sopenharmony_ci*/
10341bd4fe43Sopenharmony_ciosStatus_t osMutexDelete (osMutexId_t mutex_id);
10351bd4fe43Sopenharmony_ci
10361bd4fe43Sopenharmony_ci
10371bd4fe43Sopenharmony_ci//  ==== Semaphore Management Functions ====
10381bd4fe43Sopenharmony_ci
10391bd4fe43Sopenharmony_ci/**
10401bd4fe43Sopenharmony_ci* @brief Creates and initializes a semaphore object.
10411bd4fe43Sopenharmony_ci*
10421bd4fe43Sopenharmony_ci* @param max_count Indicates the maximum number of available tokens that can be applied for.
10431bd4fe43Sopenharmony_ci* @param initial_count Indicates the initial number of available tokens.
10441bd4fe43Sopenharmony_ci* @param attr Indicates the pointer to the semaphore attributes. This parameter is not used.
10451bd4fe43Sopenharmony_ci* @return Returns the semaphore ID; returns NULL in the case of an error.
10461bd4fe43Sopenharmony_ci* @since 1.0
10471bd4fe43Sopenharmony_ci* @version 1.0
10481bd4fe43Sopenharmony_ci*/
10491bd4fe43Sopenharmony_ciosSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr);
10501bd4fe43Sopenharmony_ci
10511bd4fe43Sopenharmony_ciconst char *osSemaphoreGetName (osSemaphoreId_t semaphore_id);
10521bd4fe43Sopenharmony_ci
10531bd4fe43Sopenharmony_ci/**
10541bd4fe43Sopenharmony_ci* @brief Acquires a token of a semaphore object.
10551bd4fe43Sopenharmony_ci*
10561bd4fe43Sopenharmony_ci* @param semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.
10571bd4fe43Sopenharmony_ci* @param timeout Indicates the timeout duration. This parameter is the number of ticks.
10581bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
10591bd4fe43Sopenharmony_ci* @since 1.0
10601bd4fe43Sopenharmony_ci* @version 1.0
10611bd4fe43Sopenharmony_ci*/
10621bd4fe43Sopenharmony_ciosStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout);
10631bd4fe43Sopenharmony_ci
10641bd4fe43Sopenharmony_ci/**
10651bd4fe43Sopenharmony_ci* @brief Releases a token of a semaphore object.
10661bd4fe43Sopenharmony_ci*
10671bd4fe43Sopenharmony_ci* @param semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.
10681bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
10691bd4fe43Sopenharmony_ci* @since 1.0
10701bd4fe43Sopenharmony_ci* @version 1.0
10711bd4fe43Sopenharmony_ci*/
10721bd4fe43Sopenharmony_ciosStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id);
10731bd4fe43Sopenharmony_ci
10741bd4fe43Sopenharmony_ci/**
10751bd4fe43Sopenharmony_ci* @brief Obtains the number of available tokens of a semaphore object.
10761bd4fe43Sopenharmony_ci*
10771bd4fe43Sopenharmony_ci* @param semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.
10781bd4fe43Sopenharmony_ci* @return Returns the number of available tokens.
10791bd4fe43Sopenharmony_ci* @since 1.0
10801bd4fe43Sopenharmony_ci* @version 1.0
10811bd4fe43Sopenharmony_ci*/
10821bd4fe43Sopenharmony_ciuint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id);
10831bd4fe43Sopenharmony_ci
10841bd4fe43Sopenharmony_ci/**
10851bd4fe43Sopenharmony_ci* @brief Deletes a semaphore object.
10861bd4fe43Sopenharmony_ci*
10871bd4fe43Sopenharmony_ci* @param semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.
10881bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
10891bd4fe43Sopenharmony_ci* @since 1.0
10901bd4fe43Sopenharmony_ci* @version 1.0
10911bd4fe43Sopenharmony_ci*/
10921bd4fe43Sopenharmony_ciosStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id);
10931bd4fe43Sopenharmony_ci
10941bd4fe43Sopenharmony_ci
10951bd4fe43Sopenharmony_ci//  ==== Memory Pool Management Functions ====
10961bd4fe43Sopenharmony_ci
10971bd4fe43Sopenharmony_ciosMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr);
10981bd4fe43Sopenharmony_ci
10991bd4fe43Sopenharmony_ciconst char *osMemoryPoolGetName (osMemoryPoolId_t mp_id);
11001bd4fe43Sopenharmony_ci
11011bd4fe43Sopenharmony_civoid *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout);
11021bd4fe43Sopenharmony_ci
11031bd4fe43Sopenharmony_ciosStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block);
11041bd4fe43Sopenharmony_ci
11051bd4fe43Sopenharmony_ciuint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id);
11061bd4fe43Sopenharmony_ci
11071bd4fe43Sopenharmony_ciuint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id);
11081bd4fe43Sopenharmony_ci
11091bd4fe43Sopenharmony_ciuint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id);
11101bd4fe43Sopenharmony_ci
11111bd4fe43Sopenharmony_ciuint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id);
11121bd4fe43Sopenharmony_ci
11131bd4fe43Sopenharmony_ciosStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id);
11141bd4fe43Sopenharmony_ci
11151bd4fe43Sopenharmony_ci
11161bd4fe43Sopenharmony_ci//  ==== Message Queue Management Functions ====
11171bd4fe43Sopenharmony_ci
11181bd4fe43Sopenharmony_ci/**
11191bd4fe43Sopenharmony_ci* @brief Creates and initializes a message queue.
11201bd4fe43Sopenharmony_ci*
11211bd4fe43Sopenharmony_ci* @param msg_count Indicates the number of messages in the message queue.
11221bd4fe43Sopenharmony_ci* @param msg_size Indicates the size of messages in the message queue.
11231bd4fe43Sopenharmony_ci* @param attr Indicates the pointer to the message queue attributes. This parameter is not used.
11241bd4fe43Sopenharmony_ci* @return Returns the message queue ID; returns NULL in the case of an error.
11251bd4fe43Sopenharmony_ci* @since 1.0
11261bd4fe43Sopenharmony_ci* @version 1.0
11271bd4fe43Sopenharmony_ci*/
11281bd4fe43Sopenharmony_ciosMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr);
11291bd4fe43Sopenharmony_ci
11301bd4fe43Sopenharmony_ciconst char *osMessageQueueGetName (osMessageQueueId_t mq_id);
11311bd4fe43Sopenharmony_ci
11321bd4fe43Sopenharmony_ci/**
11331bd4fe43Sopenharmony_ci* @brief Places a message in a message queue.
11341bd4fe43Sopenharmony_ci*
11351bd4fe43Sopenharmony_ci* @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew.
11361bd4fe43Sopenharmony_ci* @param msg_ptr Indicates the pointer to the buffer for storing the message to be placed in the message queue.
11371bd4fe43Sopenharmony_ci* @param msg_prio Indicates the priority of the message to be placed in the message queue. This parameter is not used.
11381bd4fe43Sopenharmony_ci* @param timeout Indicates the timeout duration.
11391bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
11401bd4fe43Sopenharmony_ci* @since 1.0
11411bd4fe43Sopenharmony_ci* @version 1.0
11421bd4fe43Sopenharmony_ci*/
11431bd4fe43Sopenharmony_ciosStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout);
11441bd4fe43Sopenharmony_ci
11451bd4fe43Sopenharmony_ci/**
11461bd4fe43Sopenharmony_ci* @brief Obtains a message in a message queue.
11471bd4fe43Sopenharmony_ci*
11481bd4fe43Sopenharmony_ci* @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew.
11491bd4fe43Sopenharmony_ci* @param msg_ptr Indicates the pointer to the buffer for storing the message to be retrieved from the message queue.
11501bd4fe43Sopenharmony_ci* @param msg_prio Indicates the pointer to the buffer for storing the priority of the message to be retrieved from the message queue. This parameter is not used.
11511bd4fe43Sopenharmony_ci* @param timeout Indicates the timeout duration.
11521bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
11531bd4fe43Sopenharmony_ci* @since 1.0
11541bd4fe43Sopenharmony_ci* @version 1.0
11551bd4fe43Sopenharmony_ci*/
11561bd4fe43Sopenharmony_ciosStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout);
11571bd4fe43Sopenharmony_ci
11581bd4fe43Sopenharmony_ci/**
11591bd4fe43Sopenharmony_ci* @brief Obtains the maximum number of messages that can be placed in a message queue.
11601bd4fe43Sopenharmony_ci*
11611bd4fe43Sopenharmony_ci* @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew.
11621bd4fe43Sopenharmony_ci* @return Returns the maximum number.
11631bd4fe43Sopenharmony_ci* @since 1.0
11641bd4fe43Sopenharmony_ci* @version 1.0
11651bd4fe43Sopenharmony_ci*/
11661bd4fe43Sopenharmony_ciuint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id);
11671bd4fe43Sopenharmony_ci
11681bd4fe43Sopenharmony_ci/**
11691bd4fe43Sopenharmony_ci* @brief Obtains the maximum size of messages that can be placed in a message queue.
11701bd4fe43Sopenharmony_ci*
11711bd4fe43Sopenharmony_ci* @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew.
11721bd4fe43Sopenharmony_ci* @return Returns the maximum message size.
11731bd4fe43Sopenharmony_ci* @since 1.0
11741bd4fe43Sopenharmony_ci* @version 1.0
11751bd4fe43Sopenharmony_ci*/
11761bd4fe43Sopenharmony_ciuint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id);
11771bd4fe43Sopenharmony_ci
11781bd4fe43Sopenharmony_ci/**
11791bd4fe43Sopenharmony_ci* @brief Obtains the number of queued messages in a message queue.
11801bd4fe43Sopenharmony_ci*
11811bd4fe43Sopenharmony_ci* @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew.
11821bd4fe43Sopenharmony_ci* @return Returns the number of queued messages.
11831bd4fe43Sopenharmony_ci* @since 1.0
11841bd4fe43Sopenharmony_ci* @version 1.0
11851bd4fe43Sopenharmony_ci*/
11861bd4fe43Sopenharmony_ciuint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id);
11871bd4fe43Sopenharmony_ci
11881bd4fe43Sopenharmony_ci/**
11891bd4fe43Sopenharmony_ci* @brief Obtains the number of available slots for messages in a message queue.
11901bd4fe43Sopenharmony_ci*
11911bd4fe43Sopenharmony_ci* @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew.
11921bd4fe43Sopenharmony_ci* @return Returns the number of available slots for messages.
11931bd4fe43Sopenharmony_ci* @since 1.0
11941bd4fe43Sopenharmony_ci* @version 1.0
11951bd4fe43Sopenharmony_ci*/
11961bd4fe43Sopenharmony_ciuint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id);
11971bd4fe43Sopenharmony_ci
11981bd4fe43Sopenharmony_ciosStatus_t osMessageQueueReset (osMessageQueueId_t mq_id);
11991bd4fe43Sopenharmony_ci
12001bd4fe43Sopenharmony_ci/**
12011bd4fe43Sopenharmony_ci* @brief Deletes a message queue.
12021bd4fe43Sopenharmony_ci*
12031bd4fe43Sopenharmony_ci* @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew.
12041bd4fe43Sopenharmony_ci* @return Returns the CMSIS-RTOS running result.
12051bd4fe43Sopenharmony_ci* @since 1.0
12061bd4fe43Sopenharmony_ci* @version 1.0
12071bd4fe43Sopenharmony_ci*/
12081bd4fe43Sopenharmony_ciosStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id);
12091bd4fe43Sopenharmony_ci
12101bd4fe43Sopenharmony_ci
12111bd4fe43Sopenharmony_ci#ifdef  __cplusplus
12121bd4fe43Sopenharmony_ci}
12131bd4fe43Sopenharmony_ci#endif
12141bd4fe43Sopenharmony_ci
12151bd4fe43Sopenharmony_ci#endif  // CMSIS_OS2_H_
1216