if (BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
{
/* Backup data register value is not correct or not yet programmed (when
the first time the program is executed) */
printf("RTC 还没有被设置....\r\n");
/* RTC Configuration */
RTC_Configuration();
Time_Regulate();
/* Adjust time by values entred by the user on the hyperterminal */
printf("RTC 初始化....\r\n");
BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);
}
else
{
/* Check if the Power On Reset flag is set */
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
{
printf("发生一次电源上电重启....\r\n");
}
/* Check if the Pin Reset flag is set */
else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
{
printf("发生一次外部复位....\r\n");
}
printf("不需要设置RCT....\r\n");
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
/* Enable the RTC Second */
RTC_ITConfig(RTC_IT_SEC, ENABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}