diff --git a/include/cmsis_rtos_v1/cmsis_os.h b/include/cmsis_rtos_v1/cmsis_os.h index 9da629dc10a..8222b89365d 100644 --- a/include/cmsis_rtos_v1/cmsis_os.h +++ b/include/cmsis_rtos_v1/cmsis_os.h @@ -61,7 +61,7 @@ #define osFeature_MessageQ 1 ///< Message Queues: 1=available, 0=not available #define osFeature_Signals 8 ///< maximum number of Signal Flags available per thread #define osFeature_Semaphore 30 ///< maximum count for \ref osSemaphoreCreate function -#define osFeature_Wait 1 ///< osWait function: 1=available, 0=not available +#define osFeature_Wait 0 ///< osWait function: 1=available, 0=not available #define osFeature_SysTick 1 ///< osKernelSysTick functions: 1=available, 0=not available #include diff --git a/lib/cmsis_rtos_v1/cmsis_signal.c b/lib/cmsis_rtos_v1/cmsis_signal.c index 2f6fbecc67a..21a5ea5abac 100644 --- a/lib/cmsis_rtos_v1/cmsis_signal.c +++ b/lib/cmsis_rtos_v1/cmsis_signal.c @@ -20,15 +20,16 @@ void *k_thread_other_custom_data_get(struct k_thread *thread_id) int32_t osSignalSet(osThreadId thread_id, int32_t signals) { int sig, key; - osThreadDef_t *thread_def = - (osThreadDef_t *)k_thread_other_custom_data_get( - (struct k_thread *)thread_id); - if (_is_in_isr() || (thread_id == NULL) || + if ((thread_id == NULL) || (!signals) || (signals >= (1 << (osFeature_Signals + 1)))) { return 0x80000000; } + osThreadDef_t *thread_def = + (osThreadDef_t *)k_thread_other_custom_data_get( + (struct k_thread *)thread_id); + key = irq_lock(); sig = thread_def->signal_results; thread_def->signal_results |= signals; @@ -45,15 +46,16 @@ int32_t osSignalSet(osThreadId thread_id, int32_t signals) int32_t osSignalClear(osThreadId thread_id, int32_t signals) { int sig, key; - osThreadDef_t *thread_def = - (osThreadDef_t *)k_thread_other_custom_data_get( - (struct k_thread *)thread_id); - if (_is_in_isr() || (thread_id == NULL) || + if (_is_in_isr() || (thread_id == NULL) || (!signals) || (signals >= (1 << (osFeature_Signals + 1)))) { return 0x80000000; } + osThreadDef_t *thread_def = + (osThreadDef_t *)k_thread_other_custom_data_get( + (struct k_thread *)thread_id); + key = irq_lock(); sig = thread_def->signal_results; thread_def->signal_results &= ~(signals); diff --git a/lib/cmsis_rtos_v1/cmsis_thread.c b/lib/cmsis_rtos_v1/cmsis_thread.c index 34034872c6d..df24c3c05e7 100644 --- a/lib/cmsis_rtos_v1/cmsis_thread.c +++ b/lib/cmsis_rtos_v1/cmsis_thread.c @@ -48,7 +48,7 @@ osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *arg) __ASSERT(thread_def->stacksize <= CONFIG_CMSIS_THREAD_MAX_STACK_SIZE, "invalid stack size\n"); - if (thread_def->instances == 0) { + if ((thread_def == NULL) || (thread_def->instances == 0)) { return NULL; } @@ -100,7 +100,7 @@ osPriority osThreadGetPriority(osThreadId thread_id) k_tid_t thread = (k_tid_t)thread_id; u32_t priority; - if (_is_in_isr()) { + if ((thread_id == NULL) || (_is_in_isr())) { return osPriorityError; }