Ok

Dependencies:   mbed_rtos_types Mutex mbed_rtos_storage mbed Semaphore

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_rtos_types.h Source File

mbed_rtos_types.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2019, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef RTOS_TYPES_H_
00018 #define RTOS_TYPES_H_
00019 
00020 #if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
00021 #include "cmsis_os2.h"
00022 #else
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Minimal definitions for bare metal form of RTOS */
00029 
00030 // Timeout value.
00031 #define osWaitForever         0xFFFFFFFFU ///< Wait forever timeout value.
00032 
00033 // Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait).
00034 #define osFlagsWaitAny        0x00000000U ///< Wait for any flag (default).
00035 #define osFlagsWaitAll        0x00000001U ///< Wait for all flags.
00036 #define osFlagsNoClear        0x00000002U ///< Do not clear flags which have been specified to wait for.
00037 
00038 // Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx).
00039 #define osFlagsError          0x80000000U ///< Error indicator.
00040 #define osFlagsErrorUnknown   0xFFFFFFFFU ///< osError (-1).
00041 #define osFlagsErrorTimeout   0xFFFFFFFEU ///< osErrorTimeout (-2).
00042 #define osFlagsErrorResource  0xFFFFFFFDU ///< osErrorResource (-3).
00043 #define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4).
00044 #define osFlagsErrorISR       0xFFFFFFFAU ///< osErrorISR (-6).
00045 
00046 // Status code values returned by CMSIS-RTOS functions.
00047 typedef enum {
00048     osOK                    =  0,         ///< Operation completed successfully.
00049     osError                 = -1,         ///< Unspecified RTOS error: run-time error but no other error message fits.
00050     osErrorTimeout          = -2,         ///< Operation not completed within the timeout period.
00051     osErrorResource         = -3,         ///< Resource not available.
00052     osErrorParameter        = -4,         ///< Parameter error.
00053     osErrorNoMemory         = -5,         ///< System is out of memory: it was impossible to allocate or reserve memory for the operation.
00054     osErrorISR              = -6,         ///< Not allowed in ISR context: the function cannot be called from interrupt service routines.
00055     osStatusReserved        = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.
00056 } osStatus_t;
00057 
00058 
00059 // \details Thread ID identifies the thread.
00060 typedef void *osThreadId_t;
00061 
00062 // Set the specified Thread Flags of a thread.
00063 // \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
00064 // \param[in]     flags         specifies the flags of the thread that shall be set.
00065 // \return thread flags after setting or error code if highest bit set.
00066 uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags);
00067 
00068 #ifdef __cplusplus
00069 }
00070 #endif
00071 
00072 #endif
00073 
00074 
00075 
00076 #endif /* RTOS_TYPES_H_ */
00077