Luca
Fork of mbed-rtos by
Diff: rtx/TARGET_CORTEX_M/cmsis_os.h
- Revision:
- 123:58563e6cba1e
- Parent:
- 120:4dc938e301cc
--- a/rtx/TARGET_CORTEX_M/cmsis_os.h Wed Nov 09 12:22:14 2016 -0600 +++ b/rtx/TARGET_CORTEX_M/cmsis_os.h Mon Nov 14 17:14:42 2016 -0600 @@ -1,3 +1,6 @@ + +/** \addtogroup rtos */ +/** @{*/ /* ---------------------------------------------------------------------- * $Date: 5. February 2013 * $Revision: V1.02 @@ -74,16 +77,22 @@ #ifdef __MBED_CMSIS_RTOS_CM -/* Single thread - disable timers and set task count to one */ -#if defined(MBED_RTOS_SINGLE_THREAD) -#define OS_TASKCNT 1 -#define OS_TIMERS 0 +/* If os timers macro is set to 0, there's no timer thread created, therefore + * main thread has tid 0x01 + */ +#if defined(OS_TIMERS) && (OS_TIMERS == 0) +#define MAIN_THREAD_ID 0x01 +#else +#define MAIN_THREAD_ID 0x02 +#endif #endif +#if defined(TARGET_XDOT_L151CC) +#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE/2) +#else +#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4) #endif -#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4) - #define osCMSIS 0x10002U ///< CMSIS-RTOS API version (main [31:16] .sub [15:0]) #define osCMSIS_RTX ((4<<16)|80) ///< RTOS identification and version (main [31:16] .sub [15:0]) @@ -99,6 +108,7 @@ #define osFeature_Semaphore 65535 ///< Maximum count for \ref osSemaphoreCreate function #define osFeature_Wait 0 ///< osWait not available #define osFeature_SysTick 1 ///< osKernelSysTick functions available +#define osFeature_ThreadEnum 1 ///< Thread enumeration available #if defined (__CC_ARM) #define os_InRegs __value_in_regs // Compiler specific: force struct in registers @@ -159,6 +169,16 @@ osTimerPeriodic = 1 ///< repeating timer } os_timer_type; +typedef enum { + osThreadInfoState, + osThreadInfoStackSize, + osThreadInfoStackMax, + osThreadInfoEntry, + osThreadInfoArg, + + osThreadInfo_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization. +} osThreadInfo; + /// Entry point of a thread. typedef void (*os_pthread) (void const *argument); @@ -188,6 +208,8 @@ /// Mail ID identifies the mail queue (pointer to a mail queue control block). typedef struct os_mailQ_cb *osMailQId; +/// Thread enumeration ID identifies the enumeration (pointer to a thread enumeration control block). +typedef uint32_t *osThreadEnumId; /// Thread Definition structure contains startup information of a thread. typedef struct os_thread_def { @@ -358,6 +380,13 @@ uint8_t osThreadGetState (osThreadId thread_id); #endif +/// Get into from an active thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. +/// \param[in] info information to read. +/// \return current state of the thread function. +/// \return requested info that includes the status code. +os_InRegs osEvent _osThreadGetInfo(osThreadId thread_id, osThreadInfo info); + // ==== Generic Wait Functions ==== /// Wait for Timeout (Time Delay). @@ -680,6 +709,26 @@ #endif // Mail Queues available +// ==== Thread Enumeration Functions ==== + +#if (defined (osFeature_ThreadEnum) && (osFeature_ThreadEnum != 0)) // Thread enumeration available + +/// Start a thread enumeration. +/// \return an enumeration ID or NULL on error. +osThreadEnumId _osThreadsEnumStart(void); + +/// Get the next task ID in the enumeration. +/// \return a thread ID or NULL on if the end of the enumeration has been reached. +osThreadId _osThreadEnumNext(osThreadEnumId enum_id); + +/// Free the enumeration structure. +/// \param[in] enum_id pointer to the enumeration ID that was obtained with \ref _osThreadsEnumStart. +/// \return status code that indicates the execution status of the function. +osStatus _osThreadEnumFree(osThreadEnumId enum_id); + +#endif // Thread Enumeration available + + // ==== RTX Extensions ==== /// Suspend the RTX task scheduler. @@ -696,3 +745,5 @@ #endif #endif // _CMSIS_OS_H + +/** @}*/