revert time()
This commit is contained in:
parent
6c7dd30532
commit
d0c2631b12
|
@ -8,7 +8,7 @@
|
||||||
* 2019-08-21 zhangjun copy from minilibc
|
* 2019-08-21 zhangjun copy from minilibc
|
||||||
* 2020-09-07 Meco Man combine gcc armcc iccarm
|
* 2020-09-07 Meco Man combine gcc armcc iccarm
|
||||||
* 2021-02-05 Meco Man add timegm()
|
* 2021-02-05 Meco Man add timegm()
|
||||||
* 2021-02-07 Meco Man fixed gettimeofday() time()
|
* 2021-02-07 Meco Man fixed gettimeofday()
|
||||||
* 2021-02-08 Meco Man add settimeofday() stime()
|
* 2021-02-08 Meco Man add settimeofday() stime()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -177,16 +177,25 @@ time_t time(time_t *t)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
time_t time_now = 0;
|
time_t time_now = 0;
|
||||||
|
|
||||||
#ifdef RT_USING_RTC
|
#ifdef RT_USING_RTC
|
||||||
rt_device_t device;
|
static rt_device_t device = RT_NULL;
|
||||||
|
|
||||||
|
/* optimization: find rtc device only first. */
|
||||||
|
if (device == RT_NULL)
|
||||||
|
{
|
||||||
|
device = rt_device_find("rtc");
|
||||||
|
}
|
||||||
|
|
||||||
/* read timestamp from RTC device. */
|
/* read timestamp from RTC device. */
|
||||||
device = rt_device_find("rtc");
|
if (device != RT_NULL)
|
||||||
|
{
|
||||||
if (rt_device_open(device, 0) == RT_EOK)
|
if (rt_device_open(device, 0) == RT_EOK)
|
||||||
{
|
{
|
||||||
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time_now);
|
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time_now);
|
||||||
rt_device_close(device);
|
rt_device_close(device);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif /* RT_USING_RTC */
|
#endif /* RT_USING_RTC */
|
||||||
|
|
||||||
/* if t is not NULL, write timestamp to *t */
|
/* if t is not NULL, write timestamp to *t */
|
||||||
|
|
Loading…
Reference in New Issue