Skip to content

Commit 3c4bff5

Browse files
committed
在gettimeofday函数中添加对RTC设备不可用时使用滴答计数的处理
1 parent 3e4f0ec commit 3c4bff5

File tree

1 file changed

+5
-0
lines changed
  • components/libc/compilers/common

1 file changed

+5
-0
lines changed

components/libc/compilers/common/ctime.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
497497
{
498498
return 0;
499499
}
500+
else
501+
{
502+
// if RTC device is not available, use tick count
503+
tv->tv_sec = rt_tick_get() / RT_TICK_PER_SECOND;
504+
}
500505
}
501506
}
502507
#endif /* RT_USING_RTC */

0 commit comments

Comments
 (0)