12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #include "includes.h"
- //进入低功耗会死机,暂时使用以下操作模拟。20mA~30mA左右
- //unsigned char g_bRTCAlarm=0;
- #if 1
- void Sleeping(void)
- {
- SlwTrace(INF, "Sleeping",1);
- PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);
- }
- #else
- void Sleeping(void)
- {
- SlwTrace(INF, "Sleeping",1);
- KEYBOARD_BACKLIGHT_LOW;
- SpeakerDisable();MicDisable();
- LCD_BL_LOW;
- MODEM_RESET_HIGH;
- // MODEM_PWRKEY_LOW;
- GPS_PWREN_LOW;
- //GetVbat();
- // SysTick->CTRL = 0x00;//?????
- // SysTick->VAL = 0x00;//??val,?????
- //
- IWDG_Configuration(3000);//////////////
- //DBGMCU_Config(DBGMCU_STOP, ENABLE);
- ENTERSTOPMODE:
- //设置闹铃时间
- dev_rtc_setAlarm(15);
- // 进入停机模式
- printf("time go go step1\r\n");
- EXTI_ClearITPendingBit(EXTI_Line17); // 清//EXTI_Line9 |
- //printf("Vbat==========%d\r\n",GetOneceVbat());
- ADC_Cmd (ADC1,DISABLE);
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); //使能PWR外设时钟
- PWR_WakeUpPinCmd(ENABLE); //使能唤醒管脚功能
- PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);
- // RTC时间到达
- if(dev_rtc_isAlarm())
- {
- IWDG_ReloadCounter();
- SystemInit();
- ADCInit();
- ADC_Cmd (ADC1,ENABLE);
- if(GetOneceVbat()>77){ // 77--345V 由于从停机模式醒来,测试ADC不准 只能打印知晓值。
- printf("Wake Up\r\n");
- while(1);
- }
- goto ENTERSTOPMODE;
-
- }
- }
- #endif
- #if 0
- void dev_rtc_setAlarm(int AlarmValue)
- {
- RTC_ITConfig(RTC_IT_ALR, ENABLE);
- /* Clear the RTC SEC flag */
- RTC_ClearFlag(RTC_FLAG_SEC);
- /* Wait clear RTC flag success */
- while(RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET); //
- /* Wait until last write operation on RTC registers has finished */
- RTC_WaitForLastTask();
- /* Sets the RTC alarm value */
- RTC_SetAlarm(RTC_GetCounter() + AlarmValue);
- /* Wait until last write operation on RTC registers has finished */
- RTC_WaitForLastTask();
-
- }
- unsigned char dev_rtc_isAlarm(void)
- {
- if(g_bRTCAlarm)
- {
- /* Clear the RTC alarm flag */
- g_bRTCAlarm = 0;
- return 1;
- }
- return 0;
- }
- #endif
|