From ebf0a6f11cd6ff9f735db8391a6351ffeeda4cc3 Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Mon, 4 May 2020 12:24:52 +0200 Subject: [PATCH] timeouts: Use the new timeout API Port the code to use the new timeout API. Signed-off-by: Carles Cufi --- simplelink/kernel/zephyr/dpl/ClockP_zephyr.c | 4 ++-- simplelink/kernel/zephyr/dpl/SemaphoreP_zephyr.c | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/simplelink/kernel/zephyr/dpl/ClockP_zephyr.c b/simplelink/kernel/zephyr/dpl/ClockP_zephyr.c index 70218cf..d8c8890 100644 --- a/simplelink/kernel/zephyr/dpl/ClockP_zephyr.c +++ b/simplelink/kernel/zephyr/dpl/ClockP_zephyr.c @@ -137,7 +137,7 @@ void ClockP_start(ClockP_Handle handle) period = obj->period * 1000 / CONFIG_SYS_CLOCK_TICKS_PER_SEC; } - k_timer_start(&obj->timer, timeout, period); + k_timer_start(&obj->timer, K_MSEC(timeout), K_MSEC(period)); obj->active = true; } @@ -158,7 +158,7 @@ void ClockP_stop(ClockP_Handle handle) */ void ClockP_usleep(uint32_t usec) { - k_sleep((s32_t)usec); + k_sleep(K_USEC(usec)); } /* diff --git a/simplelink/kernel/zephyr/dpl/SemaphoreP_zephyr.c b/simplelink/kernel/zephyr/dpl/SemaphoreP_zephyr.c index 39e472e..020066e 100644 --- a/simplelink/kernel/zephyr/dpl/SemaphoreP_zephyr.c +++ b/simplelink/kernel/zephyr/dpl/SemaphoreP_zephyr.c @@ -48,21 +48,16 @@ static SemaphoreP_Status dpl_sem_pool_free(struct k_sem *sem) } /* timeout comes in and out as milliSeconds: */ -static int32_t dpl_convert_timeout(uint32_t timeout) +static k_timeout_t dpl_convert_timeout(uint32_t timeout) { - int32_t zephyr_timeout; - switch(timeout) { case SemaphoreP_NO_WAIT: - zephyr_timeout = K_NO_WAIT; - break; + return K_NO_WAIT; case SemaphoreP_WAIT_FOREVER: - zephyr_timeout = K_FOREVER; - break; + return K_FOREVER; default: - zephyr_timeout = timeout; + return K_MSEC(timeout); } - return zephyr_timeout; }