[X9D] RTC. Tx Setup cosmetics
This commit is contained in:
+42
-38
@@ -35,49 +35,53 @@
|
||||
|
||||
void rtc_settime(struct gtm * t)
|
||||
{
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_TimeStruct.RTC_Hours = t->tm_hour;
|
||||
RTC_TimeStruct.RTC_Minutes = t->tm_min;
|
||||
RTC_TimeStruct.RTC_Seconds = t->tm_sec;
|
||||
RTC_DateStruct.RTC_Year = t->tm_year - 100;
|
||||
RTC_DateStruct.RTC_Month = t->tm_mon;
|
||||
RTC_DateStruct.RTC_Date = t->tm_mday;
|
||||
|
||||
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_TimeStruct.RTC_Hours = t->tm_hour;
|
||||
RTC_TimeStruct.RTC_Minutes = t->tm_min;
|
||||
RTC_TimeStruct.RTC_Seconds = t->tm_sec;
|
||||
RTC_DateStruct.RTC_Year = t->tm_year - 100;
|
||||
RTC_DateStruct.RTC_Month = t->tm_mon;
|
||||
RTC_DateStruct.RTC_Date = t->tm_mday;
|
||||
|
||||
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
}
|
||||
|
||||
void rtc_gettime(struct gtm * t)
|
||||
{
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
|
||||
t->tm_hour = RTC_TimeStruct.RTC_Hours;
|
||||
t->tm_min = RTC_TimeStruct.RTC_Minutes;
|
||||
t->tm_sec = RTC_TimeStruct.RTC_Seconds;
|
||||
t->tm_year = RTC_DateStruct.RTC_Year + 100;
|
||||
t->tm_mon = RTC_DateStruct.RTC_Month;
|
||||
t->tm_mday = RTC_DateStruct.RTC_Date;
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
RTC_DateTypeDef RTC_DateStruct;
|
||||
|
||||
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
|
||||
|
||||
t->tm_hour = RTC_TimeStruct.RTC_Hours;
|
||||
t->tm_min = RTC_TimeStruct.RTC_Minutes;
|
||||
t->tm_sec = RTC_TimeStruct.RTC_Seconds;
|
||||
t->tm_year = RTC_DateStruct.RTC_Year + 100;
|
||||
t->tm_mon = RTC_DateStruct.RTC_Month;
|
||||
t->tm_mday = RTC_DateStruct.RTC_Date;
|
||||
}
|
||||
|
||||
void rtc_init()
|
||||
void rtcInit()
|
||||
{
|
||||
RTC_InitTypeDef RTC_InitStruct;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
|
||||
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
|
||||
RCC_RTCCLKCmd(ENABLE);
|
||||
|
||||
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
|
||||
RTC_InitStruct.RTC_AsynchPrediv = 128;
|
||||
RTC_InitStruct.RTC_SynchPrediv = 256;
|
||||
|
||||
RTC_Init(&RTC_InitStruct);
|
||||
RTC_InitTypeDef RTC_InitStruct;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
|
||||
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
|
||||
RCC_RTCCLKCmd(ENABLE);
|
||||
|
||||
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
|
||||
RTC_InitStruct.RTC_AsynchPrediv = 128;
|
||||
RTC_InitStruct.RTC_SynchPrediv = 256;
|
||||
|
||||
RTC_Init(&RTC_InitStruct);
|
||||
|
||||
struct gtm utm;
|
||||
rtc_gettime(&utm);
|
||||
g_rtcTime = gmktime(&utm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user