summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorwuyangyong <[email protected]>2011-11-28 05:58:21 +0000
committerwuyangyong <[email protected]>2011-11-28 05:58:21 +0000
commitbff77ee86b1ebce59cf652ae9c32937d9529de25 (patch)
treeb8c887c95871e76b20b62609131d690221fa7eca /bsp
parenta4cff858f6dfb68bcf78cfa8353c7bc46abcb4a5 (diff)
update rtc driver.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1811 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp')
-rw-r--r--bsp/stm32f10x/rtc.c4
-rw-r--r--bsp/stm32f20x/rtc.c60
2 files changed, 28 insertions, 36 deletions
diff --git a/bsp/stm32f10x/rtc.c b/bsp/stm32f10x/rtc.c
index bddb6a07f0..20618a1d33 100644
--- a/bsp/stm32f10x/rtc.c
+++ b/bsp/stm32f10x/rtc.c
@@ -156,10 +156,6 @@ void rt_hw_rtc_init(void)
rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR);
-#ifdef RT_USING_FINSH
- list_date();
-#endif
-
return;
}
diff --git a/bsp/stm32f20x/rtc.c b/bsp/stm32f20x/rtc.c
index fb3ba6fba3..1604ee4497 100644
--- a/bsp/stm32f20x/rtc.c
+++ b/bsp/stm32f20x/rtc.c
@@ -49,18 +49,18 @@ static time_t rt_mktime(struct tm *tm)
{
long res;
int year;
- year = tm->tm_year - 70;
-
- res = YEAR * year + DAY * ((year + 1) / 4);
- res += month[tm->tm_mon];
+ year = tm->tm_year - 70;
+
+ res = YEAR * year + DAY * ((year + 1) / 4);
+ res += month[tm->tm_mon];
if (tm->tm_mon > 1 && ((year + 2) % 4))
res -= DAY;
- res += DAY * (tm->tm_mday - 1);
- res += HOUR * tm->tm_hour;
+ res += DAY * (tm->tm_mday - 1);
+ res += HOUR * tm->tm_hour;
res += MINUTE * tm->tm_min;
- res += tm->tm_sec;
- return res;
+ res += tm->tm_sec;
+ return res;
}
static rt_err_t rt_rtc_open(rt_device_t dev, rt_uint16_t oflag)
{
@@ -109,7 +109,7 @@ static rt_err_t rt_rtc_control(rt_device_t dev, rt_uint8_t cmd, void *args)
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
-
+
/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);
@@ -154,35 +154,35 @@ int RTC_Config(void)
u32 count=0x200000;
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
-
+
/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);
-
+
RCC_LSEConfig(RCC_LSE_ON);
-
- /* Wait till LSE is ready */
+
+ /* Wait till LSE is ready */
while ( (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) && (--count) );
if ( count == 0 )
{
return -1;
}
-
+
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
-
+
SynchPrediv = 0xFF;
AsynchPrediv = 0x7F;
-
+
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
-
+
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
-
+
/* Enable The TimeStamp */
- //RTC_TimeStampCmd(RTC_TimeStampEdge_Falling, ENABLE);
-
- return 0;
+ //RTC_TimeStampCmd(RTC_TimeStampEdge_Falling, ENABLE);
+
+ return 0;
}
int RTC_Configuration(void)
@@ -195,21 +195,21 @@ int RTC_Configuration(void)
RTC_TimeStructure.RTC_Hours = 0;
RTC_TimeStructure.RTC_Minutes = 0;
RTC_TimeStructure.RTC_Seconds = 0;
-
+
/* Set the Date */
RTC_DateStructure.RTC_Month = 1;
- RTC_DateStructure.RTC_Date = 1;
- RTC_DateStructure.RTC_Year = 0;
- RTC_DateStructure.RTC_WeekDay = 4;
-
+ RTC_DateStructure.RTC_Date = 1;
+ RTC_DateStructure.RTC_Year = 0;
+ RTC_DateStructure.RTC_WeekDay = 4;
+
/* Calendar Configuration */
RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv;
RTC_InitStructure.RTC_SynchPrediv = SynchPrediv;
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStructure);
-
+
/* Set Current Time and Date */
- RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
+ RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
RTC_SetDate(RTC_Format_BCD, &RTC_DateStructure);
if (RTC_Init(&RTC_InitStructure) == ERROR)
return -1;
@@ -250,10 +250,6 @@ void rt_hw_rtc_init(void)
rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR);
-#ifdef RT_USING_FINSH
- list_date();
-#endif
-
return;
}