mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
utilities: fix new Zephyr k_timer based implementation
- Fixed the Zephyr kernel version checks to check for 0.1.6 rather than 1.6.0. - fixed the k_timer implementation to actually work. None of these were being called correctly. - due to the fact that the k_timer API only has a 1ms resolution, re-implement upm_delay_us() (on 0.1.6 version of zephyr) as a busy loop using a upm_clock_t. Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
parent
6667646d32
commit
024b43dfa3
@ -30,12 +30,16 @@ void upm_delay(int time){
|
|||||||
#if defined(UPM_PLATFORM_LINUX)
|
#if defined(UPM_PLATFORM_LINUX)
|
||||||
sleep(time);
|
sleep(time);
|
||||||
#elif defined(UPM_PLATFORM_ZEPHYR)
|
#elif defined(UPM_PLATFORM_ZEPHYR)
|
||||||
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 1 && \
|
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 0 && \
|
||||||
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) >= 6
|
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) == 1 && \
|
||||||
|
SYS_KERNEL_VER_PATCHLEVEL(KERNEL_VERSION_NUMBER) >= 6
|
||||||
|
|
||||||
|
if (time <= 0)
|
||||||
|
time = 1;
|
||||||
|
|
||||||
struct k_timer timer;
|
struct k_timer timer;
|
||||||
k_timer_init(&timer, NULL, NULL);
|
k_timer_init(&timer, NULL, NULL);
|
||||||
k_timer_start(&timer, SECONDS(time) + 1, 0);
|
k_timer_start(&timer, time * 1000, 0);
|
||||||
k_timer_status_sync(&timer);
|
k_timer_status_sync(&timer);
|
||||||
|
|
||||||
# else
|
# else
|
||||||
@ -55,12 +59,16 @@ void upm_delay_ms(int time){
|
|||||||
#if defined(UPM_PLATFORM_LINUX)
|
#if defined(UPM_PLATFORM_LINUX)
|
||||||
usleep(1000 * time);
|
usleep(1000 * time);
|
||||||
#elif defined(UPM_PLATFORM_ZEPHYR)
|
#elif defined(UPM_PLATFORM_ZEPHYR)
|
||||||
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 1 && \
|
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 0 && \
|
||||||
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) >= 6
|
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) == 1 && \
|
||||||
|
SYS_KERNEL_VER_PATCHLEVEL(KERNEL_VERSION_NUMBER) >= 6
|
||||||
|
|
||||||
|
if (time <= 0)
|
||||||
|
time = 1;
|
||||||
|
|
||||||
struct k_timer timer;
|
struct k_timer timer;
|
||||||
k_timer_init(&timer, NULL, NULL);
|
k_timer_init(&timer, NULL, NULL);
|
||||||
k_timer_start(&timer, MSEC(time) + 1, 0);
|
k_timer_start(&timer, time, 0);
|
||||||
k_timer_status_sync(&timer);
|
k_timer_status_sync(&timer);
|
||||||
|
|
||||||
# else
|
# else
|
||||||
@ -79,13 +87,20 @@ void upm_delay_us(int time){
|
|||||||
#if defined(UPM_PLATFORM_LINUX)
|
#if defined(UPM_PLATFORM_LINUX)
|
||||||
usleep(time);
|
usleep(time);
|
||||||
#elif defined(UPM_PLATFORM_ZEPHYR)
|
#elif defined(UPM_PLATFORM_ZEPHYR)
|
||||||
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 1 && \
|
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 0 && \
|
||||||
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) >= 6
|
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) == 1 && \
|
||||||
|
SYS_KERNEL_VER_PATCHLEVEL(KERNEL_VERSION_NUMBER) >= 6
|
||||||
|
|
||||||
struct k_timer timer;
|
// we will use a upm_clock to do microsecond timings here as k_timer has
|
||||||
k_timer_init(&timer, NULL, NULL);
|
// only a millisecond resolution. So we init a clock and spin.
|
||||||
k_timer_start(&timer, USEC(time) + 1, 0);
|
|
||||||
k_timer_status_sync(&timer);
|
if (time <= 0)
|
||||||
|
time = 1;
|
||||||
|
|
||||||
|
upm_clock_t timer;
|
||||||
|
upm_clock_init(&timer);
|
||||||
|
while (upm_elapsed_us(&timer) < time)
|
||||||
|
; // spin
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user