網(wǎng)上找不到范例 自已對(duì)著PDF整了半天!!void RTC_EXTI_INITIAL(FunctionalState interrupt_en_or_dis)
{
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
本文引用地址:
http://m.butianyuan.cn/article/201611/320090.htm//------------EXTI 配置 -------------------
EXTI_InitStructure.EXTI_Line = EXTI_Line17;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = interrupt_en_or_dis;
EXTI_Init(&EXTI_InitStructure);
//------------設(shè)置 中斷-------------------
NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn;//防拆
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = interrupt_en_or_dis;
NVIC_Init(&NVIC_InitStructure);
//-------------------------------------------
}
void RTC_SET_ALARM(u32 sec)
{
//DEBUG_COM_STREAM("-鬧鐘-",NULL);
RTC_SetAlarm(RTC_GetCounter()+sec);
//DEBUG_COM_STREAM("-鬧鐘1-",NULL);
RTC_WaitForLastTask();
//DEBUG_COM_STREAM("-鬧鐘2-",NULL);
RTC_ITConfig(RTC_FLAG_ALR,ENABLE);
}
void RTC_AWU_SET(void)
{
//啟用PWR和BKP的時(shí)鐘(from APB1)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
//后備域解鎖
PWR_BackupAccessCmd(ENABLE);
RTC_ITConfig(RTC_IT_SEC, DISABLE);
RTC_SET_ALARM(5);
//PWR_BackupAccessCmd(DISABLE);
RTC_EXTI_INITIAL(ENABLE);
}
void RTCAlarm_IRQHandler(void)
{
EXTI_ClearITPendingBit(EXTI_Line17);
//SYS.wake_id|=1<<17;
}
void RTC_IRQHandler(void)
{
if (RTC_GetITStatus(RTC_IT_SEC) != RESET)
{
RTC_ClearITPendingBit(RTC_IT_SEC);
RTC_WaitForLastTask();
//TIME_COUNT=RTC_GetCounter();
//RTC_WaitForLastTask();
}
if (RTC_GetITStatus(RTC_FLAG_ALR) != RESET)
{RTC_ClearITPendingBit(RTC_FLAG_ALR);
RTC_WaitForLastTask();
//SYS.wake_id|=1<<1;
}
}
評(píng)論