#include "includes.h" //进入低功耗会死机,暂时使用以下操作模拟。20mA~30mA左右 unsigned char g_bRTCAlarm=0; #if 0 void Sleeping(void) { SlwTrace(INF, "Sleeping",1); MODEM_LED1_LOW; MODEM_LED2_LOW; KEYBOARD_BACKLIGHT_LOW; SpeakerDisable(); MicDisable(); LCD_BL_LOW; MODEM_RESET_HIGH; MODEM_PWRKEY_LOW; GPS_PWREN_LOW; IWDG_Configuration(3000); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, DISABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2 | RCC_APB1Periph_USART3, DISABLE); ADC_Cmd (ADC1,DISABLE);//使能或者失能指定的ADC RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, DISABLE); os_tsk_delete(idModemUartTask); os_tsk_delete(idModemTask); ADCInit();//ADC Init while(1) { Vbat=GetVbat(); if(Vbat>375){ while(1); } os_dly_wait(1000); IWDG_ReloadCounter(); } } #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; MODEM_LED1_HIGH; MODEM_LED2_LOW; OnOff_Init2(); IWDG_Configuration(3000);////////////// SetLedStatus(NotBright); PWR_EN_LOW; ENTERSTOPMODE: //设置闹铃时间 dev_rtc_setAlarm(10); // 进入停机模式 printf("time go go step1\r\n"); MODEM_LED1_LOW;//均不亮 HIGH EXTI_ClearITPendingBit(EXTI_Line17); // 清//EXTI_Line9 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); //使能PWR外设时钟 PWR_WakeUpPinCmd(ENABLE); //使能唤醒管脚功能 if((GPIO_ReadInputDataBit(CHARGEChek_PORT,CHARGEChek_PIN)==SET)) { CHARGE_IC_LOW; //之后需要改LOW //开始充电 }else { // CHARGE_IC_HIGH; } PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI); // RTC时间到达 if(dev_rtc_isAlarm()) { IWDG_ReloadCounter(); SystemInit(); ADCInit(); ADC_Cmd (ADC1,ENABLE); DelayMs(1000); printf("Vbat====%d\r\n",GetOneceVbat()); // if(GetOneceVbat()>53){ // printf("Wake Up\r\n"); // while(1); // } goto ENTERSTOPMODE; SlwTrace(INF,"time coming333\r\n",1); } } #endif void SleepMethod2() { SlwTrace(INF, "Sleeping",1); KEYBOARD_BACKLIGHT_LOW; SpeakerDisable();MicDisable(); LCD_BL_LOW; MODEM_RESET_HIGH; MODEM_PWRKEY_LOW; GPS_PWREN_LOW; MODEM_LED1_HIGH; MODEM_LED2_LOW; PWR_EN_LOW; if((GPIO_ReadInputDataBit(CHARGEChek_PORT,CHARGEChek_PIN)==SET)) { CHARGE_IC_LOW; //之后需要改LOW //开始充电 }else { // CHARGE_IC_HIGH; } PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI); } 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 sccess */ 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; }