使用get_timestamp/set_timestamp跳过了device_open,RTC未被正常初始化,导致系统死机

This commit is contained in:
2023-05-31 11:36:58 +08:00
parent 0924efffd0
commit 1563cd3e74

View File

@ -337,21 +337,21 @@ static void date(int argc, char **argv)
return;
}
/* save old timestamp */
err = get_timestamp(&old);
if (err != RT_EOK)
err = time(&old);
if (err < 0)
{
rt_kprintf("Get current timestamp failed. %d\n", err);
return;
}
/* converts the local time into the calendar time. */
now = mktime(&tm_new);
err = set_timestamp(now);
err = stime(&now);
if (err != RT_EOK)
{
rt_kprintf("set date failed. %d\n", err);
return;
}
get_timestamp(&now); /* get new timestamp */
time(&now);
rt_kprintf("old: %.*s", 25, ctime(&old));
rt_kprintf("now: %.*s", 25, ctime(&now));
}