1307注册设备代码删除
This commit is contained in:
1 parent
f740550370
commit
4e5d32a3f4
1 file changed
+2
-73
+2
-73
@@ -33,7 +33,7 @@
|
||||
#ifdef BRD_RTC_DS1307_DEBUG
|
||||
#define DBG_LVL DBG_LOG
|
||||
#else
|
||||
#define DBG_LVL DBG_INFO
|
||||
#define DBG_LVL DBG_INFO
|
||||
#endif
|
||||
#include <rtdbg.h>
|
||||
|
||||
@@ -215,67 +215,6 @@ static rt_err_t ds1307_write_tm(struct tm *tm)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* RTC ops *//*
|
||||
static rt_err_t ds1307_rtc_init(void)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t ds1307_rtc_get_secs(time_t *sec)
|
||||
{
|
||||
ds1307_read_time();
|
||||
#ifdef RT_USING_LIBC
|
||||
*sec = ds1307.tick.tv_sec;
|
||||
#else
|
||||
*sec = 0; // fallback
|
||||
#endif
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t ds1307_rtc_set_secs(time_t *sec)
|
||||
{
|
||||
#ifdef RT_USING_LIBC
|
||||
struct tm tm_time;
|
||||
localtime_r(sec, &tm_time);
|
||||
return ds1307_write_tm(&tm_time);
|
||||
#else
|
||||
LOG_E("Set by timestamp requires RT_USING_LIBC");
|
||||
return -RT_ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
static rt_err_t ds1307_rtc_get_timeval(struct timeval *tv)
|
||||
{
|
||||
ds1307_read_time();
|
||||
*tv = ds1307.tick;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t ds1307_rtc_set_timeval(struct timeval *tv)
|
||||
{
|
||||
#ifdef RT_USING_LIBC
|
||||
struct tm tm_time;
|
||||
localtime_r(&tv->tv_sec, &tm_time);
|
||||
return ds1307_write_tm(&tm_time);
|
||||
#else
|
||||
LOG_E("Set by timeval requires RT_USING_LIBC");
|
||||
return -RT_ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
static const struct rt_rtc_ops ds1307_rtc_ops =
|
||||
{
|
||||
ds1307_rtc_init,
|
||||
ds1307_rtc_get_secs,
|
||||
ds1307_rtc_set_secs,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
ds1307_rtc_get_timeval,
|
||||
ds1307_rtc_set_timeval,
|
||||
};*/
|
||||
|
||||
//static rt_rtc_dev_t ds1307_rtc_dev;
|
||||
|
||||
/* Initialization and registration */
|
||||
static int rt_hw_ds1307_rtc_init(void)
|
||||
{
|
||||
@@ -288,22 +227,12 @@ 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, 10, 5);
|
||||
if (ds1307.thd_soft_update_sec)
|
||||
{
|
||||
rt_thread_startup(ds1307.thd_soft_update_sec);
|
||||
}
|
||||
|
||||
/* rt_err_t result = rt_hw_rtc_register(&ds1307_rtc_dev, "ds1307", RT_DEVICE_FLAG_RDWR, &ds1307);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
LOG_E("RTC register failed: %d", result);
|
||||
return result;
|
||||
}*/
|
||||
|
||||
LOG_I("DS1307 RTC initialized successfully on %s", ds1307.iic_name);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user