From d20343a87d03bf00aca88945faff4dee68428937 Mon Sep 17 00:00:00 2001 From: "dzzxzz@gmail.com" Date: Mon, 25 Jun 2012 09:02:46 +0000 Subject: [PATCH] using RTC API from RTC device driver framework git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2183 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/efm32/drv_rtc.c | 97 --------------------------------------------- 1 file changed, 97 deletions(-) diff --git a/bsp/efm32/drv_rtc.c b/bsp/efm32/drv_rtc.c index 3bd41ba1c..cced103af 100644 --- a/bsp/efm32/drv_rtc.c +++ b/bsp/efm32/drv_rtc.c @@ -225,103 +225,6 @@ void rt_hw_rtc_init(void) rt_hw_rtc_register(&rtc, RT_RTC_NAME, EFM32_NO_DATA); } -/***************************************************************************//** - * Export to FINSH - ******************************************************************************/ -#ifdef RT_USING_FINSH -#include -#include -time_t time(time_t* t) -{ - rt_device_t device; - time_t time; - - device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (t != RT_NULL) *t = time; - } - - return time; -} - -void set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day) -{ - time_t now; - struct tm* ti; - rt_device_t device; - - ti = RT_NULL; - /* get current time */ - time(&now); - - ti = localtime(&now); - if (ti != RT_NULL) - { - ti->tm_year = year - 1900; - ti->tm_mon = month - 1; /* ti->tm_mon = month; */ - ti->tm_mday = day; - } - - now = mktime(ti); - - device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now); - } -} -FINSH_FUNCTION_EXPORT(set_date, set date. e.g: set_date(2010,2,28)) - -void set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second) -{ - time_t now; - struct tm* ti; - rt_device_t device; - - ti = RT_NULL; - /* get current time */ - time(&now); - rtc_debug("RTC: Now %x\n", now); - - ti = localtime(&now); - if (ti != RT_NULL) - { - ti->tm_hour = hour; - ti->tm_min = minute; - ti->tm_sec = second; - } - rtc_debug("RTC: DST %d\n", ti->tm_isdst); - rtc_debug("RTC: Days in year %d\n", ti->tm_yday); - rtc_debug("RTC: Day of week %d\n", ti->tm_wday); - rtc_debug("RTC: Year %d\n", ti->tm_year); - rtc_debug("RTC: Month %d\n", ti->tm_mon); - rtc_debug("RTC: Day %d\n", ti->tm_mday); - rtc_debug("RTC: Hour %d\n", ti->tm_hour); - rtc_debug("RTC: Min %d\n", ti->tm_min); - rtc_debug("RTC: Sec %d\n", ti->tm_sec); - - now = mktime(ti); - rtc_debug("RTC: Now %x\n", now); - device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now); - } -} -FINSH_FUNCTION_EXPORT(set_time, set time. e.g: set_time(23,59,59)) - -void list_date() -{ - time_t now; - - time(&now); - rt_kprintf("%s\n", ctime(&now)); -} -FINSH_FUNCTION_EXPORT(list_date, show date and time.) -#endif - #endif /***************************************************************************//**