// xw
/* Enable the LSI OSC */
RCC_LSICmd(ENABLE);
/* Wait till LSI is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);
// RtcWkup_Gpio_Init(); //
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
/* Configure the RTC data register and RTC prescaler */
RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
RTC_InitStructure.RTC_SynchPrediv = 0xFF;
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStructure);
/* Set the time to 00h 00mn 00s AM */
RTC_TimeStruct.RTC_H12 = RTC_H12_AM;
RTC_TimeStruct.RTC_Hours = 0x00;
RTC_TimeStruct.RTC_Minutes = 0x00;
RTC_TimeStruct.RTC_Seconds = 0x00;
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
Rtc_AlarmConfig();
}
// 当用来唤醒时, 便不会进入中断函数
void RTC_Alarm_IRQHandler(void)
{
/* Check on the AlarmA falg and on the number of interrupts per Second (60*8) */
if(RTC_GetITStatus(RTC_IT_ALRA) != RESET)
{
/* Clear RTC AlarmA Flags */
RTC_ClearITPendingBit(RTC_IT_ALRA);
// printf("\r\n 一场游戏一场梦 ");
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
RtcAlarmTime_Set();
// Rtc_AlarmConfig();
}
/* Clear the EXTIL line 17 */
EXTI_ClearITPendingBit(EXTI_Line17);
}
/* Set AlarmA subseconds and enable SubSec Alarm : generate 8 interripts per Second */
RTC_AlarmSubSecondConfig(RTC_Alarm_A, 0xFF, RTC_AlarmSubSecondMask_SS14_5);