From 7fdfe03ad057213fccc8003ec1e8e070278a0480 Mon Sep 17 00:00:00 2001 From: Rajavardhan Gundi Date: Fri, 28 Sep 2018 09:56:22 +0530 Subject: [PATCH] lib/cmsis_rtos_v1: Fix some Kconfig inconsistencies Fixed some Kconfig inconsistencies around THREAD_CUSTOM_DATA, POLL and NUM_PREEMPT_PRIORITIES. Signed-off-by: Rajavardhan Gundi --- lib/cmsis_rtos_v1/Kconfig | 22 ++-------------------- lib/cmsis_rtos_v1/cmsis_thread.c | 11 +++++++++++ tests/cmsis_rtos_v1/prj.conf | 2 ++ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/lib/cmsis_rtos_v1/Kconfig b/lib/cmsis_rtos_v1/Kconfig index 8142faca590..269c53596f7 100644 --- a/lib/cmsis_rtos_v1/Kconfig +++ b/lib/cmsis_rtos_v1/Kconfig @@ -6,28 +6,14 @@ config CMSIS_RTOS_V1 bool "CMSIS RTOS v1 API" default n + depends on THREAD_CUSTOM_DATA + depends on POLL help This enables CMSIS RTOS v1 API support. This is an OS-integration layer which allows applications using CMSIS RTOS APIs to build on Zephyr. if CMSIS_RTOS_V1 -config THREAD_CUSTOM_DATA - bool "Thread custom data" - default y - help - This option allows each thread to store 32 bits of custom data, - which can be accessed using the k_thread_custom_data_xxx() APIs. - -config POLL - bool "Async I/O Framework" - default y - help - Asynchronous notification framework. Enable the k_poll() and - k_poll_signal() APIs. The former can wait on multiple events - concurrently, which can be either directly triggered or triggered by - the availability of some kernel objects (semaphores and fifos). - config CMSIS_MAX_THREAD_COUNT int "Maximum thread count in CMSIS RTOS application" default 10 @@ -63,8 +49,4 @@ config CMSIS_SEMAPHORE_MAX_COUNT range 0 255 help Mention maximum number of semaphores in CMSIS compliant application. - -config NUM_PREEMPT_PRIORITIES - int - default 7 endif diff --git a/lib/cmsis_rtos_v1/cmsis_thread.c b/lib/cmsis_rtos_v1/cmsis_thread.c index ab3dd7dc3c0..743b331615e 100644 --- a/lib/cmsis_rtos_v1/cmsis_thread.c +++ b/lib/cmsis_rtos_v1/cmsis_thread.c @@ -8,6 +8,8 @@ #include #include +#define TOTAL_CMSIS_THREAD_PRIORITIES (osPriorityRealtime - osPriorityIdle + 1) + static inline int _is_thread_cmsis_inactive(struct k_thread *thread) { u8_t state = thread->base.thread_state; @@ -49,6 +51,11 @@ osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *arg) return NULL; } + BUILD_ASSERT_MSG( + CONFIG_NUM_PREEMPT_PRIORITIES >= TOTAL_CMSIS_THREAD_PRIORITIES, + "Configure NUM_PREEMPT_PRIORITIES to at least" + " TOTAL_CMSIS_THREAD_PRIORITIES"); + __ASSERT(thread_def->stacksize <= CONFIG_CMSIS_THREAD_MAX_STACK_SIZE, "invalid stack size\n"); @@ -56,6 +63,10 @@ osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *arg) return NULL; } + __ASSERT((thread_def->tpriority >= osPriorityIdle) && + (thread_def->tpriority <= osPriorityRealtime), + "invalid priority\n"); + stacksz = thread_def->stacksize; if (stacksz == 0) { stacksz = CONFIG_CMSIS_THREAD_MAX_STACK_SIZE; diff --git a/tests/cmsis_rtos_v1/prj.conf b/tests/cmsis_rtos_v1/prj.conf index 743847572c5..4294494c0cb 100644 --- a/tests/cmsis_rtos_v1/prj.conf +++ b/tests/cmsis_rtos_v1/prj.conf @@ -1,3 +1,5 @@ CONFIG_ZTEST=y +CONFIG_THREAD_CUSTOM_DATA=y +CONFIG_POLL=y CONFIG_CMSIS_RTOS_V1=y CONFIG_IRQ_OFFLOAD=y