subsys/cmsis_v1: Port to new timeout API
No complexity here. The CMSIS API was always in milliseconds, needs nothing but a few wrapper macros for kernel timeout arguments. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
88c0545ea4
commit
1003ab806c
9 changed files with 16 additions and 13 deletions
|
@ -5,7 +5,6 @@ config CMSIS_RTOS_V1
|
|||
bool "CMSIS RTOS v1 API"
|
||||
depends on THREAD_CUSTOM_DATA
|
||||
depends on POLL
|
||||
select LEGACY_TIMEOUT_API
|
||||
help
|
||||
This enables CMSIS RTOS v1 API support. This is an OS-integration
|
||||
layer which allows applications using CMSIS RTOS APIs to build on
|
||||
|
|
|
@ -49,7 +49,7 @@ void *osMailAlloc(osMailQId queue_id, uint32_t millisec)
|
|||
} else {
|
||||
retval = k_mem_slab_alloc(
|
||||
(struct k_mem_slab *)(queue_def->pool),
|
||||
(void **)&ptr, millisec);
|
||||
(void **)&ptr, K_MSEC(millisec));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
@ -83,7 +83,7 @@ void *osMailCAlloc(osMailQId queue_id, uint32_t millisec)
|
|||
} else {
|
||||
retval = k_mem_slab_alloc(
|
||||
(struct k_mem_slab *)(queue_def->pool),
|
||||
(void **)&ptr, millisec);
|
||||
(void **)&ptr, K_MSEC(millisec));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
@ -143,7 +143,8 @@ osEvent osMailGet(osMailQId queue_id, uint32_t millisec)
|
|||
} else if (millisec == osWaitForever) {
|
||||
retval = k_mbox_get(queue_def->mbox, &mmsg, NULL, K_FOREVER);
|
||||
} else {
|
||||
retval = k_mbox_get(queue_def->mbox, &mmsg, NULL, millisec);
|
||||
retval = k_mbox_get(queue_def->mbox, &mmsg, NULL,
|
||||
K_MSEC(millisec));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <cmsis_os.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TIME_OUT 100
|
||||
#define TIME_OUT K_MSEC(100)
|
||||
|
||||
/**
|
||||
* @brief Create and Initialize a memory pool.
|
||||
|
|
|
@ -43,7 +43,8 @@ osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
|
|||
} else if (millisec == osWaitForever) {
|
||||
retval = k_msgq_put(queue_def->msgq, (void *)&info, K_FOREVER);
|
||||
} else {
|
||||
retval = k_msgq_put(queue_def->msgq, (void *)&info, millisec);
|
||||
retval = k_msgq_put(queue_def->msgq, (void *)&info,
|
||||
K_MSEC(millisec));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
@ -75,7 +76,7 @@ osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
|
|||
} else if (millisec == osWaitForever) {
|
||||
retval = k_msgq_get(queue_def->msgq, &info, K_FOREVER);
|
||||
} else {
|
||||
retval = k_msgq_get(queue_def->msgq, &info, millisec);
|
||||
retval = k_msgq_get(queue_def->msgq, &info, K_MSEC(millisec));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
|
|
@ -58,7 +58,7 @@ osStatus osMutexWait(osMutexId mutex_id, uint32_t timeout)
|
|||
} else if (timeout == 0U) {
|
||||
status = k_mutex_lock(mutex, K_NO_WAIT);
|
||||
} else {
|
||||
status = k_mutex_lock(mutex, timeout);
|
||||
status = k_mutex_lock(mutex, K_MSEC(timeout));
|
||||
}
|
||||
|
||||
if (status == -EBUSY) {
|
||||
|
|
|
@ -60,7 +60,7 @@ int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t timeout)
|
|||
} else if (timeout == 0U) {
|
||||
status = k_sem_take(semaphore, K_NO_WAIT);
|
||||
} else {
|
||||
status = k_sem_take(semaphore, timeout);
|
||||
status = k_sem_take(semaphore, K_MSEC(timeout));
|
||||
}
|
||||
|
||||
/* If k_sem_take is successful, return the number of available
|
||||
|
|
|
@ -101,7 +101,8 @@ osEvent osSignalWait(int32_t signals, uint32_t millisec)
|
|||
retval = k_poll(thread_def->poll_event, 1, K_FOREVER);
|
||||
break;
|
||||
default:
|
||||
retval = k_poll(thread_def->poll_event, 1, timeout);
|
||||
retval = k_poll(thread_def->poll_event, 1,
|
||||
K_MSEC(timeout));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,9 +80,10 @@ osStatus osTimerStart(osTimerId timer_id, uint32_t millisec)
|
|||
}
|
||||
|
||||
if (timer->type == osTimerOnce) {
|
||||
k_timer_start(&timer->ztimer, millisec, K_NO_WAIT);
|
||||
k_timer_start(&timer->ztimer, K_MSEC(millisec), K_NO_WAIT);
|
||||
} else if (timer->type == osTimerPeriodic) {
|
||||
k_timer_start(&timer->ztimer, millisec, millisec);
|
||||
k_timer_start(&timer->ztimer, K_MSEC(millisec),
|
||||
K_MSEC(millisec));
|
||||
}
|
||||
|
||||
timer->status = ACTIVE;
|
||||
|
|
|
@ -16,6 +16,6 @@ osStatus osDelay(uint32_t delay_ms)
|
|||
return osErrorISR;
|
||||
}
|
||||
|
||||
k_sleep(delay_ms);
|
||||
k_msleep(delay_ms);
|
||||
return osEventTimeout;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue