This commit is contained in:
Meco Man 2021-02-07 21:17:27 +08:00
parent f073911cd3
commit 64bd41d654
1 changed files with 11 additions and 11 deletions

View File

@ -12,7 +12,7 @@
*/ */
#include <rtthread.h> #include <rtthread.h>
#include <time.h> #include <sys/time.h>
#include <s3c24x0.h> #include <s3c24x0.h>
// #define RTC_DEBUG // #define RTC_DEBUG
@ -132,17 +132,17 @@ static rt_err_t rtc_control(rt_device_t dev, int cmd, void *args)
time = (time_t *)args; time = (time_t *)args;
switch (cmd) switch (cmd)
{ {
case RT_DEVICE_CTRL_RTC_GET_TIME: case RT_DEVICE_CTRL_RTC_GET_TIME:
/* read device */ /* read device */
rt_hw_rtc_get(&tm); rt_hw_rtc_get(&tm);
*((rt_time_t *)args) = mktime(&tm); *((rt_time_t *)args) = mktime(&tm);
break; break;
case RT_DEVICE_CTRL_RTC_SET_TIME: case RT_DEVICE_CTRL_RTC_SET_TIME:
tm_ptr = localtime(time); tm_ptr = localtime(time);
/* write device */ /* write device */
rt_hw_rtc_set(tm_ptr); rt_hw_rtc_set(tm_ptr);
break; break;
} }
return RT_EOK; return RT_EOK;