✨ feat(ktime): add RT_USING_KTIME to kconfig build
This commit is contained in:
parent
0b966bfca0
commit
5f0328ee41
|
@ -34,5 +34,6 @@ source "$RTT_DIR/components/libc/Kconfig"
|
|||
source "$RTT_DIR/components/net/Kconfig"
|
||||
source "$RTT_DIR/components/utilities/Kconfig"
|
||||
source "$RTT_DIR/components/vbus/Kconfig"
|
||||
source "$RTT_DIR/components/ktime/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#ifdef RT_USING_KTIME
|
||||
#include <ktime.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SOFT_RTC
|
||||
|
||||
|
@ -38,8 +40,11 @@ static rt_device_t source_device = RT_NULL;
|
|||
static struct rt_device soft_rtc_dev;
|
||||
static rt_tick_t init_tick;
|
||||
static time_t init_time;
|
||||
|
||||
#ifdef RT_USING_KTIME
|
||||
static struct timeval init_tv = {0};
|
||||
static struct timespec init_ts = {0};
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_ALARM
|
||||
|
||||
|
@ -92,10 +97,12 @@ static void _source_device_control(int cmd, void *args)
|
|||
static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
time_t *t;
|
||||
#ifdef RT_USING_KTIME
|
||||
struct timeval *tv;
|
||||
struct timespec *ts;
|
||||
struct timeval _tv;
|
||||
struct timespec _ts;
|
||||
#endif
|
||||
struct tm time_temp;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
@ -123,6 +130,7 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
|
|||
soft_rtc_alarm_update(&wkalarm);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RT_USING_KTIME
|
||||
case RT_DEVICE_CTRL_RTC_GET_TIMEVAL:
|
||||
tv = (struct timeval *)args;
|
||||
rt_ktime_boottime_get_us(&_tv);
|
||||
|
@ -154,6 +162,9 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
|
|||
ts->tv_sec = 0;
|
||||
ts->tv_nsec = (rt_ktime_cputimer_getres() / RT_KTIME_RESMUL);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return -RT_EINVAL;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
menuconfig RT_USING_KTIME
|
||||
bool "Ktime: kernel time"
|
||||
default n
|
|
@ -14,6 +14,6 @@ if rtconfig.ARCH in list:
|
|||
src += Glob("src/" + rtconfig.ARCH + "/*.c")
|
||||
CPPPATH = [cwd, cwd + "/inc"]
|
||||
|
||||
group = DefineGroup('ktime', src, depend=[''], CPPPATH=CPPPATH)
|
||||
group = DefineGroup('ktime', src, depend=['RT_USING_KTIME'], CPPPATH=CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
|
||||
#include "sys/time.h"
|
||||
#include <ktime.h>
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <sys/errno.h>
|
||||
|
@ -40,6 +39,9 @@
|
|||
#if defined( RT_USING_RTC ) || defined( RT_USING_CPUTIME)
|
||||
#include <rtdevice.h>
|
||||
#endif
|
||||
#ifdef RT_USING_KTIME
|
||||
#include "ktime.h"
|
||||
#endif
|
||||
|
||||
#define DBG_TAG "time"
|
||||
#define DBG_LVL DBG_INFO
|
||||
|
@ -459,7 +461,7 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
|||
}
|
||||
RTM_EXPORT(settimeofday);
|
||||
|
||||
#ifdef RT_USING_POSIX_DELAY
|
||||
#if defined(RT_USING_POSIX_DELAY) && defined(RT_USING_KTIME)
|
||||
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
{
|
||||
struct timespec old_ts = {0};
|
||||
|
@ -501,9 +503,9 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
|||
return 0;
|
||||
}
|
||||
RTM_EXPORT(nanosleep);
|
||||
#endif /* RT_USING_POSIX_DELAY */
|
||||
#endif /* RT_USING_POSIX_DELAY && RT_USING_KTIME */
|
||||
|
||||
#ifdef RT_USING_POSIX_CLOCK
|
||||
#if defined(RT_USING_POSIX_CLOCK) && defined(RT_USING_KTIME)
|
||||
|
||||
int clock_getres(clockid_t clockid, struct timespec *res)
|
||||
{
|
||||
|
@ -693,9 +695,9 @@ int rt_timespec_to_tick(const struct timespec *time)
|
|||
}
|
||||
RTM_EXPORT(rt_timespec_to_tick);
|
||||
|
||||
#endif /* RT_USING_POSIX_CLOCK */
|
||||
#endif /* RT_USING_POSIX_CLOCK && RT_USING_KTIME */
|
||||
|
||||
#ifdef RT_USING_POSIX_TIMER
|
||||
#if defined(RT_USING_POSIX_TIMER) && defined(RT_USING_KTIME)
|
||||
|
||||
#include <resource_id.h>
|
||||
|
||||
|
@ -1111,7 +1113,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
|
|||
return 0;
|
||||
}
|
||||
RTM_EXPORT(timer_settime);
|
||||
#endif /* RT_USING_POSIX_TIMER */
|
||||
#endif /* RT_USING_POSIX_TIMER && RT_USING_KTIME */
|
||||
|
||||
|
||||
/* timezone */
|
||||
|
|
|
@ -47,6 +47,7 @@ if RT_USING_POSIX_FS
|
|||
endif
|
||||
|
||||
config RT_USING_POSIX_DELAY
|
||||
select RT_USING_KTIME
|
||||
bool "Enable delay APIs, sleep()/usleep()/msleep() etc"
|
||||
default n
|
||||
|
||||
|
@ -56,7 +57,7 @@ config RT_USING_POSIX_CLOCK
|
|||
default n
|
||||
|
||||
config RT_USING_POSIX_TIMER
|
||||
select RT_USING_TIMER_SOFT
|
||||
select RT_USING_KTIME
|
||||
select RT_USING_RESOURCE_ID
|
||||
bool "Enable timer APIs, timer_create()/timer_gettime() etc"
|
||||
default n
|
||||
|
|
|
@ -34,6 +34,7 @@ config RT_USING_SMART
|
|||
select RT_USING_POSIX_CLOCK
|
||||
select RT_USING_POSIX_FS
|
||||
select RT_USING_POSIX_TERMIOS
|
||||
select RT_USING_KTIME
|
||||
depends on ARCH_ARM_CORTEX_M || ARCH_ARM_ARM9 || ARCH_ARM_CORTEX_A || ARCH_ARMV8 || ARCH_RISCV64
|
||||
help
|
||||
RT-Thread Smart is a microkernel based operating system on RT-Thread.
|
||||
|
|
Loading…
Reference in New Issue