summaryrefslogtreecommitdiff
path: root/components/libc/compilers/common
diff options
context:
space:
mode:
authorbernard <[email protected]>2021-07-12 00:46:38 +0000
committerGitee <[email protected]>2021-07-12 00:46:38 +0000
commitddc5c793a482fe44310bafe181802ad406fa1b29 (patch)
treeb64de33831a39079cd27acb358cfe90b90a525cb /components/libc/compilers/common
parent2fda55d898826a1ee79babc4e0852ce539a3bff4 (diff)
parentecc0981d1027b2712f27b1c28d7657cb97b93ca2 (diff)
!253 更新 RTC 设备驱动框架,统一并简化 RTC 设备的注册和访问过程
Merge pull request !253 from iysheng/tmp1
Diffstat (limited to 'components/libc/compilers/common')
-rw-r--r--components/libc/compilers/common/time.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index deda18a560..e13f81c2f7 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -473,12 +473,17 @@ static int clock_time_system_init()
rt_device_t device;
time = 0;
+
+#ifdef RT_USING_RTC
device = rt_device_find("rtc");
if (device != RT_NULL)
{
/* get realtime seconds */
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
}
+#else
+ LOG_W("Cannot find a RTC device to provide time!");
+#endif
/* get tick */
tick = rt_tick_get();
@@ -591,6 +596,7 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
_timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
_timevalue.tv_sec = second - tick/RT_TICK_PER_SECOND - 1;
+#ifdef RT_USING_RTC
/* update for RTC device */
device = rt_device_find("rtc");
if (device != RT_NULL)
@@ -599,6 +605,9 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &second);
}
else
+#else
+ LOG_W("Cannot find a RTC device to save time!");
+#endif
return -1;
return 0;