mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
utilities: use a better method for detecting zephyr kernel version
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
parent
024b43dfa3
commit
c6ad8cb5ee
@ -26,17 +26,18 @@
|
|||||||
#include <upm_platform.h>
|
#include <upm_platform.h>
|
||||||
#include <upm_utilities.h>
|
#include <upm_utilities.h>
|
||||||
|
|
||||||
void upm_delay(int time){
|
void upm_delay(int time)
|
||||||
#if defined(UPM_PLATFORM_LINUX)
|
{
|
||||||
sleep(time);
|
|
||||||
#elif defined(UPM_PLATFORM_ZEPHYR)
|
|
||||||
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 0 && \
|
|
||||||
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) == 1 && \
|
|
||||||
SYS_KERNEL_VER_PATCHLEVEL(KERNEL_VERSION_NUMBER) >= 6
|
|
||||||
|
|
||||||
if (time <= 0)
|
if (time <= 0)
|
||||||
time = 1;
|
time = 1;
|
||||||
|
|
||||||
|
#if defined(UPM_PLATFORM_LINUX)
|
||||||
|
|
||||||
|
sleep(time);
|
||||||
|
|
||||||
|
#elif defined(UPM_PLATFORM_ZEPHYR)
|
||||||
|
# if KERNEL_VERSION_MAJOR == 1 && KERNEL_VERSION_MINOR >= 6
|
||||||
|
|
||||||
struct k_timer timer;
|
struct k_timer timer;
|
||||||
k_timer_init(&timer, NULL, NULL);
|
k_timer_init(&timer, NULL, NULL);
|
||||||
k_timer_start(&timer, time * 1000, 0);
|
k_timer_start(&timer, time * 1000, 0);
|
||||||
@ -55,17 +56,18 @@ void upm_delay(int time){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void upm_delay_ms(int time){
|
void upm_delay_ms(int time)
|
||||||
#if defined(UPM_PLATFORM_LINUX)
|
{
|
||||||
usleep(1000 * time);
|
|
||||||
#elif defined(UPM_PLATFORM_ZEPHYR)
|
|
||||||
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 0 && \
|
|
||||||
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) == 1 && \
|
|
||||||
SYS_KERNEL_VER_PATCHLEVEL(KERNEL_VERSION_NUMBER) >= 6
|
|
||||||
|
|
||||||
if (time <= 0)
|
if (time <= 0)
|
||||||
time = 1;
|
time = 1;
|
||||||
|
|
||||||
|
#if defined(UPM_PLATFORM_LINUX)
|
||||||
|
|
||||||
|
usleep(1000 * time);
|
||||||
|
|
||||||
|
#elif defined(UPM_PLATFORM_ZEPHYR)
|
||||||
|
# if KERNEL_VERSION_MAJOR == 1 && KERNEL_VERSION_MINOR >= 6
|
||||||
|
|
||||||
struct k_timer timer;
|
struct k_timer timer;
|
||||||
k_timer_init(&timer, NULL, NULL);
|
k_timer_init(&timer, NULL, NULL);
|
||||||
k_timer_start(&timer, time, 0);
|
k_timer_start(&timer, time, 0);
|
||||||
@ -83,20 +85,20 @@ void upm_delay_ms(int time){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void upm_delay_us(int time){
|
void upm_delay_us(int time)
|
||||||
#if defined(UPM_PLATFORM_LINUX)
|
{
|
||||||
usleep(time);
|
|
||||||
#elif defined(UPM_PLATFORM_ZEPHYR)
|
|
||||||
# if SYS_KERNEL_VER_MAJOR(KERNEL_VERSION_NUMBER) == 0 && \
|
|
||||||
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) == 1 && \
|
|
||||||
SYS_KERNEL_VER_PATCHLEVEL(KERNEL_VERSION_NUMBER) >= 6
|
|
||||||
|
|
||||||
// we will use a upm_clock to do microsecond timings here as k_timer has
|
|
||||||
// only a millisecond resolution. So we init a clock and spin.
|
|
||||||
|
|
||||||
if (time <= 0)
|
if (time <= 0)
|
||||||
time = 1;
|
time = 1;
|
||||||
|
|
||||||
|
#if defined(UPM_PLATFORM_LINUX)
|
||||||
|
|
||||||
|
usleep(time);
|
||||||
|
|
||||||
|
#elif defined(UPM_PLATFORM_ZEPHYR)
|
||||||
|
# if KERNEL_VERSION_MAJOR == 1 && KERNEL_VERSION_MINOR >= 6
|
||||||
|
// we will use a upm_clock to do microsecond timings here as k_timer has
|
||||||
|
// only a millisecond resolution. So we init a clock and spin.
|
||||||
|
|
||||||
upm_clock_t timer;
|
upm_clock_t timer;
|
||||||
upm_clock_init(&timer);
|
upm_clock_init(&timer);
|
||||||
while (upm_elapsed_us(&timer) < time)
|
while (upm_elapsed_us(&timer) < time)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user