mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
utilities: add Zephyr 1.6 k_timer support (pulled from zupm)
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
parent
232089f400
commit
c4656bf8ba
@ -30,11 +30,24 @@ 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 && \
|
||||||
|
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) >= 6
|
||||||
|
|
||||||
|
struct k_timer timer;
|
||||||
|
k_timer_init(&timer, NULL, NULL);
|
||||||
|
k_timer_start(&timer, SECONDS(time) + 1, 0);
|
||||||
|
k_timer_status_sync(&timer);
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
struct nano_timer timer;
|
struct nano_timer timer;
|
||||||
void *timer_data[1];
|
void *timer_data[1];
|
||||||
nano_timer_init(&timer, timer_data);
|
nano_timer_init(&timer, timer_data);
|
||||||
nano_timer_start(&timer, SECONDS(time) + 1);
|
nano_timer_start(&timer, SECONDS(time) + 1);
|
||||||
nano_timer_test(&timer, TICKS_UNLIMITED);
|
nano_timer_test(&timer, TICKS_UNLIMITED);
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,11 +55,23 @@ 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 && \
|
||||||
|
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) >= 6
|
||||||
|
|
||||||
|
struct k_timer timer;
|
||||||
|
k_timer_init(&timer, NULL, NULL);
|
||||||
|
k_timer_start(&timer, MSEC(time) + 1, 0);
|
||||||
|
k_timer_status_sync(&timer);
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
struct nano_timer timer;
|
struct nano_timer timer;
|
||||||
void *timer_data[1];
|
void *timer_data[1];
|
||||||
nano_timer_init(&timer, timer_data);
|
nano_timer_init(&timer, timer_data);
|
||||||
nano_timer_start(&timer, MSEC(time) + 1);
|
nano_timer_start(&timer, MSEC(time) + 1);
|
||||||
nano_timer_test(&timer, TICKS_UNLIMITED);
|
nano_timer_test(&timer, TICKS_UNLIMITED);
|
||||||
|
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +79,24 @@ 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 && \
|
||||||
|
SYS_KERNEL_VER_MINOR(KERNEL_VERSION_NUMBER) >= 6
|
||||||
|
|
||||||
|
struct k_timer timer;
|
||||||
|
k_timer_init(&timer, NULL, NULL);
|
||||||
|
k_timer_start(&timer, USEC(time) + 1, 0);
|
||||||
|
k_timer_status_sync(&timer);
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
struct nano_timer timer;
|
struct nano_timer timer;
|
||||||
void *timer_data[1];
|
void *timer_data[1];
|
||||||
nano_timer_init(&timer, timer_data);
|
nano_timer_init(&timer, timer_data);
|
||||||
nano_timer_start(&timer, USEC(time) + 1);
|
nano_timer_start(&timer, USEC(time) + 1);
|
||||||
nano_timer_test(&timer, TICKS_UNLIMITED);
|
nano_timer_test(&timer, TICKS_UNLIMITED);
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ typedef struct timeval upm_clock_t;
|
|||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <sys_clock.h>
|
#include <sys_clock.h>
|
||||||
|
#include <version.h>
|
||||||
|
#include <kernel_version.h>
|
||||||
|
|
||||||
#if defined(CONFIG_STDOUT_CONSOLE)
|
#if defined(CONFIG_STDOUT_CONSOLE)
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user