diff --git a/bsp/stm32f10x/drivers/rtc.c b/bsp/stm32f10x/drivers/stm32f1_rtc.c similarity index 66% rename from bsp/stm32f10x/drivers/rtc.c rename to bsp/stm32f10x/drivers/stm32f1_rtc.c index c63054cdab456ce067ced7d988360c491ac9c095..2376a032924d3461eccc2b3457af71bb14f0ee34 100644 --- a/bsp/stm32f10x/drivers/rtc.c +++ b/bsp/stm32f10x/drivers/stm32f1_rtc.c @@ -1,5 +1,5 @@ /* - * File : rtc.c + * File : stm32f1_rtc.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2009, RT-Thread Development Team * @@ -11,11 +11,12 @@ * Date Author Notes * 2009-01-05 Bernard the first version. * 2011-11-26 aozima implementation time. + * 2015-07-16 FlyM rename rtc to stm32f1_rtc. remove finsh export function */ #include #include -#include "rtc.h" +#include "stm32f1_rtc.h" static struct rt_device rtc; static rt_err_t rt_rtc_open(rt_device_t dev, rt_uint16_t oflag) @@ -159,91 +160,4 @@ void rt_hw_rtc_init(void) return; } -#include -#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000 /* for IAR 6.2 later Compiler */ -#pragma module_name = "?time" -time_t (__time32)(time_t *t) /* Only supports 32-bit timestamp */ -#else -time_t time(time_t* t) -#endif -{ - rt_device_t device; - time_t time=0; - - 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; -} - -#ifdef RT_USING_FINSH -#include - -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; 0~11 */ - 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); - - ti = localtime(&now); - if (ti != RT_NULL) - { - ti->tm_hour = hour; - ti->tm_min = minute; - ti->tm_sec = second; - } - - 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_time, set time. e.g: set_time(23,59,59)) - -void list_date(void) -{ - time_t now; - - time(&now); - rt_kprintf("%s\n", ctime(&now)); -} -FINSH_FUNCTION_EXPORT(list_date, show date and time.) -#endif diff --git a/bsp/stm32f10x/drivers/rtc.h b/bsp/stm32f10x/drivers/stm32f1_rtc.h similarity index 83% rename from bsp/stm32f10x/drivers/rtc.h rename to bsp/stm32f10x/drivers/stm32f1_rtc.h index 1f54d593287e9c5524740248743917d65e5baaeb..02f463fce51f79cc31f1e6d5bd7ef0221617123e 100644 --- a/bsp/stm32f10x/drivers/rtc.h +++ b/bsp/stm32f10x/drivers/stm32f1_rtc.h @@ -1,5 +1,5 @@ /* - * File : rtc.h + * File : stm32f1_rtc.h * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2009, RT-Thread Development Team * @@ -12,8 +12,8 @@ * 2009-01-05 Bernard the first version */ -#ifndef __RTC_H__ -#define __RTC_H__ +#ifndef __STM32F1_RTC_H__ +#define __STM32F1_RTC_H__ void rt_hw_rtc_init(void);