diff --git a/lib/cmsis_rtos_v2/Kconfig b/lib/cmsis_rtos_v2/Kconfig index cb54769085b..d79fb04e0b5 100644 --- a/lib/cmsis_rtos_v2/Kconfig +++ b/lib/cmsis_rtos_v2/Kconfig @@ -9,7 +9,6 @@ config CMSIS_RTOS_V2 depends on THREAD_MONITOR depends on INIT_STACKS depends on NUM_PREEMPT_PRIORITIES >= 56 - select LEGACY_TIMEOUT_API help This enables CMSIS RTOS v2 API support. This is an OS-integration layer which allows applications using CMSIS RTOS V2 APIs to build diff --git a/lib/cmsis_rtos_v2/event_flags.c b/lib/cmsis_rtos_v2/event_flags.c index 20b99c810f6..961a47af2bd 100644 --- a/lib/cmsis_rtos_v2/event_flags.c +++ b/lib/cmsis_rtos_v2/event_flags.c @@ -133,7 +133,8 @@ uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, retval = k_poll(&events->poll_event, 1, K_FOREVER); break; default: - retval = k_poll(&events->poll_event, 1, timeout_ms); + retval = k_poll(&events->poll_event, 1, + K_MSEC(timeout_ms)); break; } diff --git a/lib/cmsis_rtos_v2/kernel.c b/lib/cmsis_rtos_v2/kernel.c index e58bef5e7dd..2e05b9aa225 100644 --- a/lib/cmsis_rtos_v2/kernel.c +++ b/lib/cmsis_rtos_v2/kernel.c @@ -9,13 +9,6 @@ #include #include -/* Currently the timing implementations for timeouts and osDelay - * assume that the arguments are in Zephyr ticks, even though ARM - * documentation and at least some of our test code assume they are - * milliseconds. They must match for now. - */ -BUILD_ASSERT(CONFIG_SYS_CLOCK_TICKS_PER_SEC == 1000); - extern u32_t z_tick_get_32(void); /** @@ -132,7 +125,7 @@ osStatus_t osDelay(uint32_t ticks) return osErrorISR; } - k_sleep(k_ticks_to_ms_floor64(ticks)); + k_sleep(K_TICKS(ticks)); return osOK; } @@ -149,7 +142,7 @@ osStatus_t osDelayUntil(uint32_t ticks) } ticks_elapsed = osKernelGetTickCount(); - k_sleep(k_ticks_to_ms_floor64(ticks - ticks_elapsed)); + k_sleep(K_TICKS(ticks - ticks_elapsed)); return osOK; } diff --git a/lib/cmsis_rtos_v2/mempool.c b/lib/cmsis_rtos_v2/mempool.c index 01bddc391cc..d20cb73c4da 100644 --- a/lib/cmsis_rtos_v2/mempool.c +++ b/lib/cmsis_rtos_v2/mempool.c @@ -109,7 +109,7 @@ void *osMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout) } else { retval = k_mem_slab_alloc( (struct k_mem_slab *)(&mslab->z_mslab), - (void **)&ptr, k_ticks_to_ms_floor64(timeout)); + (void **)&ptr, K_TICKS(timeout)); } if (retval == 0) { diff --git a/lib/cmsis_rtos_v2/msgq.c b/lib/cmsis_rtos_v2/msgq.c index 8d7d62a402b..377a3d93872 100644 --- a/lib/cmsis_rtos_v2/msgq.c +++ b/lib/cmsis_rtos_v2/msgq.c @@ -104,7 +104,7 @@ osStatus_t osMessageQueuePut(osMessageQueueId_t msgq_id, const void *msg_ptr, retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr, K_FOREVER); } else { retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr, - k_ticks_to_ms_floor64(timeout)); + K_TICKS(timeout)); } if (retval == 0) { @@ -142,7 +142,7 @@ osStatus_t osMessageQueueGet(osMessageQueueId_t msgq_id, void *msg_ptr, retval = k_msgq_get(&msgq->z_msgq, msg_ptr, K_FOREVER); } else { retval = k_msgq_get(&msgq->z_msgq, msg_ptr, - k_ticks_to_ms_floor64(timeout)); + K_TICKS(timeout)); } if (retval == 0) { diff --git a/lib/cmsis_rtos_v2/mutex.c b/lib/cmsis_rtos_v2/mutex.c index 8127941f5dc..78f31f54ab3 100644 --- a/lib/cmsis_rtos_v2/mutex.c +++ b/lib/cmsis_rtos_v2/mutex.c @@ -94,7 +94,7 @@ osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) status = k_mutex_lock(&mutex->z_mutex, K_NO_WAIT); } else { status = k_mutex_lock(&mutex->z_mutex, - k_ticks_to_ms_floor64(timeout)); + K_TICKS(timeout)); } if (status == -EBUSY) { diff --git a/lib/cmsis_rtos_v2/semaphore.c b/lib/cmsis_rtos_v2/semaphore.c index d77dea51e77..fc04c20bda6 100644 --- a/lib/cmsis_rtos_v2/semaphore.c +++ b/lib/cmsis_rtos_v2/semaphore.c @@ -77,7 +77,7 @@ osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout) status = k_sem_take(&semaphore->z_semaphore, K_NO_WAIT); } else { status = k_sem_take(&semaphore->z_semaphore, - k_ticks_to_ms_floor64(timeout)); + K_TICKS(timeout)); } if (status == -EBUSY) { diff --git a/lib/cmsis_rtos_v2/thread_flags.c b/lib/cmsis_rtos_v2/thread_flags.c index ecb51caae40..564f9821a54 100644 --- a/lib/cmsis_rtos_v2/thread_flags.c +++ b/lib/cmsis_rtos_v2/thread_flags.c @@ -117,7 +117,8 @@ uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout) retval = k_poll(&tid->poll_event, 1, K_FOREVER); break; default: - retval = k_poll(&tid->poll_event, 1, timeout_ms); + retval = k_poll(&tid->poll_event, 1, + K_MSEC(timeout_ms)); break; } diff --git a/lib/cmsis_rtos_v2/timer.c b/lib/cmsis_rtos_v2/timer.c index af3b5c278aa..b74943f5c92 100644 --- a/lib/cmsis_rtos_v2/timer.c +++ b/lib/cmsis_rtos_v2/timer.c @@ -80,7 +80,6 @@ osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks) { struct cv2_timer *timer = (struct cv2_timer *)timer_id; - u32_t millisec = k_ticks_to_ms_floor64(ticks); if (timer == NULL) { return osErrorParameter; @@ -91,9 +90,10 @@ osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks) } if (timer->type == osTimerOnce) { - k_timer_start(&timer->z_timer, millisec, K_NO_WAIT); + k_timer_start(&timer->z_timer, K_TICKS(ticks), K_NO_WAIT); } else if (timer->type == osTimerPeriodic) { - k_timer_start(&timer->z_timer, millisec, millisec); + k_timer_start(&timer->z_timer, + K_TICKS(ticks), K_TICKS(ticks)); } timer->status = ACTIVE; diff --git a/tests/portability/cmsis_rtos_v2/prj.conf b/tests/portability/cmsis_rtos_v2/prj.conf index ab8d18fcfd6..ccdf0628a9d 100644 --- a/tests/portability/cmsis_rtos_v2/prj.conf +++ b/tests/portability/cmsis_rtos_v2/prj.conf @@ -13,6 +13,4 @@ CONFIG_SCHED_SCALABLE=y CONFIG_CMSIS_V2_MEM_SLAB_MAX_DYNAMIC_SIZE=128 CONFIG_CMSIS_V2_THREAD_MAX_COUNT=23 CONFIG_CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT=10 - -# The Zephyr CMSIS emulation assumes that ticks are ms, currently -CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000 +CONFIG_TIMEOUT_64BIT=n