色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應用 > STM32 AWU RTC鬧鐘從停機模式喚醒CPU

          STM32 AWU RTC鬧鐘從停機模式喚醒CPU

          作者: 時間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
          網(wǎng)上找不到范例 自已對著PDF整了半天??!

          void RTC_EXTI_INITIAL(FunctionalState interrupt_en_or_dis)
          {
          NVIC_InitTypeDef NVIC_InitStructure;
          EXTI_InitTypeDef EXTI_InitStructure;

          本文引用地址:http://cafeforensic.com/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的時鐘(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;
          }

          }




          評論


          技術(shù)專區(qū)

          關(guān)閉