修改ini功能添加默认返回
This commit is contained in:
1 parent
4e5d32a3f4
commit
a27c950c42
6 files changed
+15
-34
No files matched your search
+6
-23
@@ -131,14 +131,13 @@ static void ds1307_read_time(void)
|
||||
ds1307.datetime.tm_min,
|
||||
ds1307.datetime.tm_sec);
|
||||
|
||||
if(ds1307.datetime.tm_year<199)//
|
||||
{
|
||||
/* 设置日期为年月号 */
|
||||
set_date(ds1307.datetime.tm_year + 1900, ds1307.datetime.tm_mon + 1, ds1307.datetime.tm_mday);
|
||||
/* 设置时间为点分秒 */
|
||||
set_time(ds1307.datetime.tm_hour, ds1307.datetime.tm_min, ds1307.datetime.tm_sec);
|
||||
/* 获取时间 */
|
||||
time_t now = time(RT_NULL);
|
||||
/* 打印输出时间信息 */
|
||||
rt_kprintf("DATE: %s", ctime(&now));
|
||||
}
|
||||
}
|
||||
|
||||
/* Software thread to maintain local time estimation */
|
||||
@@ -148,25 +147,9 @@ static void auto_update_current_datatime(void *parameter)
|
||||
while (1)
|
||||
{
|
||||
rt_thread_delay(RT_TICK_PER_SECOND);
|
||||
ds1307.datetime.tm_sec++;
|
||||
if (ds1307.datetime.tm_sec >= 60)
|
||||
{
|
||||
ds1307.datetime.tm_sec = 0;
|
||||
ds1307.datetime.tm_min++;
|
||||
if (ds1307.datetime.tm_min >= 60)
|
||||
{
|
||||
ds1307.datetime.tm_min = 0;
|
||||
ds1307.datetime.tm_hour++;
|
||||
if (ds1307.datetime.tm_hour >= 24)
|
||||
{
|
||||
ds1307.datetime.tm_hour = 0;
|
||||
// Note: day/month/year rollover not handled in soft update
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sync with hardware every 10 minutes
|
||||
if (++count >= 600) // 600 seconds
|
||||
if (++count >= 3600) // 600 seconds
|
||||
{
|
||||
ds1307_read_time();
|
||||
count = 0;
|
||||
@@ -227,7 +210,7 @@ static int rt_hw_ds1307_rtc_init(void)
|
||||
|
||||
ds1307_read_time();
|
||||
|
||||
ds1307.thd_soft_update_sec = rt_thread_create("ds1307",auto_update_current_datatime,RT_NULL,512, 10, 5);
|
||||
ds1307.thd_soft_update_sec = rt_thread_create("ds1307",auto_update_current_datatime,RT_NULL,512, 20, 5);
|
||||
if (ds1307.thd_soft_update_sec)
|
||||
{
|
||||
rt_thread_startup(ds1307.thd_soft_update_sec);
|
||||
@@ -236,7 +219,7 @@ static int rt_hw_ds1307_rtc_init(void)
|
||||
LOG_I("DS1307 RTC initialized successfully on %s", ds1307.iic_name);
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_ds1307_rtc_init);
|
||||
INIT_APP_EXPORT(rt_hw_ds1307_rtc_init);
|
||||
|
||||
/* MSH Commands */
|
||||
#include <stdlib.h>
|
||||
|
||||
Reference in new issue
Block a user