rename bsp/stm32f10x/drivers/rtc.c to stm32f1_rtc.c

rename bsp/stm32f10x/drivers/rtc.h to stm32f10x/drivers/stm32f1_rtc.h

remove set_date,set_time function.
This commit is contained in:
FlyM 2015-07-16 02:08:44 +08:00
parent eb29a6877f
commit 32855cfd3a
2 changed files with 88 additions and 88 deletions

View File

@ -15,7 +15,7 @@
#include <rtthread.h> #include <rtthread.h>
#include <stm32f10x.h> #include <stm32f10x.h>
#include "rtc.h" #include "stm32f1_rtc.h"
static struct rt_device rtc; static struct rt_device rtc;
static rt_err_t rt_rtc_open(rt_device_t dev, rt_uint16_t oflag) static rt_err_t rt_rtc_open(rt_device_t dev, rt_uint16_t oflag)
@ -159,91 +159,91 @@ void rt_hw_rtc_init(void)
return; return;
} }
#include <time.h> // #include <time.h>
#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000 /* for IAR 6.2 later Compiler */ // #if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000 /* for IAR 6.2 later Compiler */
#pragma module_name = "?time" // #pragma module_name = "?time"
time_t (__time32)(time_t *t) /* Only supports 32-bit timestamp */ // time_t (__time32)(time_t *t) /* Only supports 32-bit timestamp */
#else // #else
time_t time(time_t* t) // time_t time(time_t* t)
#endif // #endif
{ // {
rt_device_t device; // rt_device_t device;
time_t time=0; // 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;
// }
device = rt_device_find("rtc"); // #ifdef RT_USING_FINSH
if (device != RT_NULL) // #include <finsh.h>
{ //
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); // void set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
if (t != RT_NULL) *t = time; // {
} // time_t now;
// struct tm* ti;
return time; // rt_device_t device;
} //
// ti = RT_NULL;
#ifdef RT_USING_FINSH // /* get current time */
#include <finsh.h> // time(&now);
//
void set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day) // ti = localtime(&now);
{ // if (ti != RT_NULL)
time_t now; // {
struct tm* ti; // ti->tm_year = year - 1900;
rt_device_t device; // ti->tm_mon = month - 1; /* ti->tm_mon = month; 0~11 */
// ti->tm_mday = day;
ti = RT_NULL; // }
/* get current time */ //
time(&now); // now = mktime(ti);
//
ti = localtime(&now); // device = rt_device_find("rtc");
if (ti != RT_NULL) // if (device != RT_NULL)
{ // {
ti->tm_year = year - 1900; // rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
ti->tm_mon = month - 1; /* ti->tm_mon = month; 0~11 */ // }
ti->tm_mday = day; // }
} // FINSH_FUNCTION_EXPORT(set_date, set date. e.g: set_date(2010,2,28))
//
now = mktime(ti); // void set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
// {
device = rt_device_find("rtc"); // time_t now;
if (device != RT_NULL) // struct tm* ti;
{ // rt_device_t device;
rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now); //
} // ti = RT_NULL;
} // /* get current time */
FINSH_FUNCTION_EXPORT(set_date, set date. e.g: set_date(2010,2,28)) // time(&now);
//
void set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second) // ti = localtime(&now);
{ // if (ti != RT_NULL)
time_t now; // {
struct tm* ti; // ti->tm_hour = hour;
rt_device_t device; // ti->tm_min = minute;
// ti->tm_sec = second;
ti = RT_NULL; // }
/* get current time */ //
time(&now); // now = mktime(ti);
// device = rt_device_find("rtc");
ti = localtime(&now); // if (device != RT_NULL)
if (ti != RT_NULL) // {
{ // rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
ti->tm_hour = hour; // }
ti->tm_min = minute; // }
ti->tm_sec = second; // FINSH_FUNCTION_EXPORT(set_time, set time. e.g: set_time(23,59,59))
} //
// void list_date(void)
now = mktime(ti); // {
device = rt_device_find("rtc"); // time_t now;
if (device != RT_NULL) //
{ // time(&now);
rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now); // rt_kprintf("%s\n", ctime(&now));
} // }
} // FINSH_FUNCTION_EXPORT(list_date, show date and time.)
FINSH_FUNCTION_EXPORT(set_time, set time. e.g: set_time(23,59,59)) // #endif
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